1 #ifndef LAP_DoublePackedUpperMatrix_H
2 #define LAP_DoublePackedUpperMatrix_H
63 inline static SP::LAP_DoublePackedUpperMatrix
New() {
71 SP::LAP_DoublePackedUpperMatrix p=
New();
107 getPackedStorage()^=s;
114 getPackedStorage()*=s;
120 getPackedStorage()/=s;
127 getPackedStorage()+=s;
135 getPackedStorage()-=s;
145 getPackedStorage()*=s.getPackedStorage();
151 getPackedStorage()/=s.getPackedStorage();
158 getPackedStorage()-=s.getPackedStorage();
164 getPackedStorage()+=s.getPackedStorage();
234 n=( ((sqrt(1+8*n)-1)/2) +0.5);
357 if (alpha!=1) X*=alpha;
398 if (nRows==0)
return;
400 if (isTrans) std::swap(nRows,nCols);
406 throw LAP_Exception(
"math/linalg/core",
"LAP_DoublePackedUpperMatrix::product()",
"incompatible size of X vector");
410 throw LAP_Exception(
"math/linalg/core",
"LAP_DoublePackedUpperMatrix::product()",
"only squared matrix");
420 if (alpha!=1) Y*=alpha;
427 throw LAP_Exception(
"math/linalg/core",
"LAP_DoublePackedUpperMatrix::product()",
"incompatible size of Y vector");
454 if (isTrans) std::swap(nRows,nCols);
460 throw LAP_Exception(
"math/linalg/core",
"LAP_DoublePackedUpperMatrix::product()",
"incompatible size of X vector");
468 throw LAP_Exception(
"math/linalg/core",
"LAP_DoublePackedUpperMatrix::product()",
"incompatible size of Y vector");
495 if (nRows==0)
return;
498 throw LAP_Exception(
"math/linalg/core",
"LAP_DoublePackedUpperMatrix::product()",
499 "X=A.X needs to have a squared matrix");
502 throw LAP_Exception(
"math/linal/core",
"LAP_DoublePackedUpperMatrix::product",
"incompatible size of X vector");
524 const double& alpha,
const double& beta,
541 throw LAP_Exception(
"math/linal/core",
" LAP_DoublePackedUpperMatrix:rankDProduct",
"incompatible dimension of vector");
544 throw LAP_Exception(
"math/linal/core",
" LAP_DoublePackedUpperMatrix:rankDProduct",
"incompatible dimension of vector");
547 throw LAP_Exception(
"math/linal/core",
" LAP_DoublePackedUpperMatrix:rankDProduct",
"incompatible dimension of vectors");
559 X.getSize(),X.getIncrement(),&X(0));
571 throw LAP_Exception(
"math/linal/core",
" LAP_DoublePackedUpperMatrix:rankProduct",
"incompatible dimension of vector");
574 throw LAP_Exception(
"math/linal/core",
" LAP_DoublePackedUpperMatrix:rankProduct",
"incompatible dimension of vector");
715 const double *A_ii=&A(0,0);
716 for (i=0;i<nRows;i++) {
767 if (nRows==0)
return;
769 throw LAP_Exception(
"math/linal/core",
" LAP_DoublePackedUpperMatrix:solve",
"incompatible dimension of vector");
771 throw LAP_Exception(
"math/linal/core",
" LAP_DoublePackedUpperMatrix:solve",
"only be used with squared matrix");
786 return solve(isTrans,*
this,X);
807 if (nARows==0)
return true;
810 throw LAP_Exception(
"math/linal/core",
" LAP_DoublePackedUpperMatrix:solve",
"incompatible size of matrices");
834 if (nRows==0)
return true;
virtual tReal norm2() const
return norm2 sqrt(sum_ij(aij^2))=sqrt(tr(AtA));
Definition: LAP_DoublePackedUpperMatrix.cpp:189
virtual ~LAP_DoublePackedUpperMatrix()
destroy a matrix
Definition: LAP_DoublePackedUpperMatrix.cpp:24
LAP_DoublePackedUpperMatrix & operator-=(const lapack_real &s)
sub s to the upper matrix
Definition: LAP_DoublePackedUpperMatrix.h:134
this class describes the exceptions raised for LAP package
Definition: LAP_Exception.h:14
LAP_DoubleMatrixStorage & getStorage()
set the storage
Definition: LAP_DoubleMatrix.h:179
virtual void vectorProduct(const tBoolean &isTrans, const LAP_DoubleVector &X, LAP_DoubleVector &Y) const
return Y=op(This).X
Definition: LAP_DoublePackedUpperMatrix.h:378
this class describes a packed storage by column
Definition: LAP_DoublePackedStorage.h:21
LAP_DoublePackedUpperMatrix & operator=(const double &s)
init all the matrix to s
Definition: LAP_DoublePackedUpperMatrix.h:176
virtual void setValuesPointer(SP::LAP_DoubleVector v)
set the vector values by reference
Definition: LAP_DoubleMatrixStorage.h:132
virtual void getColumn(const tLVectorIndex &j, LAP_DoubleVector &v) const
get the j-th column of this symmetric matrix in a vector
Definition: LAP_DoublePackedUpperMatrix.cpp:113
void vectorProduct(const tBoolean &isTrans, const tLVectorIndex &nX, const tLVectorIncrement &incX, double *X) const
compute X:=op(A). X
Definition: LAP_DoublePackedUpperMatrix.h:491
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_DoublePackedUpperMatrix.h:275
virtual tBoolean copy(const LAP_DoubleMatrix &x)
copy a matrix
Definition: LAP_DoubleMatrix.cpp:18
double & getNullValue()
get a null value
Definition: LAP_Object.h:54
virtual void setValues(const tLVectorIndex &n, const double *values)
set the values
Definition: LAP_DoublePackedUpperMatrix.h:245
virtual void getRow(const tLVectorIndex &i, SP::LAP_DoubleVector v) const
get the i-th row in a vector
Definition: LAP_DoublePackedUpperMatrix.h:286
LAP_DoublePackedUpperMatrix & operator-=(const LAP_DoublePackedUpperMatrix &s)
sub the viewed matrix
Definition: LAP_DoublePackedUpperMatrix.h:157
Definition: LAP_DoubleVector.h:20
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_DoublePackedUpperMatrix.h:96
Definition: LAP_DoubleMatrix.h:18
void DoublePackedUpperMatrixVectorProduct(const tBoolean &isTransA, const tLVectorIndex &nRowsA, const double *A, const tLVectorIndex &nX, const tLVectorIncrement &incX, double *x)
Definition: dpackeduppermatrix_functions.cpp:96
virtual tBoolean solve(const tBoolean &isTrans, LAP_DoubleFullGeneralMatrix &X) const
solve:
Definition: LAP_DoublePackedUpperMatrix.h:784
virtual void setSize(const tLVectorIndex &n, const tLVectorIndex &p)
set the dimension of the matrix n x p
Definition: LAP_Matrix.h:87
tLVectorIndex getSize() const
get the size of the vector
Definition: LAP_ConstVector.h:170
#define tBoolean
Definition: types.h:48
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_DoublePackedUpperMatrix.h:446
#define lapack_real
Definition: lapack_functions.h:9
LAP_DoublePackedUpperMatrix & operator*=(const lapack_real &s)
multiply by s the matrix
Definition: LAP_DoublePackedUpperMatrix.h:113
virtual tLVectorIndex getRowsNumber() const
get the lines number of the matrix from view
Definition: LAP_DoubleFullGeneralMatrix.h:366
virtual tBoolean copyLower(const LAP_DoubleFullGeneralMatrix &f)
copy the transposed of the full matrix
Definition: LAP_DoublePackedUpperMatrix.cpp:28
virtual SP::LAP_DoubleMatrix NewInstance() const
create a New instance of this
Definition: LAP_DoublePackedUpperMatrix.h:77
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_DoublePackedUpperMatrix.h:389
virtual void setValues(SP::LAP_DoubleVector values)
set the values set the pointer values of the matrix to values the size of the vector is mBandsNumber*...
Definition: LAP_DoublePackedUpperMatrix.h:229
virtual tBoolean computeEigenValues(LAP_DoubleVector &U) const
compute the eigen values of This
Definition: LAP_DoublePackedUpperMatrix.h:726
#define null
Definition: types.h:13
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_Vector.h:529
virtual void solve(const tBoolean &isTrans, LAP_DoubleVector &B) const
solve:
Definition: LAP_DoublePackedUpperMatrix.h:746
void init(const double &v)
init the values
Definition: LAP_DoubleMatrixStorage.h:124
LAP_DoublePackedUpperMatrix()
build a matrix
Definition: LAP_DoublePackedUpperMatrix.cpp:12
virtual void setValuesNumber(const tLVectorIndex &n)
set the values number
Definition: LAP_DoubleMatrixStorage.h:155
Definition: LAP_DoubleFullGeneralMatrix.h:30
tLVectorIndex getSize() const
get the size of the vector
Definition: LAP_Vector.h:519
virtual void setSize(const tLVectorIndex &n)
set the dimension of the matrix
Definition: LAP_DoublePackedUpperMatrix.h:216
void DoublePackedUpperMatrixVectorSolve(const tBoolean &isTransA, const tLVectorIndex &nARows, const double *A, const tLVectorIndex &nB, const tLVectorIncrement &incB, double *B)
Definition: dpackeduppermatrix_functions.cpp:181
static SP::LAP_DoublePackedUpperMatrix New()
Definition: LAP_DoublePackedUpperMatrix.h:63
LAP_DoublePackedUpperMatrix & operator=(const LAP_DoubleMatrix &s)
init all the matrix to s
Definition: LAP_DoublePackedUpperMatrix.h:182
LAP_DoublePackedUpperMatrix & operator/=(const lapack_real &s)
divide by s the matrix v
Definition: LAP_DoublePackedUpperMatrix.h:119
tBoolean inverse()
inverse the matrix
Definition: LAP_DoublePackedUpperMatrix.h:821
this class describes a general double symmetric matrix
Definition: LAP_DoubleUpperMatrix.h:17
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_DoublePackedUpperMatrix.h:675
virtual void getRow(const tLVectorIndex &i, LAP_DoubleVector &v) const
get the i-th row in a vector
Definition: LAP_DoublePackedUpperMatrix.cpp:75
LAP_DoublePackedUpperMatrix & operator+=(const LAP_DoublePackedUpperMatrix &s)
add the viewed matrix
Definition: LAP_DoublePackedUpperMatrix.h:163
tBoolean DoublePackedUpperMatrixInverse(const tLVectorIndex &nRows, double *A)
Definition: dpackeduppermatrix_functions.cpp:394
virtual void rankProduct(const tBoolean &isTransU, const LAP_DoubleVector &Diag, LAP_DoubleVector &X) const
compute product
Definition: LAP_DoublePackedUpperMatrix.h:535
static tBoolean solve(const tBoolean &isTransA, const LAP_DoublePackedUpperMatrix &A, LAP_DoubleFullGeneralMatrix &B)
solve:
Definition: LAP_DoublePackedUpperMatrix.h:798
void matrixProduct(const LAP_DoubleFullGeneralMatrix &B, LAP_DoubleFullGeneralMatrix &C) const
return C=(This) . B
Definition: LAP_DoublePackedUpperMatrix.h:622
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_DoublePackedUpperMatrix.cpp:384
#define tLVectorIndex
Definition: lapack_types.h:13
this class describes a packed upper matrix for lapack used where values are stored in vector: {A(0...
Definition: LAP_DoublePackedUpperMatrix.h:29
DEFINE_SPTR(LAP_DoublePackedMatrix)
void vectorProduct(const tBoolean &isTrans, const double &alpha, LAP_DoubleVector &X) const
Definition: LAP_DoublePackedUpperMatrix.h:348
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_DoublePackedUpperMatrix.h:662
virtual void solve(const tBoolean &isTrans, const tLVectorIndex &nB, const tLVectorIncrement &incB, double *B) const
solve:
Definition: LAP_DoublePackedUpperMatrix.h:762
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_ConstVector.h:175
static tBoolean inverse(LAP_DoublePackedUpperMatrix &A)
inverse a symmetric matrix dsytrf & dsytri lapack methods called
Definition: LAP_DoublePackedUpperMatrix.h:830
tLVectorIndex getLeadingDimension() const
get the memory distance between (*this)(i,j) & (*this)(i,j+1)
Definition: LAP_DoubleFullGeneralMatrix.h:351
virtual void vectorProduct(const tBoolean &isTrans, LAP_DoubleVector &X) const
compute X:=op(This).X
Definition: LAP_DoublePackedUpperMatrix.h:341
LAP_DoublePackedUpperMatrix & operator^=(const lapack_real &s)
power by s the matrix v
Definition: LAP_DoublePackedUpperMatrix.h:106
virtual void setSize(const tLVectorIndex &nRows, const tLVectorIndex &nCols)
set the dimension of the matrix
Definition: LAP_DoublePackedUpperMatrix.h:206
virtual tLVectorIndex getColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_DoubleFullGeneralMatrix.h:371
virtual void rankProduct(const tBoolean &isTransU, LAP_DoubleVector &X) const
compute product
Definition: LAP_DoublePackedUpperMatrix.h:567
LAP_DoublePackedUpperMatrix & operator*=(const LAP_DoublePackedUpperMatrix &s)
multiply the viewed matrices term by term
Definition: LAP_DoublePackedUpperMatrix.h:144
virtual tLVectorIndex getColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_Matrix.h:121
tBoolean DoublePackedUpperMatrixSolve(const tBoolean &isTransA, const tLVectorIndex &nARows, const double *A, const tLVectorIndex &nBCols, const tLVectorIndex &ldB, double *B)
Definition: dpackeduppermatrix_functions.cpp:433
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_DoublePackedUpperMatrix.cpp:211
static tBoolean computeEigenValues(const LAP_DoublePackedUpperMatrix &A, LAP_DoubleVector &U)
compute the eigen values of A and A is destroyed after method
Definition: LAP_DoublePackedUpperMatrix.h:708
LAP_DoublePackedUpperMatrix & operator+=(const lapack_real &s)
add s to the upper matrix
Definition: LAP_DoublePackedUpperMatrix.h:126
#define tLVectorIncrement
Definition: lapack_types.h:16
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
Definition: LAP_ConstDoubleVector.h:25
#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 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_DoublePackedUpperMatrix.h:89
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
virtual void setValues(const tLVectorIndex &n, const double *values)
copy the values
Definition: LAP_DoubleMatrixStorage.h:145
#define ASSERT_IN(a)
Definition: types.h:96
static SP::LAP_DoublePackedUpperMatrix New(const tLVectorIndex &n)
Definition: LAP_DoublePackedUpperMatrix.h:70
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14
LAP_DoublePackedUpperMatrix & operator/=(const LAP_DoublePackedUpperMatrix &s)
divide the viewed matrices term by term
Definition: LAP_DoublePackedUpperMatrix.h:150