示例#1
0
        /// <summary>
        /// 解方程 A*X = B。A 为本矩阵。
        /// </summary>
        /// <param name="B">右侧矩阵</param>
        /// <returns></returns>
        public Matrix Solve(Matrix B)
        {
            if (_rowCount == _columnCount)
            {
                LUD    lu = new LUD(this);
                Matrix m  = lu.Solve(B);
                lu.Dispose();
                return(m);
            }

            if (_rowCount > _columnCount)
            {
                QRD    qr = new QRD(this);
                Matrix m  = qr.Solve(B);
                return(m);
            }

            throw new InvalidOperationException("Only square supported.");
        }
示例#2
0
        /// <summary>
        /// 解方程 A*X = B。A 为本矩阵。
        /// </summary>
        /// <param name="B">右侧矩阵</param>
        /// <returns></returns>
        public Matrix Solve(Matrix B)
        {
            if (_rowCount == _columnCount)
            {
                LUD lu = new LUD(this);
                Matrix m = lu.Solve(B);
                lu.Dispose();
                return m;
            }

            if (_rowCount > _columnCount)
            {
                QRD qr = new QRD(this);
                Matrix m = qr.Solve(B);
                return m;
            }

            throw new InvalidOperationException("Only square supported.");
        }