1 #ifndef LAP_DoubleBandedUpperMatrix_H
2 #define LAP_DoubleBandedUpperMatrix_H
65 inline static SP::LAP_DoubleBandedUpperMatrix
New() {
73 SP::LAP_DoubleBandedUpperMatrix p=
New();
210 if (nBandsNumber<=0) {
225 if (nBandsNumber<=0) {
392 if (alpha!=1) X*=alpha;
425 if (nRows==0)
return;
427 if (isTrans) std::swap(nRows,nCols);
433 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleBandedUpperMatrix::product()",
"incompatible size of X vector");
437 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleBandedUpperMatrix::product()",
"only squared matrix");
447 if (alpha!=1) Y*=alpha;
454 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleBandedUpperMatrix::product()",
"incompatible size of Y vector");
480 if (isTrans) std::swap(nRows,nCols);
486 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleBandedUpperMatrix::product()",
"incompatible size of X vector");
494 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleBandedUpperMatrix::product()",
"incompatible size of Y vector");
521 if (nRows==0)
return;
524 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleBandedUpperMatrix::product()",
525 "X=A.X needs to have a squared matrix");
528 throw LAP_Exception(
"math/linal/core",
"LAP_DoubleBandedUpperMatrix::product",
"incompatible size of X vector");
551 const double& alpha,
const double& beta,
563 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleBandedUpperMatrix:rankDProduct",
"incompatible dimension of vector");
566 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleBandedUpperMatrix:rankDProduct",
"incompatible dimension of vector");
569 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleBandedUpperMatrix:rankDProduct",
"incompatible dimension of vectors");
583 X.getSize(),X.getIncrement(),&X(0));
595 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleBandedUpperMatrix:rankProduct",
"incompatible dimension of vector");
598 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleBandedUpperMatrix:rankProduct",
"incompatible dimension of vector");
743 const double *A_ii=&A(0,0);
744 for (i=0;i<nRows;i++) {
795 if (nRows==0)
return;
796 if (nRows!=nB)
throw LAP_Exception(
"math/linal/core",
" LAP_DoubleBandedUpperMatrix:solve",
"incompatible dimension of vector");
798 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleBandedUpperMatrix:solve",
"only be used with squared matrix");
814 return solve(isTrans,*
this,X);
835 if (nARows==0)
return true;
838 throw LAP_Exception(
"math/linal/core",
" LAP_DoubleBandedUpperMatrix:solve",
"incompatible size of matrices");
virtual void setValues(const tLVectorIndex &n, const double *values)
set the values
Definition: LAP_DoubleBandedUpperMatrix.h:259
virtual tBoolean copyLower(const LAP_DoubleFullGeneralMatrix &f)
copy the transposed of the full matrix
Definition: LAP_DoubleBandedUpperMatrix.cpp:26
virtual void getRow(const tLVectorIndex &i, LAP_DoubleVector &v) const
get the i-th row in a vector
Definition: LAP_DoubleBandedUpperMatrix.cpp:101
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_DoubleBandedUpperMatrix.cpp:577
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_DoubleBandedUpperMatrix.h:472
const tLVectorIndex & getUpperBandsNumber() const
get upper bands number
Definition: LAP_DoubleBandedUpperMatrix.h:290
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 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_DoubleBandedUpperMatrix.h:416
tBoolean compile()
compile the banded matrix
Definition: LAP_DoubleBandedUpperMatrix.h:154
void matrixProduct(const tBoolean &isTransB, const LAP_DoubleFullGeneralMatrix &B, LAP_DoubleFullGeneralMatrix &C) const
return C=(This) . B
Definition: LAP_DoubleBandedUpperMatrix.h:659
virtual void getColumn(const tLVectorIndex &j, LAP_DoubleVector &v) const
get the j-th column of this matrix in a vector
Definition: LAP_DoubleBandedUpperMatrix.cpp:150
void vectorProduct(const tBoolean &isTrans, const double &alpha, LAP_DoubleVector &X) const
Definition: LAP_DoubleBandedUpperMatrix.h:383
virtual void setValuesPointer(SP::LAP_DoubleVector v)
set the vector values by reference
Definition: LAP_DoubleMatrixStorage.h:132
void rankProduct(const tBoolean &isTransU, const LAP_DoubleVector &Diag, LAP_DoubleVector &X) const
compute product
Definition: LAP_DoubleBandedUpperMatrix.h:557
virtual void vectorProduct(const tBoolean &isTrans, LAP_DoubleVector &X) const
compute X:=op(This).X
Definition: LAP_DoubleBandedUpperMatrix.h:375
LAP_DoubleBandedUpperMatrix & operator/=(const lapack_real &s)
divide by s the matrix v
Definition: LAP_DoubleBandedUpperMatrix.h:133
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
void setBandsNumber(const tLVectorIndex &n)
set bands number
Definition: LAP_DoubleBandedUpperMatrix.h:234
tBoolean compile()
compile the matrix to optimal bands number
Definition: LAP_DoubleBandedStorage.h:222
void indexMin(tLVectorIndex &i, tLVectorIndex &j) const
get the index of the min view element in absolute value
Definition: LAP_DoubleBandedUpperMatrix.h:360
Definition: LAP_DoubleVector.h:20
double 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_DoubleBandedStorage.cpp:1349
Definition: LAP_DoubleMatrix.h:18
virtual tBoolean solve(const tBoolean &isTrans, LAP_DoubleFullGeneralMatrix &X) const
solve:
Definition: LAP_DoubleBandedUpperMatrix.h:812
this class describes a band upper matrix for lapack used where values are stored in vectorof size nBa...
Definition: LAP_DoubleBandedUpperMatrix.h:32
virtual ~LAP_DoubleBandedUpperMatrix()
destroy a matrix
Definition: LAP_DoubleBandedUpperMatrix.cpp:18
this class describes a banded storage for lapack used where values are stored in vector of size (nSBa...
Definition: LAP_DoubleBandedStorage.h:24
DEFINE_SPTR(LAP_DoubleBandedUpperMatrix)
virtual void getRow(const tLVectorIndex &i, SP::LAP_DoubleVector v) const
get the i-th row in a vector
Definition: LAP_DoubleBandedUpperMatrix.h:309
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
virtual double & operator()(const tLVectorIndex &i, const tLVectorIndex &j)
accessor of element at row i and column j taking into account the row
Definition: LAP_DoubleBandedUpperMatrix.h:88
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_DoubleBandedUpperMatrix.cpp:309
#define tBoolean
Definition: types.h:48
void rankProduct(const tBoolean &isTransU, LAP_DoubleVector &X) const
compute product X:=top(U) op(U) X
Definition: LAP_DoubleBandedUpperMatrix.h:590
static SP::LAP_DoubleBandedUpperMatrix New()
Definition: LAP_DoubleBandedUpperMatrix.h:65
#define lapack_real
Definition: lapack_functions.h:9
virtual tLVectorIndex getRowsNumber() const
get the lines number of the matrix from view
Definition: LAP_DoubleFullGeneralMatrix.h:366
LAP_DoubleBandedUpperMatrix & operator-=(const LAP_DoubleBandedUpperMatrix &s)
sub the viewed matrix
Definition: LAP_DoubleBandedUpperMatrix.h:175
void solve(const tBoolean &isTrans, LAP_DoubleVector &B) const
solve:
Definition: LAP_DoubleBandedUpperMatrix.h:774
const tLVectorIndex & getBandsNumber() const
get the bands number
Definition: LAP_DoubleBandedStorage.h:237
const LAP_DoubleBandedStorage & getBandedStorage() const
get the banded storage
Definition: LAP_DoubleBandedUpperMatrix.h:279
const tLVectorIndex & getUpperBandsNumber() const
get the upper bands number
Definition: LAP_DoubleBandedStorage.h:242
virtual SP::LAP_DoubleMatrix NewInstance() const
create a New instance of this
Definition: LAP_DoubleBandedUpperMatrix.h:79
#define null
Definition: types.h:13
void DoubleBandedUpperMatrixVectorSolve(const tBoolean &isTransA, const tLVectorIndex &nARows, const tLVectorIndex &nABands, const double *A, const tLVectorIndex &nB, const tLVectorIncrement &incB, double *B)
Definition: dbandeduppermatrix_functions.cpp:356
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_Vector.h:529
LAP_DoubleBandedUpperMatrix & operator+=(const LAP_DoubleBandedUpperMatrix &s)
add the viewed matrix
Definition: LAP_DoubleBandedUpperMatrix.h:181
void init(const double &v)
init the values
Definition: LAP_DoubleMatrixStorage.h:124
static tBoolean computeEigenValues(const LAP_DoubleBandedUpperMatrix &A, LAP_DoubleVector &U)
compute the eigen values of A and A is destroyed after method
Definition: LAP_DoubleBandedUpperMatrix.h:735
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
const tLVectorIndex & getBandsNumber() const
get bands number
Definition: LAP_DoubleBandedUpperMatrix.h:285
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_DoubleBandedUpperMatrix.h:245
virtual void setSize(const tLVectorIndex &nRows, const tLVectorIndex &nCols)
set the dimension of the matrix
Definition: LAP_DoubleBandedUpperMatrix.h:206
LAP_DoubleBandedUpperMatrix & operator-=(const lapack_real &s)
sub s to the upper matrix
Definition: LAP_DoubleBandedUpperMatrix.h:148
tBoolean DoubleBandedUpperMatrixSolve(const tBoolean &isTransA, const tLVectorIndex &nARows, const tLVectorIndex &nABands, const double *A, const tLVectorIndex &nBCols, const tLVectorIndex &ldB, double *B)
Definition: dbandeduppermatrix_functions.cpp:498
virtual const double & operator()(const tLVectorIndex &i, const tLVectorIndex &j) const
accessor of element at row i and column j
Definition: LAP_DoubleBandedUpperMatrix.h:94
LAP_DoubleBandedUpperMatrix & operator*=(const lapack_real &s)
multiply by s the matrix
Definition: LAP_DoubleBandedUpperMatrix.h:127
LAP_DoubleBandedUpperMatrix()
build a matrix
Definition: LAP_DoubleBandedUpperMatrix.cpp:6
void indexMin(tLVectorIndex &i, tLVectorIndex &j) const
get the index of the min view element in absolute value
Definition: LAP_DoubleBandedStorage.cpp:1261
this class describes a general double symmetric matrix
Definition: LAP_DoubleUpperMatrix.h:17
static tBoolean solve(const tBoolean &isTransA, const LAP_DoubleBandedUpperMatrix &A, LAP_DoubleFullGeneralMatrix &B)
solve:
Definition: LAP_DoubleBandedUpperMatrix.h:826
virtual void setSize(const tLVectorIndex &n)
set the dimension of the matrix
Definition: LAP_DoubleBandedUpperMatrix.h:221
virtual void solve(const tBoolean &isTrans, const tLVectorIndex &nB, const tLVectorIncrement &incB, double *B) const
solve:
Definition: LAP_DoubleBandedUpperMatrix.h:791
LAP_DoubleBandedUpperMatrix & operator^=(const lapack_real &s)
power by s the matrix v
Definition: LAP_DoubleBandedUpperMatrix.h:120
LAP_DoubleBandedUpperMatrix & operator*=(const LAP_DoubleBandedUpperMatrix &s)
multiply the viewed matrices term by term
Definition: LAP_DoubleBandedUpperMatrix.h:162
LAP_DoubleBandedUpperMatrix & operator=(const double &s)
init all the matrix to s
Definition: LAP_DoubleBandedUpperMatrix.h:103
void matrixProduct(const LAP_DoubleFullGeneralMatrix &B, LAP_DoubleFullGeneralMatrix &C) const
return C=(This) . B
Definition: LAP_DoubleBandedUpperMatrix.h:649
#define tLVectorIndex
Definition: lapack_types.h:13
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_ConstVector.h:175
virtual void getColumn(const tLVectorIndex &j, SP::LAP_DoubleVector v) const
get the j-th column of this matrix in a vector
Definition: LAP_DoubleBandedUpperMatrix.h:298
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_DoubleBandedUpperMatrix.h:700
tLVectorIndex getLeadingDimension() const
get the memory distance between (*this)(i,j) & (*this)(i,j+1)
Definition: LAP_DoubleFullGeneralMatrix.h:351
virtual tBoolean computeEigenValues(LAP_DoubleVector &U) const
compute the eigen values of This
Definition: LAP_DoubleBandedUpperMatrix.h:754
virtual tLVectorIndex getColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_DoubleFullGeneralMatrix.h:371
LAP_DoubleBandedUpperMatrix & operator/=(const LAP_DoubleBandedUpperMatrix &s)
divide the viewed matrices term by term
Definition: LAP_DoubleBandedUpperMatrix.h:168
void vectorProduct(const tBoolean &isTrans, const tLVectorIndex &nX, const tLVectorIncrement &incX, double *X) const
compute X:=op(A). X
Definition: LAP_DoubleBandedUpperMatrix.h:517
virtual tLVectorIndex getColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_Matrix.h:121
LAP_DoubleBandedUpperMatrix & operator=(const LAP_DoubleMatrix &s)
init all the matrix to s
Definition: LAP_DoubleBandedUpperMatrix.h:109
virtual tReal max(const tFlag &d, const tLVectorIndex &index) const
make get max among the direction if (d==ROW) max of the elements of row at index if (d==COL) max of t...
Definition: LAP_DoubleBandedUpperMatrix.h:352
#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 tReal norm2() const
return norm2 sqrt(sum_ij(aij^2))=sqrt(tr(AtA));
Definition: LAP_DoubleBandedUpperMatrix.cpp:267
static SP::LAP_DoubleBandedUpperMatrix New(const tLVectorIndex &n)
Definition: LAP_DoubleBandedUpperMatrix.h:72
void DoubleBandedUpperMatrixVectorProduct(const tBoolean &isTransA, const tLVectorIndex &nRowsA, const tLVectorIndex &nABands, const double *A, const tLVectorIndex &nX, const tLVectorIncrement &incX, double *x)
Definition: dbandeduppermatrix_functions.cpp:87
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
LAP_DoubleBandedUpperMatrix & operator+=(const lapack_real &s)
add s to the upper matrix
Definition: LAP_DoubleBandedUpperMatrix.h:140
#define ASSERT_IN(a)
Definition: types.h:96
LAP_DoubleBandedStorage & getBandedStorage()
GET.
Definition: LAP_DoubleBandedUpperMatrix.h:274
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14