1 #ifndef LAP_DoubleFullUpperMatrix_H
2 #define LAP_DoubleFullUpperMatrix_H
63 inline static SP::LAP_DoubleFullUpperMatrix
New() {
71 SP::LAP_DoubleFullUpperMatrix p=
New();
78 SP::LAP_DoubleFullUpperMatrix p=
New(nRows);
80 double *vs=&(*p.get())[0];
123 resetLowerSubMatrix();
178 getFullStorage()*=s.getFullStorage();
184 getFullStorage()/=s.getFullStorage();
191 getFullStorage()-=s.getFullStorage();
197 getFullStorage()+=s.getFullStorage();
207 void resetLowerSubMatrix();
248 SP::LAP_DoubleVector v) {
282 const double* values) {
287 getFullStorage().
setValues(n,n*p,values);
294 const double* values) {
299 getFullStorage().
setValues(nRows,n,values);
447 if (isTrans) std::swap(nRows,nCols);
453 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleFullUpperMatrix::product()",
"incompatible size of X vector");
461 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleFullUpperMatrix::product()",
"incompatible size of Y vector");
486 if (isTrans) std::swap(nRows,nCols);
492 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleFullUpperMatrix::product()",
"incompatible size of X vector");
500 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleFullUpperMatrix::product()",
"incompatible size of Y vector");
530 if (alpha!=1) X*=alpha;
560 cout <<
"WARNING:row increment matrix ignored in lapack functions. It is set to 1. \n";
564 if (nRows==0)
return;
567 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleFullUpperMatrix::product()",
568 "X=A.X needs to have a squared matrix");
571 throw LAP_Exception(
"math/linal/core",
"LAP_DoubleFullUpperMatrix::product",
"incompatible size of X vector");
595 const double& alpha,
const double& beta,
613 cout <<
"WARNING:row increment matrix ignored in lapack functions. It is set to 1. \n";
616 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleFullUpperMatrix:rankDProduct",
"incompatible dimension of vector");
619 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleFullUpperMatrix:rankDProduct",
"incompatible dimension of vector");
622 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleFullUpperMatrix:rankDProduct",
"incompatible dimension of vectors");
636 X.getSize(),X.getIncrement(),&X(0));
648 cout <<
"WARNING:row increment matrix ignored in lapack functions. It is set to 1. \n";
651 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleFullUpperMatrix:rankProduct",
"incompatible dimension of vector");
654 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleFullUpperMatrix:rankProduct",
"incompatible dimension of vector");
800 const double *A_ii=&A(0,0);
883 if (nRows==0)
return;
884 if (nRows!=nB)
throw LAP_Exception(
"math/linal/core",
" LAP_DoubleFullUpperMatrix:solve",
"incompatible dimension of vector");
886 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleFullUpperMatrix:solve",
"only be used with squared matrix");
908 return solve(isLeft,isTrans,*
this,alpha,X);
921 return solve(
true,isTrans,*
this,1.,X);
957 cout<<
"math/linal/core "<<
"LAP_DoubleFullUpperMatrix::inverseMatrix() "<<
"matrix is non-contiguous."<<endl;
LAP_DoubleFullUpperMatrix & operator+=(const LAP_DoubleFullUpperMatrix &s)
add the viewed matrix
Definition: LAP_DoubleFullUpperMatrix.h:196
this class describes the exceptions raised for LAP package
Definition: LAP_Exception.h:14
virtual void matrixProduct(const tBoolean &isTrans, const double &alpha, LAP_DoubleFullGeneralMatrix &A) const
compute A:=alpha op(This).A or A:=alpha A. op(This)
Definition: LAP_DoubleFullUpperMatrix.h:757
LAP_DoubleMatrixStorage & getStorage()
set the storage
Definition: LAP_DoubleMatrix.h:179
virtual ~LAP_DoubleFullUpperMatrix()
destroy a matrix
Definition: LAP_DoubleFullUpperMatrix.cpp:22
virtual tBoolean solve(const tBoolean &isTrans, LAP_DoubleFullGeneralMatrix &X) const
solve:
Definition: LAP_DoubleFullUpperMatrix.h:919
LAP_DoubleFullUpperMatrix & operator-=(const lapack_real &s)
sub s to the upper matrix
Definition: LAP_DoubleFullUpperMatrix.h:167
static SP::LAP_DoubleFullUpperMatrix New(const tLVectorIndex &n)
Definition: LAP_DoubleFullUpperMatrix.h:70
virtual tBoolean computeEigenValues(LAP_DoubleVector &U) const
compute the eigen values of This
Definition: LAP_DoubleFullUpperMatrix.h:811
void solve(const tBoolean &isTrans, LAP_DoubleVector &B) const
solve:
Definition: LAP_DoubleFullUpperMatrix.h:862
virtual void getRow(const tLVectorIndex &i, SP::LAP_DoubleVector v) const
get the i-th row in a vector
Definition: LAP_DoubleFullUpperMatrix.h:357
virtual tBoolean copyLower(const LAP_DoubleFullGeneralMatrix &f)
copy the transposed of the full matrix
Definition: LAP_DoubleFullUpperMatrix.cpp:58
virtual void vectorProduct(const LAP_DoubleVector &X, LAP_DoubleVector &Y) const
return Y=This.X
Definition: LAP_DoubleFullUpperMatrix.h:421
virtual tBoolean copy(const LAP_DoubleMatrix &x)
copy a matrix
Definition: LAP_DoubleMatrix.cpp:18
virtual void setSize(const tLVectorIndex &n)
set the dimension of the matrix and alocate the values array
Definition: LAP_DoubleFullUpperMatrix.h:237
double & getNullValue()
get a null value
Definition: LAP_Object.h:54
Definition: LAP_DoubleVector.h:20
Definition: LAP_DoubleMatrix.h:18
virtual void setValues(const tLVectorIndex &n, const tLVectorIndex &p, const double *values)
set the values
Definition: LAP_DoubleFullUpperMatrix.h:280
const tLVectorIncrement & getRowIncrement() const
get the row increment ie the memory distance between M(i,j) & M(i+1,j)
Definition: LAP_DoubleFullStorage.h:301
virtual tReal max(const tFlag &d, const tLVectorIndex &index) const
make get max among the direction if (d==ROW) max of all the columns of row index if (d==COL) max of a...
Definition: LAP_DoubleFullUpperMatrix.cpp:458
virtual void getRow(const tLVectorIndex &i, LAP_DoubleVector &v) const
get the i-th row in a vector
Definition: LAP_DoubleFullUpperMatrix.cpp:109
virtual double & operator()(const tLVectorIndex &i, const tLVectorIndex &j)
accessor of element at row i and column j taking into account the view only use the upper diagonal ...
Definition: LAP_DoubleFullUpperMatrix.h:103
virtual void getColumn(const tLVectorIndex &j, LAP_DoubleVector &v) const
get the j-th column of this symmetric matrix in a vector
Definition: LAP_DoubleFullUpperMatrix.cpp:148
LAP_DoubleFullUpperMatrix & operator+=(const lapack_real &s)
add s to the upper matrix
Definition: LAP_DoubleFullUpperMatrix.h:159
virtual void setSize(const tLVectorIndex &n, const tLVectorIndex &p)
set the dimension of the matrix n x p
Definition: LAP_Matrix.h:87
static tBoolean inverse(LAP_DoubleFullUpperMatrix &A)
inverse a symmetric matrix dsytrf & dsytri lapack methods called
Definition: LAP_DoubleFullUpperMatrix.h:954
tLVectorIndex getSize() const
get the size of the vector
Definition: LAP_ConstVector.h:170
virtual void setSize(const tLVectorIndex &n, const tLVectorIndex &p)
set the dimension of the matrix and allocate the values array
Definition: LAP_DoubleFullUpperMatrix.h:224
virtual tLVectorIndex getViewedRowsNumber() const
get the lines number of the matrix from view
Definition: LAP_DoubleFullStorage.h:285
virtual void setValues(const tLVectorIndex &n, const double *values)
set the values
Definition: LAP_DoubleFullUpperMatrix.h:293
void vectorProduct(const tBoolean &isTrans, const LAP_DoubleVector &X, const lapack_real &alpha, const lapack_real &beta, LAP_DoubleVector &Y) const
return Y=betaY+alpha.op(This).X
Definition: LAP_DoubleFullUpperMatrix.h:439
#define tBoolean
Definition: types.h:48
this class describes a full upper matrix for lapack used
Definition: LAP_DoubleFullUpperMatrix.h:29
tLVectorIncrement getRowIncrement() const
get the memory distance between (*this)(i,j) & (*this)(i+1,j)
Definition: LAP_DoubleFullUpperMatrix.h:320
void DoubleFullUpperMatrixVectorProduct(const tBoolean &isTransA, const tLVectorIndex &nRowsA, const tLVectorIndex &ldA, const double *A, const tLVectorIndex &nX, const tLVectorIncrement &incX, double *x)
compute X=op(A). X where op(A)=A or op(A)=tA where A is Upper matrix
Definition: dfulluppermatrix_functions.cpp:125
virtual void getColumn(const tLVectorIndex &j, SP::LAP_DoubleVector v) const
get the j-th column of this symmetric matrix in a vector
Definition: LAP_DoubleFullUpperMatrix.h:343
#define lapack_real
Definition: lapack_functions.h:9
virtual tBoolean solve(const tBoolean &isLeft, const tBoolean &isTrans, const double &alpha, LAP_DoubleFullGeneralMatrix &X) const
solve:
Definition: LAP_DoubleFullUpperMatrix.h:904
virtual void setValues(const tLVectorIndex &n, const tLVectorIndex &p, SP::LAP_DoubleVector v)
set the values of the matrix to V without allocation the values array
Definition: LAP_DoubleFullUpperMatrix.h:246
static SP::LAP_DoubleFullUpperMatrix New()
Definition: LAP_DoubleFullUpperMatrix.h:63
virtual tLVectorIndex getColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_DoubleFullUpperMatrix.h:335
LAP_DoubleFullUpperMatrix & operator-=(const LAP_DoubleFullUpperMatrix &s)
sub the viewed matrix
Definition: LAP_DoubleFullUpperMatrix.h:190
LAP_DoubleFullUpperMatrix & operator*=(const lapack_real &s)
multiply by s the matrix
Definition: LAP_DoubleFullUpperMatrix.h:146
#define null
Definition: types.h:13
virtual void rankProduct(const tBoolean &isTransU, const LAP_DoubleVector &Diag, LAP_DoubleVector &X) const
compute product
Definition: LAP_DoubleFullUpperMatrix.h:606
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_Vector.h:529
bool DoubleFullUpperMatrixInverse(const tLVectorIndex &nRowsA, const tLVectorIndex &ldA, double *A)
compute the inverse of the matrix
Definition: dfulluppermatrix_functions.cpp:341
void vectorProduct(const tBoolean &isTrans, const LAP_ConstDoubleVector &X, const lapack_real &alpha, const lapack_real &beta, LAP_DoubleVector &Y) const
return Y=betaY+alpha.op(This).X
Definition: LAP_DoubleFullUpperMatrix.h:478
void init(const double &v)
init the values
Definition: LAP_DoubleMatrixStorage.h:124
virtual void setValues(const tLVectorIndex &n, const double *values)
copy the values to the matrix values
Definition: LAP_DoubleFullStorage.h:195
LAP_DoubleFullUpperMatrix & operator*=(const LAP_DoubleFullUpperMatrix &s)
multiply the viewed matrices term by term
Definition: LAP_DoubleFullUpperMatrix.h:177
Definition: LAP_DoubleFullGeneralMatrix.h:30
tLVectorIndex getSize() const
get the size of the vector
Definition: LAP_Vector.h:519
virtual void setValues(SP::LAP_DoubleVector v)
set the values of the matrix to V without allocation the values array
Definition: LAP_DoubleFullUpperMatrix.h:265
virtual void vectorProduct(const tBoolean &isTrans, const LAP_DoubleVector &X, LAP_DoubleVector &Y) const
return Y=op(This).X
Definition: LAP_DoubleFullUpperMatrix.h:429
LAP_DoubleFullUpperMatrix & operator=(const LAP_DoubleFullUpperMatrix &s)
init all the matrix to s
Definition: LAP_DoubleFullUpperMatrix.h:128
virtual tBoolean computeEigenValueDecomposition(LAP_DoubleVector &U)
compute the eigen values decomposition on this: A is destroyed such that it contains the eigen vector...
Definition: LAP_DoubleFullUpperMatrix.cpp:762
void matrixProduct(const LAP_DoubleFullGeneralMatrix &B, LAP_DoubleFullGeneralMatrix &C) const
return C=(This) . B
Definition: LAP_DoubleFullUpperMatrix.h:704
virtual tReal sum(const tFlag &d, LAP_DoubleVector &s) const
make the sum among the direction if (d==ROW) sum all the columns of each row and size of s is the num...
Definition: LAP_DoubleFullUpperMatrix.cpp:335
LAP_DoubleFullUpperMatrix & operator^=(const lapack_real &s)
power by s the matrix v
Definition: LAP_DoubleFullUpperMatrix.h:139
virtual void setValuesNumber(const tLVectorIndex &nRows, const tLVectorIndex &n)
set the values number
Definition: LAP_DoubleFullStorage.h:213
virtual tLVectorIndex getViewedColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_DoubleFullStorage.h:290
void DoubleFullUpperMatrixVectorSolve(const tBoolean &isTransA, const tLVectorIndex &nARows, const tLVectorIndex &ldA, const double *A, const tLVectorIndex &nB, const tLVectorIncrement &incB, double *B)
solve op(A).X=Y and Y:=X
Definition: dfulluppermatrix_functions.cpp:403
void indexMin(tLVectorIndex &i, tLVectorIndex &j) const
get the index of the min view element in absolute value
Definition: LAP_DoubleFullUpperMatrix.cpp:492
DEFINE_SPTR(LAP_DoubleFullGeneralMatrix)
virtual const double & operator()(const tLVectorIndex &i, const tLVectorIndex &j) const
accessor of element at row i and column j taking into account the view only use the upper diagonal ...
Definition: LAP_DoubleFullUpperMatrix.h:110
Definition: LAP_DoubleFullStorage.h:29
this class describes a general double symmetric matrix
Definition: LAP_DoubleUpperMatrix.h:17
virtual tReal norm2() const
return norm2 sqrt(sum_ij(aij^2))=sqrt(tr(AtA));
Definition: LAP_DoubleFullUpperMatrix.cpp:279
virtual SP::LAP_DoubleMatrix matrixProduct(const LAP_DoubleMatrix &B) const
general return C=(This) . B Create a general full matrix and return it
Definition: LAP_DoubleFullUpperMatrix.cpp:685
static SP::LAP_DoubleFullUpperMatrix Identity(const tLVectorIndex &nRows)
create an identity matrix
Definition: LAP_DoubleFullUpperMatrix.h:77
#define tLVectorIndex
Definition: lapack_types.h:13
void vectorProduct(const tBoolean &isTrans, const tLVectorIndex &nX, const tLVectorIncrement &incX, double *X) const
compute X:=alpha. op(A). X
Definition: LAP_DoubleFullUpperMatrix.h:558
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_ConstVector.h:175
static tBoolean computeEigenValues(const LAP_DoubleFullUpperMatrix &A, LAP_DoubleVector &U)
compute the eigen values of A and A is destroyed after method
Definition: LAP_DoubleFullUpperMatrix.h:791
LAP_DoubleFullUpperMatrix & operator/=(const LAP_DoubleFullUpperMatrix &s)
divide the viewed matrices term by term
Definition: LAP_DoubleFullUpperMatrix.h:183
virtual void solve(const tBoolean &isTrans, const tLVectorIndex &nB, const tLVectorIncrement &incB, double *B) const
solve:
Definition: LAP_DoubleFullUpperMatrix.h:879
LAP_DoubleFullUpperMatrix()
build a matrix
Definition: LAP_DoubleFullUpperMatrix.cpp:6
void vectorProduct(const tBoolean &isTrans, const double &alpha, LAP_DoubleVector &X) const
Definition: LAP_DoubleFullUpperMatrix.h:521
virtual void setValuesPointer(SP::LAP_DoubleVector v)
set the values of without copying
Definition: LAP_DoubleFullStorage.h:180
virtual void matrixProduct(const tBoolean &isLeft, const tBoolean &isTrans, const double &alpha, LAP_DoubleFullGeneralMatrix &A) const
compute A:=alpha op(This).A or A:=alpha A. op(This)
Definition: LAP_DoubleFullUpperMatrix.h:744
virtual tLVectorIndex getRowsNumber() const
get the lines number of the matrix from view
Definition: LAP_DoubleFullUpperMatrix.h:330
#define tLVectorIncrement
Definition: lapack_types.h:16
tBoolean inverse()
inverse the matrix
Definition: LAP_DoubleFullUpperMatrix.h:945
virtual SP::LAP_DoubleMatrix NewInstance() const
create a New instance of this
Definition: LAP_DoubleFullUpperMatrix.h:92
void copy(const LAP_Vector< lapack_real > &v)
copy the vector v into this. the view is set to [0,v.getSize()[ the viewed values of v is copied into...
Definition: LAP_DoubleVector.h:222
tLVectorIndex getLeadingDimension() const
get the leading dimension ie the memory distance between M(i,j) & M(i,j+1)
Definition: LAP_DoubleFullStorage.h:296
Definition: LAP_ConstDoubleVector.h:25
virtual void vectorProduct(const tBoolean &isTrans, LAP_DoubleVector &X) const
compute X:=op(This).X
Definition: LAP_DoubleFullUpperMatrix.h:513
tLVectorIndex getLeadingDimension() const
get the memory distance between (*this)(i,j) & (*this)(i,j+1)
Definition: LAP_DoubleFullUpperMatrix.h:325
#define tReal
Definition: types.h:18
LAP_DoubleFullUpperMatrix & operator/=(const lapack_real &s)
divide by s the matrix v
Definition: LAP_DoubleFullUpperMatrix.h:152
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
#define ASSERT_IN(a)
Definition: types.h:96
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14
LAP_DoubleFullUpperMatrix & operator=(const double &s)
init all the matrix to s
Definition: LAP_DoubleFullUpperMatrix.h:121
virtual void rankProduct(const tBoolean &isTransU, LAP_DoubleVector &X) const
compute product
Definition: LAP_DoubleFullUpperMatrix.h:643