1 #ifndef LAP_DoubleMatrix_H
2 #define LAP_DoubleMatrix_H
30 SP::LAP_DoubleMatrixStorage mStorage;
102 if (x.get()!=
null)
return copy(*x.get());
119 inline void init(
const double v) {
154 mStorage->setValuesPointer(v);
160 mStorage->setValues(n,values);
180 if (mStorage.get()==
null) {
181 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleMatrix::getStorage()",
182 "a matrix must have a storage");
184 return *mStorage.get();
188 if (mStorage.get()==
null) {
189 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleMatrix::getStorage()",
190 "a matrix must have a storage");
192 return *mStorage.get();
258 mStorage->addDiagonal(alpha);
266 return mStorage->computeBandsNumber();
272 return mStorage->getFillRate();
277 return mStorage->getNullValuesNumber();
282 return mStorage->getValuesNumber();
296 inline static double zpow(
const double& f,
const int& n) {
303 if (n<0)
return zpow(1./f,-n);
308 for (
int i=0;i<n;i++) ret*=ret;
347 SP::LAP_DoubleVector& Y)
const {
348 if ((X.get()!=
null) &&
366 if (isTrans) std::swap(nRows,nCols);
368 if (nRows*nCols==0)
return;
372 throw LAP_Exception(
"math/linal/core",
"LAP_DoubleMatrix::product",
"incompatible size of vector");
400 const double& alpha,
const double& beta,
virtual tBoolean isUpper() const =0
return true if the matrix is upper
void set(const tLVectorIndex &i, const tLVectorIndex &j, const double &v)
set the value of the element at row i and column j
Definition: LAP_DoubleMatrix.h:128
double trace() const
return trace
Definition: LAP_DoubleMatrix.h:251
this class describes the exceptions raised for LAP package
Definition: LAP_Exception.h:14
virtual tBoolean isSymmetric() const =0
return true if the matrix is symmetric
LAP_DoubleMatrixStorage & getStorage()
set the storage
Definition: LAP_DoubleMatrix.h:179
virtual double trace() const =0
compute the trace of the storage
virtual void getRow(const tLVectorIndex &i, LAP_DoubleVector &v) const =0
get the i-th row in a vector
pair< tLVectorIndex, tLVectorIndex > computeBandsNumber() const
Definition: LAP_DoubleMatrix.h:265
virtual void vectorProduct(const tBoolean &isTrans, const LAP_DoubleVector &X, LAP_DoubleVector &Y) const
compute Y= op(This). X
Definition: LAP_DoubleMatrix.h:360
virtual ~LAP_DoubleMatrix()
destroy a matrix
Definition: LAP_DoubleMatrix.cpp:15
double & operator[](const tLVectorIndex &index)
get the element at index
Definition: LAP_DoubleMatrix.h:62
virtual tBoolean copy(const LAP_DoubleMatrix &x)
copy a matrix
Definition: LAP_DoubleMatrix.cpp:18
virtual void vectorProduct(const LAP_DoubleVector &X, LAP_DoubleVector &Y) const
compute Y= This. X
Definition: LAP_DoubleMatrix.h:337
Definition: LAP_DoubleVector.h:20
const LAP_DoubleMatrixStorage & getStorage() const
set the storage
Definition: LAP_DoubleMatrix.h:187
Definition: LAP_DoubleMatrix.h:18
virtual void setValues(const tLVectorIndex &n, const double *values)
set the values
Definition: LAP_DoubleMatrix.h:159
virtual void getRow(const tLVectorIndex &i, SP::LAP_DoubleVector v) const
get the j-th column in a vector
Definition: LAP_DoubleMatrix.h:218
virtual SP::LAP_DoubleMatrix NewInstance() const =0
create a New instance of this
tLVectorIndex getValuesNumber() const
get the number of values
Definition: LAP_DoubleMatrix.h:281
#define tBoolean
Definition: types.h:48
DEFINE_SPTR(LAP_DoubleMatrix)
void addDiagonal(const double &alpha)
This +=alpha.I.
Definition: LAP_DoubleMatrix.h:257
LAP_DoubleMatrix()
build a matrix
Definition: LAP_DoubleMatrix.cpp:6
virtual tReal norm2() const =0
return norm2 sqrt(sum_ij(aij^2))=sqrt(tr(AtA));
#define null
Definition: types.h:13
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_Vector.h:529
void init(const double &v)
init the values
Definition: LAP_DoubleMatrixStorage.h:124
virtual void getColumn(const tLVectorIndex &j, LAP_DoubleVector &v) const =0
get the j-th column in a vector
static double zpow(const double &f, const int &n)
compute the value of pow(f,n)=f^n
Definition: LAP_DoubleMatrix.h:296
virtual SP::LAP_DoubleMatrix matrixProduct(const LAP_DoubleMatrix &B) const =0
return C= This.B
tLVectorIndex getSize() const
get the size of the vector
Definition: LAP_Vector.h:519
virtual tReal sum(const tFlag &d, LAP_DoubleVector &s) const =0
make the sum among the direction if (d==ROW) sum all the columns of each row and size of s is the num...
virtual tBoolean computeEigenValues(LAP_DoubleVector &U) const =0
compute the eigen values of This: A is copied
virtual const double & operator()(const tLVectorIndex &i, const tLVectorIndex &j) const =0
get the element at row i & column j
void init(const double v)
init the values to v
Definition: LAP_DoubleMatrix.h:119
void add(const tLVectorIndex &i, const tLVectorIndex &j, const double &v)
add v to the view term (i,j) of the matrix
Definition: LAP_DoubleMatrix.h:139
#define tLVectorIndex
Definition: lapack_types.h:13
static SP::LAP_DoubleVector New()
create a new vector of double
Definition: LAP_DoubleVector.h:57
#define tString
Definition: types.h:49
tBoolean copy(SPC::LAP_DoubleMatrix x)
copy a matrix
Definition: LAP_DoubleMatrix.h:101
virtual void vectorProduct(SPC::LAP_DoubleVector &X, SP::LAP_DoubleVector &Y) const
rcompute Y= This X
Definition: LAP_DoubleMatrix.h:346
tLVectorIndex getNullValuesNumber() const
get the number of null values
Definition: LAP_DoubleMatrix.h:276
virtual void setValues(SP::LAP_DoubleVector v)
set the values of the matrix
Definition: LAP_DoubleMatrix.h:153
double getFillRate() const
get the fill rate of the matrix
Definition: LAP_DoubleMatrix.h:271
tBoolean copy(LAP_DoubleMatrix *x)
copy a matrix
Definition: LAP_DoubleMatrix.h:108
virtual tLVectorIndex getColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_Matrix.h:121
virtual void getColumn(const tLVectorIndex &j, SP::LAP_DoubleVector v) const
get the j-th column in a vector
Definition: LAP_DoubleMatrix.h:208
this class describes a general matrix for lapack used : the matrix is stored in column mValues={T_{0...
Definition: LAP_Matrix.h:15
#define tLVectorIncrement
Definition: lapack_types.h:16
virtual const T & get(const tLVectorIndex &i) const
get element at index i taking into account the view
Definition: LAP_Vector.h:513
void setStorage(SP::LAP_DoubleMatrixStorage s)
set the storage
Definition: LAP_DoubleMatrix.h:147
Definition: LAP_DoubleMatrixStorage.h:16
#define tReal
Definition: types.h:18
virtual tLVectorIndex getRowsNumber() const
get the lines number of the matrix from view
Definition: LAP_Matrix.h:116
virtual SP::LAP_DoubleVector vectorProduct(const LAP_DoubleVector &X) const
compute This. X
Definition: LAP_DoubleMatrix.h:328
virtual tString toString() const
print the matrix taking into account the view
Definition: LAP_DoubleMatrix.cpp:32
void setSize(const tLVectorIndex &n)
set the view to [0,n[ by 1 increment if values is too small, re-alocate it
Definition: LAP_Vector.h:360
const double & operator[](const tLVectorIndex &index) const
get the element at index
Definition: LAP_DoubleMatrix.h:55
#define tFlag
Definition: types.h:14