36#ifndef STK_LAPACK_MULTILEASTSQUARE_H
37#define STK_LAPACK_MULTILEASTSQUARE_H
61template<
class ArrayB,
class ArrayA>
class MultiLeastSquare;
69template<
class ArrayB_,
class ArrayA_>
100template<
class ArrayB,
class ArrayA>
119 template<
class ArrayB_,
class ArrayA_>
140 template<
class Weights>
158template<
class ArrayB,
class ArrayA>
161 Range brows = (b_.sizeRows()< a_.sizeCols()) ? a_.cols() : b_.rows();
164 b.
sub(b_.rows(), b_.cols()) = b_;
166 return computeLS(b,a);
172template<
class ArrayB,
class ArrayA>
173template<
class Weights>
177 Range brows = (b_.sizeRows()< a_.sizeCols()) ? a_.cols() : b_.rows();
180 b.
sub(b_.rows(), b_.cols()) =
w.sqrt().diagonalize() * b_;
182 return computeLS(b,a);
191{
return computeLS(b_,a_);}
195template<
class ArrayB,
class ArrayA>
212 int lda = a.sizeRows(),
ldb = b.sizeRows();
216 s_.resize(
m); s_ = 0.;
In this file we implement the final class CArrayVector.
In this file we implement the final class CArray.
In this file we define the interface class ILeastSquare.
#define STKERROR_NO_ARG(Where, Error)
#define STKERROR_1ARG(Where, Arg, Error)
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
#define STK_STATIC_ASSERT_ONE_DIMENSION_ONLY(EXPR)
In this file we define and implement utilities classes and methods for the interface with lapack.
Derived & resize(Range const &I, Range const &J)
resize the Array.
Derived & shift(int beginRows, int beginCols)
shift the Array.
hidden::CSliceDispatcher< Derived, Size >::Result sub(TRange< Size > const &J) const
implement the sub operator for 1D arrays using a reference on the row/column of the allocator
Type *const & p_data() const
The class ILeastSquare is an interface class for the methods solving the least-square problem.
ArrayB b_
Array or vector of the left hand side.
Integer rank_
rank of matrix A
hidden::AlgebraTraits< MultiLeastSquare< ArrayB, ArrayA > >::ArrayB ArrayB
ArrayA a_
Array of the right hand side.
ArrayB x_
Array of the solution (a vector if b is a vector, a matrix otherwise)
hidden::AlgebraTraits< MultiLeastSquare< ArrayB, ArrayA > >::ArrayA ArrayA
The class MultiLeastSQquare solve the least square problem when the response b is multidimensional.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Index sub-vector region: Specialization when the size is unknown.
The class MultiLeastSQquare solve the least square problem when the response b is multidimensional.
virtual ~MultiLeastSquare()
Destructor.
MultiLeastSquare(ExprBase< ArrayB_ > const &b, ExprBase< ArrayA_ > const &a)
template constructor
bool computeLS(CArrayXX &b, CArrayXX &a)
private method for computing the LS solution
ILeastSquare< MultiLeastSquare< ArrayB, ArrayA > > Base
bool runImpl()
solve the multi-linear least square problem.
CVectorX s_
Array of the singular values.
void setRcond(Real rcond)
Real rcond_
condition number used for determining the effective rank of A
CVectorX const & s() const
return the array with the singular values of A
MultiLeastSquare(ArrayB const &b, ArrayA const &a, bool isBref=false, bool isAref=false)
constructor
int gelsd(int m, int n, int nrhs, Real *a, int lda, Real *b, int ldb, Real *s, Real *rcond, int *rank, Real *work, int lWork, int *iwork)
wrapper of the LAPACK GELSD routine: computes the minimum-norm solution to a real linear least square...
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.
traits class for the algebra methods.