1 #ifndef LAP_DoubleFullGeneralMatrix_H
2 #define LAP_DoubleFullGeneralMatrix_H
78 inline static SP::LAP_DoubleFullGeneralMatrix
New() {
85 inline static SP::LAP_DoubleFullGeneralMatrix
New(
const int& n,
const int& m) {
101 SP::LAP_DoubleFullGeneralMatrix Id=
New(nRows,nRows);
104 double *vs=&(*Id.get())[0];
126 return getFullStorage()(i,j);
132 return getFullStorage()(i,j);
200 getFullStorage()*=s.getFullStorage();
206 getFullStorage()/=s.getFullStorage();
213 getFullStorage()-=s.getFullStorage();
219 getFullStorage()+=s.getFullStorage();
256 SP::LAP_DoubleVector v) {
287 const double* values) {
292 getFullStorage().
setValues(n,n*p,values);
299 const double* values) {
304 getFullStorage().
setValues(nRows,n,values);
318 "LAP_DoubleFullGeneralMatrix::concat()",
319 "incompatible dimenion of concat matrices");
324 getFullStorage().
concat(alpha,X.getFullStorage(),
325 beta,Y.getFullStorage());
362 return mIsTransposed;
376 void add(
const double& alpha,
409 "can not store the row in a null shared pointer");
462 if (n!=p)
return false;
467 const double *vc_jk,*vc_j=&(*this)(0,0);
468 const double *vr_jk,*vr_j=vc_j;
487 const double *v_ij,*v_jj=&(*this)(0,0);
493 for (i=j+1;i<n;i++) {
508 const double *v_ij,*v_j=&(*this)(0,0);
511 for (i=j+1;i<n;i++) {
592 if (isTrans) std::swap(nRows,nCols);
598 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleFullGeneralMatrix::product()",
"incompatible size of X vector");
606 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleFullGeneralMatrix::product()",
"incompatible size of Y vector");
630 if (isTrans) std::swap(nRows,nCols);
637 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleFullGeneralMatrix::product()",
"incompatible size of X vector");
645 throw LAP_Exception(
"math/linalg/core",
"LAP_DoubleFullGeneralMatrix::product()",
"incompatible size of Y vector");
678 cout <<
"WARNING:row increment matrix ignored in lapack functions. It is set to 1. \n";
684 if (nRows*nCols==0)
return;
686 throw LAP_Exception(
"math/linal/core",
"LAP_DoubleFullGeneralMatrix::product",
"incompatible size of X vector");
689 throw LAP_Exception(
"math/linal/core",
"LAP_DoubleFullGeneralMatrix::product",
"incompatible size of Y vector");
693 throw LAP_Exception(
"math/linal/core",
"LAP_DoubleFullGeneralMatrix::product",
"x & y vector must not have same pointer");
763 if (isTrans) std::swap(nCols,nRows);
771 if (nBCols!=nRows)
throw LAP_Exception(
"math/linalg/core",
"LAPD_DoubleFullGeneralMatrix::product",
"incompatible size of matrices");
773 if (nCols!=nBRows)
throw LAP_Exception(
"math/linalg/core",
"LAPD_DoubleFullGeneralMatrix::product",
"incompatible size of matrices");
805 cout <<
"WARNING : Row increment in matric are ignored in lapack routines...set to 1 \n";
811 if (nARows*nACols==0)
return;
812 if (nBRows*nBCols==0)
return;
906 QRFactorization(*
this,
true);
908 QRFactorizationWithPivotingColumns(*
this,
true);
927 inline int LUFactorization() {
928 if (mLUPivots!=
null)
delete[] mLUPivots;
931 int N=(nRows>nCols)?nRows:nCols;
933 return LUFactorization(*
this,mLUPivots);
977 int N=(nRows>nCols)?nRows:nCols;
979 int info=LUFactorization(Ac,ipiv);
996 int info=LUFactorization();
997 if (info!=0)
return false;
999 return solve(*
this,mLUPivots,isTr,X);
tBoolean isTransposed() const
return the transposed
Definition: LAP_DoubleFullGeneralMatrix.h:361
LAP_DoubleFullGeneralMatrix & operator+=(const LAP_DoubleFullGeneralMatrix &s)
add the viewed matrix
Definition: LAP_DoubleFullGeneralMatrix.h:218
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_DoubleFullGeneralMatrix.cpp:167
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
static SP::LAP_DoubleFullGeneralMatrix New()
Definition: LAP_DoubleFullGeneralMatrix.h:78
tBoolean lowerTest() const
test if the matrix is symmetric with epsilon difference
Definition: LAP_DoubleFullGeneralMatrix.h:503
double get(const tLVectorIndex &i, const tLVectorIndex &j) const
get the value taking into account the view
Definition: LAP_DoubleMatrix.h:172
void removeColumn(const tLVectorIndex &index)
remove column at index
Definition: LAP_DoubleFullGeneralMatrix.cpp:116
tBoolean symmetricTest() const
test if the matrix is symmetric with epsilon difference
Definition: LAP_DoubleFullGeneralMatrix.h:459
static tBoolean computeEigenValues(LAP_DoubleFullGeneralMatrix &A, LAP_DoubleVector &U)
compute the eigen values of A and A is destroyed after method
Definition: LAP_DoubleFullGeneralMatrix.cpp:486
tLVectorIncrement getRowIncrement() const
get the memory distance between (*this)(i,j) & (*this)(i+1,j)
Definition: LAP_DoubleFullGeneralMatrix.h:346
LAP_DoubleFullGeneralMatrix & operator+=(const lapack_real &s)
add s to the upper matrix
Definition: LAP_DoubleFullGeneralMatrix.h:181
LAP_DoubleFullGeneralMatrix()
build a matrix
Definition: LAP_DoubleFullGeneralMatrix.cpp:14
virtual SP::LAP_DoubleMatrix matrixProduct(const LAP_DoubleMatrix &B) const
return C= This.B
Definition: LAP_DoubleFullGeneralMatrix.h:712
static const tFlag COL
Definition: LAP_Matrix.h:22
virtual tBoolean copy(const LAP_DoubleMatrix &x)
copy a matrix
Definition: LAP_DoubleMatrix.cpp:18
tBoolean LUSolve(const tBoolean &isTr, LAP_DoubleFullGeneralMatrix &X)
solve op(This).X=B where K is the number of colums of B
Definition: LAP_DoubleFullGeneralMatrix.h:995
virtual void getColumn(const tLVectorIndex &j, LAP_DoubleVector &v) const
get the viewed j-th column in a vector
Definition: LAP_DoubleFullGeneralMatrix.cpp:85
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_DoubleFullGeneralMatrix.h:868
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_DoubleFullGeneralMatrix.h:622
Definition: LAP_DoubleVector.h:20
#define lapack_int
Definition: lapack_functions.h:7
void concat(const double &alpha, const LAP_DoubleFullGeneralMatrix &X, const double &beta, const LAP_DoubleFullGeneralMatrix &Y)
concat This-> [alpha X, beta Y] add the colmuns of Y to the columns of X to becomes A ...
Definition: LAP_DoubleFullGeneralMatrix.h:312
Definition: LAP_DoubleMatrix.h:18
this class describes a general double matrix
Definition: LAP_DoubleGeneralMatrix.h:17
void orthogonalize()
Definition: LAP_DoubleFullGeneralMatrix.h:900
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 double & operator()(const tLVectorIndex &i, const tLVectorIndex &j)
accessor of element at row i and column j taking into account the row
Definition: LAP_DoubleFullGeneralMatrix.h:125
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
virtual tLVectorIndex getViewedRowsNumber() const
get the lines number of the matrix from view
Definition: LAP_DoubleFullStorage.h:285
virtual SP::LAP_DoubleMatrix NewInstance() const
create a New instance of this
Definition: LAP_DoubleFullGeneralMatrix.h:116
#define tBoolean
Definition: types.h:48
virtual void setSize(const tLVectorIndex &n)
set the dimension of the matrix and alocate the values array
Definition: LAP_DoubleFullGeneralMatrix.h:244
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
void transpose()
transpose the matrix
Definition: LAP_DoubleFullGeneralMatrix.cpp:338
LAP_DoubleFullGeneralMatrix & operator-=(const LAP_DoubleFullGeneralMatrix &s)
sub the viewed matrix
Definition: LAP_DoubleFullGeneralMatrix.h:212
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= betaY + alpha. op(This). X
Definition: LAP_DoubleFullGeneralMatrix.h:671
#define lapack_real
Definition: lapack_functions.h:9
virtual tReal norm2() const
return norm2 sqrt(sum_ij(aij^2))=sqrt(tr(AtA));
Definition: LAP_DoubleFullGeneralMatrix.cpp:152
LAP_DoubleFullGeneralMatrix & operator*=(const lapack_real &s)
multiply by s the matrix
Definition: LAP_DoubleFullGeneralMatrix.h:168
LAP_DoubleFullGeneralMatrix & operator=(const LAP_DoubleFullGeneralMatrix &s)
init all the matrix to s
Definition: LAP_DoubleFullGeneralMatrix.h:150
static const tFlag ROW
Definition: LAP_Matrix.h:21
virtual tLVectorIndex getRowsNumber() const
get the lines number of the matrix from view
Definition: LAP_DoubleFullGeneralMatrix.h:366
virtual tBoolean inverse()
inverse the matrix
Definition: LAP_DoubleFullGeneralMatrix.cpp:559
void getRowByReference(const tLVectorIndex &i, LAP_ConstDoubleVector &v) const
get the row by reference the values of v pointer to the values of the column j of this ...
Definition: LAP_DoubleFullGeneralMatrix.h:425
static double ZERO_EPSILON
Definition: LAP_Object.h:21
#define null
Definition: types.h:13
void matrixProduct(const LAP_DoubleFullGeneralMatrix &B, LAP_DoubleFullGeneralMatrix &C) const
make the product : C:=This. B
Definition: LAP_DoubleFullGeneralMatrix.h:736
LAP_DoubleFullGeneralMatrix & operator-=(const lapack_real &s)
sub s to the upper matrix
Definition: LAP_DoubleFullGeneralMatrix.h:189
static SP::LAP_DoubleFullGeneralMatrix Identity(const tLVectorIndex &nRows)
create an identity matrix
Definition: LAP_DoubleFullGeneralMatrix.h:100
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_Vector.h:529
virtual void setValues(const tLVectorIndex &n, const double *values)
set the values n is the size of values. the size of the matrix is sqrt(n)xsqrt(n) ...
Definition: LAP_DoubleFullGeneralMatrix.h:298
int DoubleFullMatrixLUFactorization(const tLVectorIndex &nRows, const tLVectorIndex &nCols, const tLVectorIndex &ld, double *A, lapack_int *LU_pivots)
Definition: dfullmatrix_functions.cpp:561
virtual void setValues(SP::LAP_DoubleVector v)
set the values n is the size of values. the size of the matrix is sqrt(n)xsqrt(n) ...
Definition: LAP_DoubleFullGeneralMatrix.h:272
virtual void getRow(const tLVectorIndex &i, SP::LAP_DoubleVector v) const
get the i-th viewed row in a vector
Definition: LAP_DoubleFullGeneralMatrix.h:406
LAP_DoubleFullGeneralMatrix & operator/=(const LAP_DoubleFullGeneralMatrix &s)
divide the viewed matrices term by term
Definition: LAP_DoubleFullGeneralMatrix.h:205
void init(const double &v)
init the values
Definition: LAP_DoubleMatrixStorage.h:124
virtual void getRowByReference(const tLVectorIndex &i, LAP_DoubleVector &v)
get the row by reference the values of v pointer to the values of the column j of this ...
Definition: LAP_DoubleFullStorage.cpp:1038
virtual void setValues(const tLVectorIndex &n, const double *values)
copy the values to the matrix values
Definition: LAP_DoubleFullStorage.h:195
static SP::LAP_DoubleFullGeneralMatrix New(const int &n, const int &m)
Definition: LAP_DoubleFullGeneralMatrix.h:85
Definition: LAP_DoubleFullGeneralMatrix.h:30
tLVectorIndex getSize() const
get the size of the vector
Definition: LAP_Vector.h:519
virtual const double & operator()(const tLVectorIndex &i, const tLVectorIndex &j) const
accessor of element at row i and column j
Definition: LAP_DoubleFullGeneralMatrix.h:131
tBoolean upperTest() const
test if the matrix is upper
Definition: LAP_DoubleFullGeneralMatrix.h:484
void swapColumns(const tLVectorIndex &i, const tLVectorIndex &j)
swap the column i & j
Definition: LAP_DoubleFullStorage.cpp:1175
LAP_DoubleFullGeneralMatrix & operator*=(const LAP_DoubleFullGeneralMatrix &s)
multiply the viewed matrices term by term
Definition: LAP_DoubleFullGeneralMatrix.h:199
void orthogonalize(const tFlag &m)
Definition: LAP_DoubleFullGeneralMatrix.h:904
virtual void setValuesNumber(const tLVectorIndex &nRows, const tLVectorIndex &n)
set the values number
Definition: LAP_DoubleFullStorage.h:213
tBoolean solve(const tBoolean &isTr, LAP_DoubleFullGeneralMatrix &X) const
solve op(This).X=B where K is the number of colums of B
Definition: LAP_DoubleFullGeneralMatrix.h:972
virtual tLVectorIndex getViewedColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_DoubleFullStorage.h:290
void reverseColumns()
reverese the column order
Definition: LAP_DoubleFullStorage.cpp:1136
const tLVectorIndex & getSize(const tFlag &direction) const
get the size in direction
Definition: LAP_Matrix.h:108
static SP::LAP_DoubleFullGeneralMatrix New(const tLVectorIndex &n, const tLVectorIndex &m)
Definition: LAP_DoubleFullGeneralMatrix.h:91
Definition: LAP_DoubleFullStorage.h:29
void getColumnByReference(const tLVectorIndex &j, LAP_ConstDoubleVector &v) const
get the column by reference the values of v pointer to the values of the column j of this ...
Definition: LAP_DoubleFullGeneralMatrix.h:400
virtual ~LAP_DoubleFullGeneralMatrix()
destroy a matrix
Definition: LAP_DoubleFullGeneralMatrix.cpp:39
virtual tBoolean computeEigenValueDecomposition(LAP_DoubleVector &U, LAP_DoubleMatrix &VR) const
compute the eigen values decomposition on A: A is copied
Definition: LAP_DoubleFullGeneralMatrix.h:880
#define tLVectorIndex
Definition: lapack_types.h:13
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_DoubleFullGeneralMatrix.cpp:254
LAP_DoubleFullGeneralMatrix & operator^=(const lapack_real &s)
power by s the matrix v
Definition: LAP_DoubleFullGeneralMatrix.h:161
const tLVectorIncrement & getIncrement() const
get the increment of the vector
Definition: LAP_ConstVector.h:175
static const tFlag QR
Definition: LAP_DoubleFullGeneralMatrix.h:38
void swapColumns(const tLVectorIndex &i, const tLVectorIndex &j)
swap the viewed columns i & j
Definition: LAP_DoubleFullGeneralMatrix.h:439
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_DoubleFullGeneralMatrix.h:584
tLVectorIndex getLeadingDimension() const
get the memory distance between (*this)(i,j) & (*this)(i,j+1)
Definition: LAP_DoubleFullGeneralMatrix.h:351
virtual tLVectorIndex getColumnsNumber() const
get the columns number of the matrix from view
Definition: LAP_DoubleFullGeneralMatrix.h:371
static void matrixProduct(const tBoolean &isTrA, const LAP_DoubleFullGeneralMatrix &A, const tBoolean &isTrB, const LAP_DoubleFullGeneralMatrix &B, const lapack_real &alpha, const lapack_real &beta, LAP_DoubleFullGeneralMatrix &C)
make the product C = alpha. op(A).op(B) +beta C
Definition: LAP_DoubleFullGeneralMatrix.h:797
virtual tBoolean computeEigenValues(LAP_DoubleVector &U) const
compute the eigen values of This: A is copied
Definition: LAP_DoubleFullGeneralMatrix.h:859
virtual void setValuesPointer(SP::LAP_DoubleVector v)
set the values of without copying
Definition: LAP_DoubleFullStorage.h:180
virtual void vectorProduct(const LAP_DoubleVector &X, LAP_DoubleVector &Y) const
compute Y= This. X
Definition: LAP_DoubleFullGeneralMatrix.h:572
DEFINE_SPTR(LAP_DoubleFullGeneralMatrix)
void matrixProduct(const tBoolean &isLeftSide, const tBoolean &isTrans, const LAP_DoubleFullGeneralMatrix &B, const double &alpha, LAP_DoubleFullGeneralMatrix &C) const
make the product : C:=op(This).B (leftSide=true) C:=B. op(This) (leftSide=false)
Definition: LAP_DoubleFullGeneralMatrix.h:752
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_DoubleFullGeneralMatrix.h:254
void add(const double &alpha, const LAP_DoubleFullGeneralMatrix &x)
This+=alpha.x.
Definition: LAP_DoubleFullGeneralMatrix.cpp:367
virtual void getColumnByReference(const tLVectorIndex &j, LAP_DoubleVector &v)
get the column by reference the values of v pointer to the values of the column j of this ...
Definition: LAP_DoubleFullStorage.cpp:1097
void indexMin(tLVectorIndex &i, tLVectorIndex &j) const
get the index of the min view element in absolute value
Definition: LAP_DoubleFullGeneralMatrix.cpp:286
void DoubleFullMatrixVectorProduct(const tLVectorIndex &lx, const tLVectorIncrement &incx, const double *x, const tBoolean &isTransposed, const tLVectorIndex &nRows, const tLVectorIndex &nCols, const tLVectorIndex &ldaA, const double *A, const lapack_real &alpha, const lapack_real &beta, const tLVectorIndex &ly, const tLVectorIncrement &incy, double *y)
compute Y=beta.Y + alpha op(A). X where op(A)=A or op(A)=tA
Definition: dfullmatrix_functions.cpp:185
void reverseColumns()
reverse the viewed columns of the matrix
Definition: LAP_DoubleFullGeneralMatrix.h:445
#define tLVectorIncrement
Definition: lapack_types.h:16
tLVectorIndex getLeadingDimension() const
get the leading dimension ie the memory distance between M(i,j) & M(i,j+1)
Definition: LAP_DoubleFullStorage.h:296
virtual void getColumn(const tLVectorIndex &j, SP::LAP_DoubleVector v) const
get the viewed j-th column in a vector
Definition: LAP_DoubleFullGeneralMatrix.h:384
static const tFlag QRP
Definition: LAP_DoubleFullGeneralMatrix.h:39
Definition: LAP_ConstDoubleVector.h:25
void getRowByReference(const tLVectorIndex &i, LAP_DoubleVector &v)
get the row by reference the values of v pointer to the values of the column j of this ...
Definition: LAP_DoubleFullGeneralMatrix.h:419
#define tReal
Definition: types.h:18
LAP_DoubleFullGeneralMatrix & operator=(const double &s)
init all the matrix to s
Definition: LAP_DoubleFullGeneralMatrix.h:144
virtual void setValues(const tLVectorIndex &n, const tLVectorIndex &p, const double *values)
set the values
Definition: LAP_DoubleFullGeneralMatrix.h:285
virtual SP::LAP_DoubleVector vectorProduct(const LAP_DoubleVector &X) const
compute This. X
Definition: LAP_DoubleMatrix.h:328
void concat(const double &alpha, const LAP_DoubleFullStorage &X, const double &beta, const LAP_DoubleFullStorage &Y)
concat This-> [alpha X, beta Y] add the colmuns of Y to the columns of X to becomes A ...
Definition: LAP_DoubleFullStorage.h:370
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
LAP_DoubleFullGeneralMatrix & operator/=(const lapack_real &s)
divide by s the matrix v
Definition: LAP_DoubleFullGeneralMatrix.h:174
void getColumnByReference(const tLVectorIndex &j, LAP_DoubleVector &v)
get the column by reference the values of v pointer to the values of the column j of this ...
Definition: LAP_DoubleFullGeneralMatrix.h:394
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14