Accord.Math.Matrix.Solve C# (CSharp) Метод

Solve() публичный статический Метод

Returns the solution matrix if the matrix is square or the least squares solution otherwise.
Please note that this does not check if the matrix is non-singular before attempting to solve. If a least squares solution is desired in case the matrix is singular, pass true to the leastSquares parameter when calling this function.
public static Solve ( this matrix, decimal rightSide, bool leastSquares = false ) : ].decimal[
matrix this The matrix for the linear problem.
rightSide decimal The right side b.
leastSquares bool True to produce a solution even if the /// is singular; false otherwise. Default is false.
Результат ].decimal[
        public static decimal[,] Solve(this decimal[,] matrix, decimal[,] rightSide, bool leastSquares = false)
        {
            int rows = matrix.GetLength(0);
            int cols = matrix.GetLength(1);

            if (rows != rightSide.GetLength(0))
                throw new DimensionMismatchException("rightSide",
                    "The number of rows in the right hand side matrix must be "
                    + "equal to the number of rows in the problem matrix.");

            if (leastSquares)
            {
                return new SingularValueDecompositionD(matrix,
                       computeLeftSingularVectors: true,
                       computeRightSingularVectors: true,
                       autoTranspose: true).Solve(rightSide);
            }


            if (rows == cols)
            {
                // Solve by LU Decomposition if matrix is square.
                return new LuDecompositionD(matrix).Solve(rightSide);
            }
            else
            {
                if (cols < rows)
                {
                    // Solve by QR Decomposition if not.
                    return new QrDecompositionD(matrix).Solve(rightSide);
                }
                else
                {
                    return new SingularValueDecompositionD(matrix,
                        computeLeftSingularVectors: true,
                        computeRightSingularVectors: true,
                        autoTranspose: true).Solve(rightSide);
                }
            }
        }

Same methods

Matrix::Solve ( this matrix, decimal rightSide, bool leastSquares = false ) : decimal[]
Matrix::Solve ( this matrix, decimal rightSide, bool leastSquares = false ) : decimal[][]
Matrix::Solve ( this matrix, double rightSide, bool leastSquares = false ) : ].double[
Matrix::Solve ( this matrix, double rightSide, bool leastSquares = false ) : double[]
Matrix::Solve ( this matrix, double rightSide, bool leastSquares = false ) : double[][]
Matrix::Solve ( this matrix, float rightSide, bool leastSquares = false ) : ].float[
Matrix::Solve ( this matrix, float rightSide, bool leastSquares = false ) : float[]
Matrix::Solve ( this matrix, float rightSide, bool leastSquares = false ) : float[][]