LinearOperator<T>.LeastSquaresSolve Method

Definition

Namespace: Extreme.Mathematics.LinearAlgebra
Assembly: Extreme.Numerics (in Extreme.Numerics.dll) Version: 8.1.23
Solves the system of simultaneous linear equations represented by this instance in the least squares sense.

Overload List

LeastSquaresSolve(Matrix<T>) Solves the system of linear equations for the specified right-hand side matrix in the least squares sense.
LeastSquaresSolve(Vector<T>) Solves the system of linear equations for the specified right-hand side vector.
LeastSquaresSolve(DenseMatrix<T>, Boolean) Solves the system of linear equations for the specified right-hand side dense matrix in the least squares sense and optionally overwrites the right-hand side with the solution.
LeastSquaresSolve(DenseVector<T>, Boolean) Solves the system of linear equations for the specified right-hand side dense vector in the least squares sense and optionally overwrites the right-hand side with the solution.

LeastSquaresSolve(Matrix<T>)

Solves the system of linear equations for the specified right-hand side matrix in the least squares sense.
C#
public Matrix<T> LeastSquaresSolve(
	Matrix<T> rightHandSide
)

Parameters

rightHandSide  Matrix<T>
A Matrix<T>.

Return Value

Matrix<T>
A DenseMatrix<T> containing the solution of the system of simultaneous linear equations.

Exceptions

ArgumentNullExceptionrightHandSide is null.
DimensionMismatchExceptionThe length of rightHandSide does not equal the number of rows of the matrix underlying this system of equations.

-or-

The matrix is not square.

MatrixSingularExceptionThe Matrix<T> underlying this system of equations is singular and does not have an inverse.
DimensionMismatchException

LeastSquaresSolve(Vector<T>)

Solves the system of linear equations for the specified right-hand side vector.
C#
public Vector<T> LeastSquaresSolve(
	Vector<T> rightHandSide
)

Parameters

rightHandSide  Vector<T>
A Vector<T>.

Return Value

Vector<T>
A DenseVector<T> containing the solution of the system of simultaneous linear equations.

Exceptions

ArgumentNullExceptionrightHandSide is null.
DimensionMismatchExceptionThe length of rightHandSide does not equal the number of rows in the matrix underlying this system of equations.
MatrixSingularExceptionThe Matrix<T> underlying this system of equations is singular and does not have an inverse.
DimensionMismatchExceptionThe Matrix<T> underlying this system of equations is not square.

LeastSquaresSolve(DenseMatrix<T>, Boolean)

Solves the system of linear equations for the specified right-hand side dense matrix in the least squares sense and optionally overwrites the right-hand side with the solution.
C#
public Matrix<T> LeastSquaresSolve(
	DenseMatrix<T> rightHandSide,
	bool overwrite
)

Parameters

rightHandSide  DenseMatrix<T>
A DenseMatrix<T>.
overwrite  Boolean
If false, a new DenseMatrix<T> instance containing the solution to the system of equations is returned. (This is the default.) If true, the matrix rightHandSide is overwritten by the solution.

Return Value

Matrix<T>
A DenseMatrix<T> containing the solution of the system of simultaneous linear equations.

Remarks

Note that the first parameter must be a DenseMatrix<T>. This is because this is the only matrix type whose elements are guaranteed to be all writable.

Exceptions

ArgumentNullExceptionrightHandSide is null.
DimensionMismatchExceptionThe number of rows of rightHandSide does not equal the number of rows of the matrix underlying this system of equations.
MatrixSingularExceptionThe Matrix<T> underlying this system of equations is singular and does not have an inverse.
DimensionMismatchExceptionThe Matrix<T> underlying this system of equations is not square.

LeastSquaresSolve(DenseVector<T>, Boolean)

Solves the system of linear equations for the specified right-hand side dense vector in the least squares sense and optionally overwrites the right-hand side with the solution.
C#
public Vector<T> LeastSquaresSolve(
	DenseVector<T> rightHandSide,
	bool overwrite
)

Parameters

rightHandSide  DenseVector<T>
A Vector<T>.
overwrite  Boolean
If false, a new Vector<T> instance containing the solution to the system of equations is returned. If false, the vector rightHandSide is overwritten by the solution.

Return Value

Vector<T>
A DenseVector<T> containing the solution of the system of simultaneous linear equations.

Exceptions

ArgumentNullExceptionrightHandSide is null.
DimensionMismatchExceptionThe length of rightHandSide does not equal the number of rows of the matrix underlying this system of equations.
MatrixSingularExceptionThe Matrix<T> underlying this system of equations is singular and does not have an inverse.
DimensionMismatchExceptionThe Matrix<T> underlying this system of equations is not square.

See Also