1 #ifndef LINEAR_ALGEBRA_H 2 #define LINEAR_ALGEBRA_H 3 #include <blitz/array.h> 11 inline double sqr(
double x) {
return x * x;}
20 template<
class T,
int D> blitz::Array<T, D>
23 bool is_ok = In.isStorageContiguous();
24 for(
int i = 0; i < D; ++i)
25 if(In.ordering(i) != i ||
26 !In.isRankStoredAscending(i))
31 blitz::Array<T, D> res(In.shape(), blitz::ColumnMajorArray<D>());
43 template<
class T,
int D> blitz::Array<T, D>
46 bool is_ok = In.isStorageContiguous();
47 for(
int i = 0; i < D; ++i)
48 if(In.ordering(i) != D - i - 1||
49 !In.isRankStoredAscending(i))
54 blitz::Array<T, D> res(In.shape());
69 template<
class T,
int D> blitz::Array<T, D>
72 bool is_ok = In.isStorageContiguous();
73 for(
int i = 0; i < D; ++i)
74 if(In.ordering(i) != D - i - 1||
75 !In.isRankStoredAscending(i))
80 blitz::Array<T, D> res(In.shape());
94 bool is_ok = M.isStorageContiguous();
95 for(
int i = 0; i < D; ++i)
96 if(M.ordering(i) != i ||
97 !M.isRankStoredAscending(i))
102 M.reference(blitz::Array<T, D>(sz1, blitz::ColumnMajorArray<D>()));
113 bool is_ok = M.isStorageContiguous();
114 for(
int i = 0; i < D; ++i)
115 if(M.ordering(i) != i ||
116 !M.isRankStoredAscending(i))
121 M.reference(blitz::Array<T, D>(sz1, sz2, blitz::ColumnMajorArray<D>()));
133 bool is_ok = M.isStorageContiguous();
134 for(
int i = 0; i < D; ++i)
135 if(M.ordering(i) != i ||
136 !M.isRankStoredAscending(i))
139 M.resize(sz1, sz2, sz3);
141 M.reference(blitz::Array<T, D>(sz1, sz2, sz3,
142 blitz::ColumnMajorArray<D>()));
155 template<
class T,
int D> blitz::Array<T, D>
158 bool is_ok = In.isStorageContiguous();
159 for(
int i = 0; i < D; ++i)
160 if(In.ordering(i) != i ||
161 !In.isRankStoredAscending(i))
166 blitz::Array<T, D> res(In.shape(), blitz::ColumnMajorArray<D>());
173 const blitz::Array<double, 1>& B,
174 double Rcond = 1e-12);
177 const blitz::Array<double, 1>& B);
179 void svd(
const blitz::Array<double, 2>& A, blitz::Array<double, 1>& S,
180 blitz::Array<double, 2>& U, blitz::Array<double, 2>& VT);
185 double Rcond = std::numeric_limits<double>::epsilon());
187 const blitz::Array<bool, 1>& Zero_unused,
188 double Rcond = std::numeric_limits<double>::epsilon());
191 blitz::Array<double, 2>
multifit_covar(
const blitz::Array<double, 2>&
J,
192 double Eps_rel = std::numeric_limits<double>::epsilon());
194 double Eps_abs = std::numeric_limits<double>::epsilon());
195 bool multifit_test_delta(
const blitz::Array<double, 1>& dx,
const blitz::Array<double, 1>& x,
196 double Eps_abs = std::numeric_limits<double>::epsilon(),
197 double Eps_rel = std::numeric_limits<double>::epsilon());
void svd(const blitz::Array< double, 2 > &A, blitz::Array< double, 1 > &S, blitz::Array< double, 2 > &U, blitz::Array< double, 2 > &VT)
Compute the SVD decomposition of a matrix A = U * SIGMA * V^T.
blitz::Array< double, 1 > solve_least_squares(const blitz::Array< double, 2 > &A, const blitz::Array< double, 1 > &B, double Rcond=1e-12)
This solves the least squares system A*x = b, returning the minimum norm solution.
blitz::Array< T, D > to_fortran_const(const blitz::Array< T, D > &In)
Ensure that a given blitz::Array is contiguous, not reversed, and in fortran ColumnMajorArray format...
void fortran_resize(blitz::Array< T, 1 > &M, int sz1)
If matrix is in Fortran order, resize it.
blitz::Array< T, D > to_c_order_const(const blitz::Array< T, D > &In)
Ensure that a given blitz::Array is contiguous, not reversed, and in C RowMajorArray format...
blitz::Array< double, 2 > cholesky_decomposition(const blitz::Array< double, 2 > &A)
This calculates the Cholesky Decompostion of A so that A = L L^T.
const Unit A("A", 1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0)
blitz::Array< double, 1 > solve_least_squares_qr(const blitz::Array< double, 2 > &A, const blitz::Array< double, 1 > &B)
This finds the least squares solution to the overdetermined system A x = b where the matrix A has mor...
blitz::Array< double, 2 > multifit_covar(const blitz::Array< double, 2 > &J, double Eps_rel=std::numeric_limits< double >::epsilon())
bool multifit_test_gradient(const blitz::Array< double, 1 > &g, double Eps_abs=std::numeric_limits< double >::epsilon())
blitz::Array< double, 2 > generalized_inverse(const blitz::Array< double, 2 > &A, double Rcond=std::numeric_limits< double >::epsilon())
This returns the generalized inverse of the given matrix.
blitz::Array< T, D > to_fortran(const blitz::Array< T, D > &In)
Ensure that a given blitz::Array is contiguous, not reversed, and in fortran ColumnMajorArray format...
bool multifit_test_delta(const blitz::Array< double, 1 > &dx, const blitz::Array< double, 1 > &x, double Eps_abs=std::numeric_limits< double >::epsilon(), double Eps_rel=std::numeric_limits< double >::epsilon())
const Unit g("g", 1e-3 *kg)
Contains classes to abstract away details in various Spurr Radiative Transfer software.
blitz::Array< T, D > to_c_order(const blitz::Array< T, D > &In)
Ensure that a given blitz::Array is contiguous, not reversed, and in C RowMajorArray format...