1 #ifndef LAP_DoubleBandedSymmetricMatrix_H
2 #define LAP_DoubleBandedSymmetricMatrix_H
64 inline static SP::LAP_DoubleBandedSymmetricMatrix
New() {
72 SP::LAP_DoubleBandedSymmetricMatrix p=
New();
206 if (nBandsNumber<=0) {
221 if (nBandsNumber<=0) {
391 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleBandedSymmetricMatrix::product()",
"incompatible size of X vector");
400 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleBandedSymmetricMatrix::product()",
"incompatible size of Y vector");
426 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleBandedSymmetricMatrix::product()",
"incompatible size of X vector");
435 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleBandedSymmetricMatrix::product()",
"incompatible size of Y vector");
482 if (nRows==0)
return;
484 throw LAP_Exception(
"math/linal/core",
"LAP_DoubleBandedSymmetricMatrix::product",
"incompatible size of X vector");
487 throw LAP_Exception(
"math/linal/core",
"LAP_DoubleBandedSymmetricMatrix::product",
"incompatible size of Y vector");
490 throw LAP_Exception(
"math/linal/core",
"LAP_DoubleBandedSymmetricMatrix::product",
"x & y must have different pointer");
525 const tBoolean& isTransA,
const double* A);
594 if (!leftSide) std::swap(M,P);
596 if (N!=M)
throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleFullSymmetricMatrix::product()",
"incompatible size of matrix");
605 if (nBRows!=nBCols)
throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleFullSymmetricMatrix::product()",
"incompatible size of matrix");
615 nBRows,nBCols,incB,ldB,B,
650 if (!leftSide) std::swap(M,P);
652 if (N!=M)
throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleBandedSymmetricMatrix::product()",
"incompatible size of matrix");
690 throw LAP_Exception(
"math/linal/core",
"LAP_DoubleBandedSymmetricMatrix::computeEigenValues",
"matrix columns number must be greater than its rows number");
736 const int& il,
const int& iu)
const {
789 SP::LAP_DoubleVector vs;
791 if (succeeds) U->setValues(vs);
virtual tReal norm2() const
return norm2 sqrt(sum_ij(aij^2))=sqrt(tr(AtA));
Definition: LAP_DoubleBandedSymmetricMatrix.cpp:203
tBoolean computeEigenValueDecomposition(LAP_DoubleVector &U, LAP_DoubleFullGeneralMatrix &W) const
compute the eigen elements in ascending order of This the eigen vectors are set in This: This is dest...
Definition: LAP_DoubleBandedSymmetricMatrix.h:702
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
void setBandsNumber(const tLVectorIndex &n)
set bands number
Definition: LAP_DoubleBandedSymmetricMatrix.h:230
static SP::LAP_DoubleFullGeneralMatrix New()
Definition: LAP_DoubleFullGeneralMatrix.h:78
tBoolean DoubleBandedSymmetricMatrixEigenValues(const tLVectorIndex &nRowsA, const tLVectorIndex &nBandsA, double *A, const tLVectorIndex &nU, double *U, const tLVectorIndex &ldW, double *W)
compute all the eigen values or vectors (if W is not null or ldW<=1)
Definition: dbandedsymmatrix_functions.cpp:375
double get(const tLVectorIndex &i, const tLVectorIndex &j) const
get the value taking into account the view
Definition: LAP_DoubleMatrix.h:172
virtual SP::LAP_DoubleUpperMatrix choleskyFactorization()
compute the choleskey factorization of the full symmetric matrix A is modified such that the upper ma...
Definition: LAP_DoubleBandedSymmetricMatrix.h:799
this class describes a general double symmetric matrix
Definition: LAP_DoubleSymmetricMatrix.h:21
tBoolean computeEigenValueDecomposition(LAP_DoubleVector &U, LAP_DoubleFullGeneralMatrix &VR, const int &il, const int &iu) const
compute the eigen elements in ascending order of This supposed to be symmetric, the eigen vectors are...
Definition: LAP_DoubleBandedSymmetricMatrix.h:734
virtual void vectorProduct(const tBoolean &isTrans, const tLVectorIndex &nX, const tLVectorIncrement &incX, const double *X, const lapack_real &alpha, const lapack_real &beta, const tLVectorIndex &nY, const tLVectorIncrement &incY, double *Y) const
compute Y= op(This). X with op(A)=A or tA depending on isTrans value
Definition: LAP_DoubleBandedSymmetricMatrix.h:456
tLVectorIncrement getRowIncrement() const
get the memory distance between (*this)(i,j) & (*this)(i+1,j)
Definition: LAP_DoubleFullGeneralMatrix.h:346
virtual void setValuesPointer(SP::LAP_DoubleVector v)
set the vector values by reference
Definition: LAP_DoubleMatrixStorage.h:132
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_DoubleBandedSymmetricMatrix.h:89
virtual void setSize(const tLVectorIndex &n)
set the dimension of the matrix
Definition: LAP_DoubleBandedSymmetricMatrix.h:217
virtual tBoolean computeEigenValues(LAP_DoubleVector &U) const
compute the eigen values of This: A is copied in ascending order
Definition: LAP_DoubleBandedSymmetricMatrix.h:678
virtual tBoolean copy(const LAP_DoubleMatrix &x)
copy a matrix
Definition: LAP_DoubleMatrix.cpp:18
tBoolean compile()
compile the banded matrix
Definition: LAP_DoubleBandedSymmetricMatrix.h:267
LAP_DoubleBandedSymmetricMatrix & operator-=(const lapack_real &s)
sub s to the upper matrix
Definition: LAP_DoubleBandedSymmetricMatrix.h:153
tBoolean compile()
compile the matrix to optimal bands number
Definition: LAP_DoubleBandedStorage.h:222
LAP_DoubleBandedSymmetricMatrix & operator+=(const LAP_DoubleBandedSymmetricMatrix &s)
add the viewed matrix
Definition: LAP_DoubleBandedSymmetricMatrix.h:182
Definition: LAP_DoubleVector.h:20
#define lapack_int
Definition: lapack_functions.h:7
tBoolean DoubleBandedSymmetricMatrixBoundedEigenValues(const tLVectorIndex &nRowsA, const tLVectorIndex &nBandsA, double *A, const tLVectorIndex &nU, double *U, const tLVectorIndex &minIndex, const tLVectorIndex &maxIndex, const double &minBound, const double &maxBound, const tLVectorIndex &ldQ, double *Q, const tLVectorIndex &ldW, double *W)
compute the selected eigen values or vectors (if W is not null or ldW<=1) with
Definition: dbandedsymmatrix_functions.cpp:491
Definition: LAP_DoubleMatrix.h:18
void DoubleBandedSymmetricMatrixVectorProduct(const tLVectorIndex &nX, const tLVectorIncrement &incX, const double *x, const tLVectorIndex &nRows, const tLVectorIndex &nBands, const double *A, const lapack_real &alpha, const lapack_real &beta, const tLVectorIndex &nY, const tLVectorIncrement &incY, double *y)
compute Y:=Beta.Y+alpha A.X
Definition: dbandedsymmatrix_functions.cpp:108
this class describes a banded storage for lapack used where values are stored in vector of size (nSBa...
Definition: LAP_DoubleBandedStorage.h:24
LAP_DoubleBandedSymmetricMatrix & operator-=(const LAP_DoubleBandedSymmetricMatrix &s)
sub the viewed matrix
Definition: LAP_DoubleBandedSymmetricMatrix.h:176
const LAP_DoubleBandedStorage & getBandedStorage() const
get the banded storage
Definition: LAP_DoubleBandedSymmetricMatrix.h:282
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_DoubleBandedSymmetricMatrix.h:302
static tBoolean computeEigenValueDecomposition(LAP_DoubleBandedSymmetricMatrix &A, LAP_DoubleVector &U, LAP_DoubleFullGeneralMatrix &Z, LAP_DoubleFullGeneralMatrix &Q, const lapack_int &il, const lapack_int &ul)
compute the eigen elements of A in ascending order . A is supposed to be symmetric, the eigen vectors are set in Z, A must be symmetric. only the eigen values & vectors are computed in index il and iu when the iegen values are ordering in an ascent order.
Definition: LAP_DoubleBandedSymmetricMatrix.h:752
virtual void setSize(const tLVectorIndex &n, const tLVectorIndex &p)
set the dimension of the matrix n x p
Definition: LAP_Matrix.h:87
const tLVectorIndex & setBandsNumber(const tLVectorIndex &u, const tLVectorIndex &l)
set bands number
Definition: LAP_DoubleBandedStorage.h:209
tLVectorIndex getSize() const
get the size of the vector
Definition: LAP_ConstVector.h:170
const tLVectorIndex & getBandsNumber() const
get bands number
Definition: LAP_DoubleBandedSymmetricMatrix.h:288
#define tBoolean
Definition: types.h:48
static void matrixProduct(const tBoolean &leftSide, const LAP_DoubleBandedSymmetricMatrix &S, const LAP_DoubleFullGeneralMatrix &B, const lapack_real &alpha, const lapack_real &beta, LAP_DoubleFullGeneralMatrix &C)
compute :
Definition: LAP_DoubleBandedSymmetricMatrix.h:638
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_DoubleBandedSymmetricMatrix.h:96
virtual void setSize(const tLVectorIndex &n, const tLVectorIndex &p)
set the dimension of the matrix and allocate the values array
Definition: LAP_DoubleFullGeneralMatrix.h:230
static SP::LAP_DoubleBandedUpperMatrix New()
Definition: LAP_DoubleBandedUpperMatrix.h:65
virtual SP::LAP_DoubleMatrix matrixProduct(const LAP_DoubleMatrix &B) const
return C=(This) . B
Definition: LAP_DoubleBandedSymmetricMatrix.h:532
#define lapack_real
Definition: lapack_functions.h:9
LAP_DoubleBandedSymmetricMatrix & operator/=(const lapack_real &s)
divide by s the matrix v
Definition: LAP_DoubleBandedSymmetricMatrix.h:138
virtual tLVectorIndex getRowsNumber() const
get the lines number of the matrix from view
Definition: LAP_DoubleFullGeneralMatrix.h:366
virtual void matrixProduct(const tBoolean &leftSide, const tLVectorIndex &nBRows, const tLVectorIndex &nBCols, const tLVectorIncrement &incB, const tLVectorIndex &ldB, const double *B, const lapack_real &alpha, const lapack_real &beta, LAP_DoubleFullGeneralMatrix &C) const
make the product:
Definition: LAP_DoubleBandedSymmetricMatrix.h:578
const tLVectorIndex & getBandsNumber() const
get the bands number
Definition: LAP_DoubleBandedStorage.h:237
const tLVectorIndex & getUpperBandsNumber() const
get the upper bands number
Definition: LAP_DoubleBandedStorage.h:242
#define null
Definition: types.h:13
this class describes a packed symmetric matrix for lapack used where values are stored in vector: {A(...
Definition: LAP_DoubleBandedSymmetricMatrix.h:28
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_Vector.h:529
LAP_DoubleBandedStorage & getBandedStorage()
GET.
Definition: LAP_DoubleBandedSymmetricMatrix.h:277
void init(const double &v)
init the values
Definition: LAP_DoubleMatrixStorage.h:124
const tLVectorIndex & getUpperBandsNumber() const
get upper bands number
Definition: LAP_DoubleBandedSymmetricMatrix.h:293
virtual void setValuesNumber(const tLVectorIndex &n)
set the values number
Definition: LAP_DoubleMatrixStorage.h:155
void rankSymmetricProduct(const double alpha, const tBoolean &isTransA, const LAP_DoubleFullGeneralMatrix &A)
compute the symmetric matrix This:=alpha. op(A).t(op(A))
Definition: LAP_DoubleBandedSymmetricMatrix.h:508
Definition: LAP_DoubleFullGeneralMatrix.h:30
tLVectorIndex getSize() const
get the size of the vector
Definition: LAP_Vector.h:519
virtual void getValuesPointer(SP::LAP_DoubleVector &v)
Definition: LAP_DoubleMatrixStorage.h:208
LAP_DoubleBandedSymmetricMatrix()
build a matrix
Definition: LAP_DoubleBandedSymmetricMatrix.cpp:15
LAP_DoubleBandedSymmetricMatrix & operator*=(const LAP_DoubleBandedSymmetricMatrix &s)
multiply the viewed matrices term by term
Definition: LAP_DoubleBandedSymmetricMatrix.h:163
virtual void setValues(const tLVectorIndex &n, const double *values)
set the values
Definition: LAP_DoubleBandedSymmetricMatrix.h:257
LAP_DoubleBandedSymmetricMatrix & operator+=(const lapack_real &s)
add s to the upper matrix
Definition: LAP_DoubleBandedSymmetricMatrix.h:145
virtual void setSize(const tLVectorIndex &nRows, const tLVectorIndex &nCols)
set the dimension of the matrix
Definition: LAP_DoubleBandedSymmetricMatrix.h:202
tBoolean DoubleBandedSymmetricMatrixCholeskyFactorization(const tLVectorIndex &nRows, const tLVectorIndex &nBands, double *A)
make the cholesky factorization A=tU.U
Definition: dbandedsymmatrix_functions.cpp:707
static SP::LAP_DoubleBandedSymmetricMatrix New()
Definition: LAP_DoubleBandedSymmetricMatrix.h:64
LAP_DoubleBandedSymmetricMatrix & operator*=(const lapack_real &s)
multiply by s the matrix
Definition: LAP_DoubleBandedSymmetricMatrix.h:132
virtual void vectorProduct(const LAP_DoubleVector &X, const lapack_real &alpha, const lapack_real &beta, LAP_DoubleVector &Y) const
compute Y:=betaY+alpha.This.X
Definition: LAP_DoubleBandedSymmetricMatrix.h:380
#define tLVectorIndex
Definition: lapack_types.h:13
DEFINE_SPTR(LAP_DoubleBandedSymmetricMatrix)
LAP_DoubleBandedSymmetricMatrix & operator=(const LAP_DoubleMatrix &s)
init all the matrix to s
Definition: LAP_DoubleBandedSymmetricMatrix.h:114
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_ConstVector.h:175
virtual SP::LAP_DoubleMatrix NewInstance() const
create a New instance of this
Definition: LAP_DoubleBandedSymmetricMatrix.h:78
tLVectorIndex getLeadingDimension() const
get the memory distance between (*this)(i,j) & (*this)(i,j+1)
Definition: LAP_DoubleFullGeneralMatrix.h:351
virtual void vectorProduct(const LAP_DoubleVector &X, LAP_DoubleVector &Y)
compute Y=A.X
Definition: LAP_DoubleBandedSymmetricMatrix.h:370
void matrixProduct(const LAP_DoubleFullGeneralMatrix &B, LAP_DoubleFullGeneralMatrix &C) const
return C=(This) . B
Definition: LAP_DoubleBandedSymmetricMatrix.h:545
virtual void getRow(const tLVectorIndex &i, LAP_DoubleVector &v) const
get the i-th row in a vector
Definition: LAP_DoubleBandedSymmetricMatrix.cpp:36
virtual tLVectorIndex getColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_DoubleFullGeneralMatrix.h:371
virtual void vectorProduct(const LAP_ConstDoubleVector &X, const lapack_real &alpha, const lapack_real &beta, LAP_DoubleVector &Y) const
compute Y:=betaY+alpha.This.X
Definition: LAP_DoubleBandedSymmetricMatrix.h:415
virtual void getRow(const tLVectorIndex &i, SP::LAP_DoubleVector v) const
get the i-th row in a vector
Definition: LAP_DoubleBandedSymmetricMatrix.h:316
void rankSymmetricProduct(const LAP_DoubleFullGeneralMatrix &A)
compute the symmetric matrix This:=A. tA
Definition: LAP_DoubleBandedSymmetricMatrix.h:502
void DoubleBandedSymmetricMatrixMatrixProduct(const tBoolean &isLeftSide, const tLVectorIndex &nSRows, const tLVectorIndex &nSBands, const double *S, const tLVectorIndex &nBRows, const tLVectorIndex &nBCols, const tLVectorIncrement &incB, const tLVectorIndex &ldB, const double *B, const lapack_real &alpha, const lapack_real &beta, const tLVectorIndex &nCRows, const tLVectorIndex &nCCols, const tLVectorIncrement &incC, const tLVectorIndex &ldC, double *C)
Definition: dbandedsymmatrix_functions.cpp:256
virtual tLVectorIndex getColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_Matrix.h:121
virtual void vectorProduct(const tLVectorIndex &nx, const tLVectorIncrement &incx, const double *x, const lapack_real &alpha, const lapack_real &beta, const tLVectorIndex &ny, const tLVectorIncrement &incy, double *y) const
compute Y= betaY + alpha. This. X
Definition: LAP_DoubleBandedSymmetricMatrix.h:475
#define tLVectorIncrement
Definition: lapack_types.h:16
virtual void getColumn(const tLVectorIndex &j, LAP_DoubleVector &v) const
get the j-th column of this symmetric matrix in a vector
Definition: LAP_DoubleBandedSymmetricMatrix.cpp:102
virtual void matrixProduct(const tBoolean &leftSide, const LAP_DoubleFullGeneralMatrix &B, const lapack_real &alpha, const lapack_real &beta, LAP_DoubleFullGeneralMatrix &C) const
make the product if (leftSide) C = alpha. This . B +beta C if (!leftSide) C = alpha. B . This +beta C
Definition: LAP_DoubleBandedSymmetricMatrix.h:557
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_DoubleBandedSymmetricMatrix.h:243
LAP_DoubleBandedSymmetricMatrix & operator=(const double &s)
init all the matrix to s
Definition: LAP_DoubleBandedSymmetricMatrix.h:108
Definition: LAP_ConstDoubleVector.h:25
virtual ~LAP_DoubleBandedSymmetricMatrix()
destroy a matrix
Definition: LAP_DoubleBandedSymmetricMatrix.cpp:27
#define tReal
Definition: types.h:18
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_DoubleBandedSymmetricMatrix.cpp:255
virtual tLVectorIndex getRowsNumber() const
get the lines number of the matrix from view
Definition: LAP_Matrix.h:116
LAP_DoubleBandedSymmetricMatrix & operator^=(const lapack_real &s)
power by s the matrix v
Definition: LAP_DoubleBandedSymmetricMatrix.h:125
virtual SP::LAP_DoubleVector vectorProduct(const LAP_DoubleVector &X) const
compute This. X
Definition: LAP_DoubleMatrix.h:328
LAP_DoubleBandedSymmetricMatrix & operator/=(const LAP_DoubleBandedSymmetricMatrix &s)
divide the viewed matrices term by term
Definition: LAP_DoubleBandedSymmetricMatrix.h:169
void resetView()
set the view of the vector to all the values
Definition: LAP_Vector.h:352
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
static tBoolean computeEigenValues(LAP_DoubleBandedSymmetricMatrix &A, LAP_DoubleVector &U)
compute the eigen values of A in ascending order and A is destroyed after method lapack method dsyev ...
Definition: LAP_DoubleBandedSymmetricMatrix.h:685
#define ASSERT_IN(a)
Definition: types.h:96
static SP::LAP_DoubleBandedSymmetricMatrix New(const tLVectorIndex &n)
Definition: LAP_DoubleBandedSymmetricMatrix.h:71
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14