14 #include <boost/version.hpp>
16 #if BOOST_VERSION <= 103200
21 #include <boost/numeric/ublas/config.hpp>
22 #include <boost/numeric/ublas/storage.hpp>
23 #include <boost/numeric/ublas/functional.hpp>
24 #include <boost/numeric/ublas/operation.hpp>
27 #include <boost/numeric/ublas/vector.hpp>
28 #include <boost/numeric/ublas/matrix.hpp>
29 #include <boost/numeric/ublas/triangular.hpp>
30 #include <boost/numeric/ublas/lu.hpp>
31 #include <boost/numeric/ublas/io.hpp>
35 double UNorm (
const double *A,
int n,
const int m);
36 double*
M_Cholesky (
double *B,
double *q,
const int n);
38 double*
M_Invert (
double *Ap,
double *Bp,
const int n);
39 void RowMult (
const double a,
double *A,
const double b,
const double *B,
const int n);
40 double*
M_A_times_b (
double *y,
const double *A,
const int n,
const int m,
const double *b);
41 double*
M_Zero (
double *A,
const int n);
42 double*
M_Unit (
double *A,
const int n);
43 void M_Print (
const double *A,
const int n);
44 void M_Print (
const double *A,
const double *B,
const int n);
46 double *
V_Zero (
double *v,
const int n);
47 double *
V_Unit (
double *v,
const int n,
int k);
48 void V_Print (
const double *v,
const int n);
49 void V_Print (
const double *v,
const double *w,
const int n);
71 boost::numeric::ublas::matrix<T>
invert (boost::numeric::ublas::matrix<T> & input)
73 using namespace boost::numeric::ublas;
76 matrix<T> inverse(zero_matrix<T>(input.size1()));
81 permutation_matrix<std::size_t> pm(A.size1());
84 int res = lu_factorize(A, pm);
86 if (res != 0)
return inverse;
89 inverse.assign(identity_matrix<T>(A.size1()));
92 lu_substitute(A, pm, inverse);
double * M_Invert(double *Ap, double *Bp, const int n)
Matrix inversion of Ap will be stored in Bp.
double * V_Zero(double *v, const int n)
double * M_Cholesky(double *B, double *q, const int n)
Calculates the Cholesky decomposition of the positive-definite matrix B.
double * M_InvertPos(double *B, const int n)
Calculates a*A + b*B, where both A and B are rows of length n.
double * V_Unit(double *v, const int n, int k)
double UNorm(const double *A, int n, const int m)
Calculates the least upper bound norm.
void RowMult(const double a, double *A, const double b, const double *B, const int n)
Calculates a*A + b*B, where both A and B are rows of length n, returns as A.
void M_Print(const double *A, const int n)
Print matrix A of dimension [n,n] to cout.
double * M_A_times_b(double *y, const double *A, const int n, const int m, const double *b)
Calculates y[n] = A[n,m] * b[m], with dimensions indicated.
double * M_Zero(double *A, const int n)
Creates zero matrix A.
void V_Print(const double *v, const int n)
double * M_Unit(double *A, const int n)
Creates unit matrix A.
boost::numeric::ublas::matrix< T > invert(boost::numeric::ublas::matrix< T > &input)