Trait linxal::least_squares::LeastSquares
[−]
[src]
pub trait LeastSquares: Sized + Clone { fn compute_multi_full_into<D1, D2>(a: ArrayBase<D1, Ix2>, b: ArrayBase<D2, Ix2>) -> Result<LeastSquaresSolution<Self, Ix2>, LeastSquaresError> where D1: DataMut<Elem=Self> + DataOwned<Elem=Self>, D2: DataMut<Elem=Self> + DataOwned<Elem=Self>; fn compute_multi_degenerate_into<D1, D2>(a: ArrayBase<D1, Ix2>, b: ArrayBase<D2, Ix2>) -> Result<LeastSquaresSolution<Self, Ix2>, LeastSquaresError> where D1: DataMut<Elem=Self> + DataOwned<Elem=Self>, D2: DataMut<Elem=Self> + DataOwned<Elem=Self>; fn compute_multi_full<D1, D2>(a: &ArrayBase<D1, Ix2>, b: &ArrayBase<D2, Ix2>) -> Result<LeastSquaresSolution<Self, Ix2>, LeastSquaresError> where D1: Data<Elem=Self>, D2: Data<Elem=Self> { ... } fn compute_multi_degenerate<D1, D2>(a: &ArrayBase<D1, Ix2>, b: &ArrayBase<D2, Ix2>) -> Result<LeastSquaresSolution<Self, Ix2>, LeastSquaresError> where D1: Data<Elem=Self>, D2: Data<Elem=Self> { ... } fn compute_multi<D1, D2>(a: &ArrayBase<D1, Ix2>, b: &ArrayBase<D2, Ix2>) -> Result<LeastSquaresSolution<Self, Ix2>, LeastSquaresError> where D1: Data<Elem=Self>, D2: Data<Elem=Self> { ... } fn compute<D1, D2>(a: &ArrayBase<D1, Ix2>, b: &ArrayBase<D2, Ix1>) -> Result<LeastSquaresSolution<Self, Ix1>, LeastSquaresError> where D1: Data<Elem=Self>, D2: Data<Elem=Self> { ... } }
Multivariable least squares problem.
Find solutions to the following optimization;
min ||Ax - b||2
for an m
by n
matrix A. The solution is unique when the matrix
A is overdetermined, or of full rank. When A is underdtermined,
the solution returned is one of minimum norm.
The compute_multi_*
functions compute independents solutions
x_i
to min(||A*x_i
- b_i
||) for each column b_i
of b
. They
do not compute the solution X
of min(||A*X - b||).
Required Methods
fn compute_multi_full_into<D1, D2>(a: ArrayBase<D1, Ix2>, b: ArrayBase<D2, Ix2>) -> Result<LeastSquaresSolution<Self, Ix2>, LeastSquaresError> where D1: DataMut<Elem=Self> + DataOwned<Elem=Self>, D2: DataMut<Elem=Self> + DataOwned<Elem=Self>
Returns the solution x
to the least squares problem
min(||A*x - b||), for a non-degenerate A
.
Errors
Returns LeastSquaresError::Degenerate
when the coefficient
matrix a
is not of full rank (rank(a
) < min(m, n)).
fn compute_multi_degenerate_into<D1, D2>(a: ArrayBase<D1, Ix2>, b: ArrayBase<D2, Ix2>) -> Result<LeastSquaresSolution<Self, Ix2>, LeastSquaresError> where D1: DataMut<Elem=Self> + DataOwned<Elem=Self>, D2: DataMut<Elem=Self> + DataOwned<Elem=Self>
Similar to compute_multi_degenerate_into
, but doesn't modify the inputs.
Provided Methods
fn compute_multi_full<D1, D2>(a: &ArrayBase<D1, Ix2>, b: &ArrayBase<D2, Ix2>) -> Result<LeastSquaresSolution<Self, Ix2>, LeastSquaresError> where D1: Data<Elem=Self>, D2: Data<Elem=Self>
Similar to compute_multi_full_into
, but doesn't modify the inputs.
fn compute_multi_degenerate<D1, D2>(a: &ArrayBase<D1, Ix2>, b: &ArrayBase<D2, Ix2>) -> Result<LeastSquaresSolution<Self, Ix2>, LeastSquaresError> where D1: Data<Elem=Self>, D2: Data<Elem=Self>
Returns the solution x
to the least squares problem min(||A*x - b||), for any A
.
The matrix a
can possibly be degenerate.
fn compute_multi<D1, D2>(a: &ArrayBase<D1, Ix2>, b: &ArrayBase<D2, Ix2>) -> Result<LeastSquaresSolution<Self, Ix2>, LeastSquaresError> where D1: Data<Elem=Self>, D2: Data<Elem=Self>
Returns the solution x
to the least squares problem min(||A*x - b||) for any A
.
This method first assumes that the coefficent matrix a
is
non-degenerate and calls compute_multi_full
. If the matrix
is found to be degenerate, compute_multi_degenerate
is
called instead.
Remarks
If you know that your matrix is degenerate ahead of
time, it is more effiecient to instead call
compute_multi_degenerate
instead. If you want to know that
your matrix is non-degenerate and want to do something else in
that case, you should use compute_multi_full
instead, which
will return a Degenerate
error.
This method will never return LeastSquaresError::Degenerate
.
fn compute<D1, D2>(a: &ArrayBase<D1, Ix2>, b: &ArrayBase<D2, Ix1>) -> Result<LeastSquaresSolution<Self, Ix1>, LeastSquaresError> where D1: Data<Elem=Self>, D2: Data<Elem=Self>
Returns the solution x
to the least squares problem
min(||A*x - b||) for any A
and a single column b
.
This method first assumes that the coefficent matrix a
is
non-degenerate and calls compute_multi_full
. If the matrix
is found to be degenerate, compute_multi_degenerate
is
called instead.
Remarks
If you know that your matrix is degenerate ahead of
time, it is more effiecient to instead call
compute_multi_degenerate
instead. If you want to know that
your matrix is non-degenerate and want to do something else in
that case, you should use compute_multi_full
instead, which
will return a Degenerate
error.
This method will never return LeastSquaresError::Degenerate
.