33 #define TF_LSQEXAMPLE_CC_VERSION \ 34 "TF_LSQEXAMPLE_CC V1.0" 44 #include <aff/iterator.h> 46 #include <aff/arrayoperators.h> 62 const int precision=5;
65 for (
int i=m.first(1); i<=m.last(1); ++i)
71 for (
int j=m.first(0); j<=m.last(0); ++j)
75 for (
int i=m.first(1); i<=m.last(1); ++i)
78 cout.precision(precision);
87 int main(
int iargc,
char* argv[])
95 tfxx::numeric::RNGgaussian rng;
107 aff::Iterator<Tmatrix> I(G);
118 aff::Iterator<Tmatrix> I(mknown);
127 cout <<
"Solve least squares problem" << endl;
128 cout <<
"===========================" << endl;
133 "Find solution such that |r|^2 becomes minimal" << endl;
139 cout <<
"\nMatrix of partial derivatives (G):\n";
141 cout <<
"\nData vector (d):\n";
151 cout <<
"\nSystem of linear equations to be solved:\n" 152 "M * m = rhs\n" << endl;
154 cout <<
"With matrix M=G^T*G:\n";
156 cout <<
"and vector rhs=G^T*d:\n";
164 cout <<
"\nsolution vector mopt:\n";
166 cout <<
"\nexpected solution (mknown):\n";
168 cout <<
"\nresidual (mopt-mknown):\n";
#define TF_LSQEXAMPLE_CC_VERSION
prototypes for C++ LAPACK interface functions (prototypes)
void printmatrix(const Tmatrix::Tcoc &m)
aff::Array< double > TDmatrix
TDmatrix transposeNxM(const TDmatrix::Tcoc &A)
calculate transpose of NxM matrix.
int main(int iargc, char *argv[])
matrix and vector operators (prototypes)
TDmatrix dotNxM(const TDmatrix::Tcoc &A, const TDmatrix::Tcoc &B)
dot product for NxM matrices.
void dposv(char UPLO, TDmatrix &A, TDmatrix &B, int &INFO, const bool &debug)
Compute the solution to a real system of linear equations A * X = B.