C++ main module for mmsd Package  1.0
LAP_DoubleFullGeneralMatrix.h
Go to the documentation of this file.
1 #ifndef LAP_DoubleFullGeneralMatrix_H
2 #define LAP_DoubleFullGeneralMatrix_H
3 
5 
7 
8 #include "LAP_DoubleVector.h"
10 
11 #include "dfullmatrix_functions.h"
12 
13 
14 
29 
31 
32  SP_OBJECT(LAP_DoubleFullGeneralMatrix);
33 
34 
35 
36  // ATTRIBUTES
37 public:
38  static const tFlag QR;
39  static const tFlag QRP;
40 
41 
42 
43 private:
44  //transposed the element
45  tBoolean mIsTransposed;
46 
49  lapack_int *mLUPivots;
50 
51  // ASSOCIATIONS
52 
53 
54  // METHOD
55 
56 
57 public:
58  // CONSTRUCTORS
65 
66  // DESTRUCTORS
70 
71 
72 
73  // -------------
74  // NEW METHODS
75  // -------------
76 public:
77 
78  inline static SP::LAP_DoubleFullGeneralMatrix New() {
79  SP::LAP_DoubleFullGeneralMatrix p(new LAP_DoubleFullGeneralMatrix(),
81  p->setThis(p);
82  return p;
83  };
84 
85  inline static SP::LAP_DoubleFullGeneralMatrix New(const int& n,const int& m) {
86  SP::LAP_DoubleFullGeneralMatrix p(new LAP_DoubleFullGeneralMatrix(n,m),
88  p->setThis(p);
89  return p;
90  };
91  inline static SP::LAP_DoubleFullGeneralMatrix New(const tLVectorIndex& n,const tLVectorIndex & m) {
92  SP::LAP_DoubleFullGeneralMatrix p(new LAP_DoubleFullGeneralMatrix(n,m),
94  p->setThis(p);
95  return p;
96  };
97 
100  inline static SP::LAP_DoubleFullGeneralMatrix Identity(const tLVectorIndex& nRows) {
101  SP::LAP_DoubleFullGeneralMatrix Id=New(nRows,nRows);
102 
103  //get the values
104  double *vs=&(*Id.get())[0];
105  //set diagonal to 1
106  for (tLVectorIndex i=0;i<nRows-1;i++) {
107  *vs=1;
108  vs+=nRows+1;
109 
110  }
111  *vs=1;
112  return Id;
113  }
116  virtual SP::LAP_DoubleMatrix NewInstance() const {
117  return New();
118  }
119 
120  //-----------
121  // OPERATORS
122  // ----------
125  virtual double& operator()(const tLVectorIndex& i,const tLVectorIndex& j) {
126  return getFullStorage()(i,j);
127  };
128 
131  virtual const double& operator()(const tLVectorIndex& i,const tLVectorIndex& j) const {
132  return getFullStorage()(i,j);
133  };
134 
135 
136 
137 
138  //copy operator
139  //=============
140 
141 
145  getStorage().init(s);
146  return (*this);
147  };
151  copy(s);
152  return (*this);
153  };
154 
155 
156  //scalar operators
157  //================
158 
162  getFullStorage()^=s;
163  return (*this);
164  }
165 
169  getFullStorage()*=s;
170  return (*this);
171  }
175  getFullStorage()/=s;
176  return (*this);
177  }
178 
182  getFullStorage()+=s;
183  return (*this);
184  }
185 
186 
190  getFullStorage()-=s;
191  return (*this);
192  }
193 
194  //pack matrix operator
195  //=====================
196 
200  getFullStorage()*=s.getFullStorage();
201  return (*this);
202  }
206  getFullStorage()/=s.getFullStorage();
207  return (*this);
208  }
209 
213  getFullStorage()-=s.getFullStorage();
214  return (*this);
215  }
219  getFullStorage()+=s.getFullStorage();
220  return (*this);
221  }
222 
223 
224  //dimension setting
225  //=================
226 
230  virtual void setSize(const tLVectorIndex& n,const tLVectorIndex& p) {
231  //set the number of the matrix
233 
234  //set the storage
236 
237  //set the size of the storage
238  getFullStorage().setValuesNumber(n,dim);
239 
240  }
244  virtual void setSize(const tLVectorIndex & n) {
245  setSize(n,n);
246  }
247 
254  virtual void setValues(const tLVectorIndex& n,
255  const tLVectorIndex& p,
256  SP::LAP_DoubleVector v) {
257 
258 
259  tLVectorIndex m=v->getSize();
260  if (n*p!=m)
262  else
264 
265  //set the vector values
266  getFullStorage().setValuesPointer(n,v);
267  };
272  virtual void setValues(SP::LAP_DoubleVector v) {
273  tLVectorIndex n=v->getSize();
274  tLVectorIndex nRows=(tLVectorIndex) (sqrt(n)+0.5);
276 
277  getFullStorage().setValuesPointer(nRows,v);
278  }
285  virtual void setValues(const tLVectorIndex& n,
286  const tLVectorIndex& p,
287  const double* values) {
288  //set the size
289  setSize(n,p);
290 
291  //set the storage
292  getFullStorage().setValues(n,n*p,values);
293  }
298  virtual void setValues(const tLVectorIndex& n,
299  const double* values) {
300 
301  tLVectorIndex nRows=(tLVectorIndex) (sqrt(n)+0.5);
303 
304  getFullStorage().setValues(nRows,n,values);
305  }
306 
307 
308 
312  inline void concat(const double& alpha,const LAP_DoubleFullGeneralMatrix& X,
313  const double& beta, const LAP_DoubleFullGeneralMatrix& Y) {
314 
315  //verify the number of rows must be the same
317  throw LAP_Exception("math/linalg/core",
318  "LAP_DoubleFullGeneralMatrix::concat()",
319  "incompatible dimenion of concat matrices");
320 
321  // the new matrix is of size nRows x (nColsOfX+nColsOfY)
323  //merge the values
324  getFullStorage().concat(alpha,X.getFullStorage(),
325  beta,Y.getFullStorage());
326 
327 
328  }
329 
330  // GET
331  // ======
332 private:
335  inline LAP_DoubleFullStorage& getFullStorage() {
336  return *dynamic_cast<LAP_DoubleFullStorage*>(&getStorage());
337  };
340  inline const LAP_DoubleFullStorage& getFullStorage() const {
341  return *dynamic_cast<const LAP_DoubleFullStorage*>(&getStorage());
342  };
343 public:
347  return getFullStorage().getRowIncrement();
348  }
352  return getFullStorage().getLeadingDimension();
353  }
354 
357  void transpose();
358 
361  inline tBoolean isTransposed() const {
362  return mIsTransposed;
363  }
366  virtual tLVectorIndex getRowsNumber() const {
367  return getFullStorage().getViewedRowsNumber();
368  };
371  virtual tLVectorIndex getColumnsNumber() const {
372  return getFullStorage().getViewedColumnsNumber();
373  };
376  void add(const double& alpha,
377  const LAP_DoubleFullGeneralMatrix& x);
378 
381  virtual void getColumn(const tLVectorIndex& j,LAP_DoubleVector& v) const;
384  virtual void getColumn(const tLVectorIndex& j,SP::LAP_DoubleVector v) const {
385  ASSERT_IN(v.get()!=null);
386  getColumn(j,*v.get());
387  };
388 
389 
390 
395  getFullStorage().getColumnByReference(j,v);
396  }
401  getFullStorage().getColumnByReference(j,v);
402  }
403 
406  virtual void getRow(const tLVectorIndex& i,SP::LAP_DoubleVector v) const {
407  if (v.get()==null) throw LAP_Exception("math/linalg,core",
408  "getRow()",
409  "can not store the row in a null shared pointer");
410  getRow(i,*v.get());
411  };
414  virtual void getRow(const tLVectorIndex& i,LAP_DoubleVector& v) const;
415 
420  getFullStorage().getRowByReference(i,v);
421  }
425  inline void getRowByReference(const tLVectorIndex& i,LAP_ConstDoubleVector& v) const {
426  getFullStorage().getRowByReference(i,v);
427  }
428 
429 
430  //column manipulations
431  // ====================
432 
435  void removeColumn(const tLVectorIndex& index);
436 
439  void swapColumns(const tLVectorIndex& i,const tLVectorIndex& j) {
440  getFullStorage().swapColumns(i,j);
441  }
442 
445  void reverseColumns() {
446  getFullStorage().reverseColumns();
447  }
448 
449 
450 
451 
452  // =============
453  // Tools methods
454  // =============
455 
456 
459  inline tBoolean symmetricTest() const {
462  if (n!=p) return false;
463 
466 
467  const double *vc_jk,*vc_j=&(*this)(0,0);
468  const double *vr_jk,*vr_j=vc_j;
469  for (j=0;j<p;j++) {
470  vr_jk=vr_j;
471  vc_jk=vc_j;
472  for (k=0;k<j;k++) {
473  if (fabs(*vc_jk-(*vr_jk))>LAP_DoubleMatrixStorage::ZERO_EPSILON) return false;
474  vr_jk+=ld;
475  vc_jk+=inc;
476  }
477  vc_j+=ld;
478  vr_j+=inc;
479  }
480  return true;
481  };
484  inline tBoolean upperTest() const {
487  const double *v_ij,*v_jj=&(*this)(0,0);
488  const tLVectorIncrement& inc=getRowIncrement();
490  tLVectorIndex ldd=ld+inc;
491  for (j=0;j<p;j++) {
492  v_ij=v_jj+inc;
493  for (i=j+1;i<n;i++) {
494  if (fabs(*v_ij)>LAP_DoubleMatrixStorage::ZERO_EPSILON) return false;
495  v_ij+=inc;
496  }
497  v_jj+=ldd;
498  }
499  return true;
500  };
503  inline tBoolean lowerTest() const {
506  const tLVectorIncrement& inc=getRowIncrement();
508  const double *v_ij,*v_j=&(*this)(0,0);
509  for (j=0;j<p;j++) {
510  v_ij=v_j+(j+1)*inc;
511  for (i=j+1;i<n;i++) {
512  if (fabs(*v_ij)>LAP_DoubleMatrixStorage::ZERO_EPSILON) return false;
513  v_ij+=inc;
514  }
515  v_j+=ld;
516  }
517  return true;
518  };
519 
520 
521  // ------------------------
522  // operation on matrix
523  // ------------------------
524 public:
525 
526 
529  virtual tReal norm2() const;
530 
533  virtual tReal norm2(LAP_DoubleVector& v) const;
534 
535 
536 
542  virtual tReal sum(const tFlag& d,LAP_DoubleVector& s) const;
543 
549  virtual tReal sum(const tFlag& d,const tLVectorIndex& index) const;
550 
556  virtual tReal max(const tFlag& d,const tLVectorIndex& index) const;
557 
562  void indexMin(tLVectorIndex& i,tLVectorIndex& j) const;
563 
564 
565  // ----------------
566  // vector product
567  // ----------------
568 
569 public:
572  virtual void vectorProduct(const LAP_DoubleVector& X,
573  LAP_DoubleVector& Y) const{
575  }
576 
584  void vectorProduct(const tBoolean& isTrans,
585  const LAP_DoubleVector& X,
586  const lapack_real& alpha,
587  const lapack_real& beta,
588  LAP_DoubleVector& Y) const {
589  //get the dimenson of Matrix
592  if (isTrans) std::swap(nRows,nCols);
593 
594  tLVectorIndex nX=X.getSize();
595 
596  //verify the dimension of X
597  if (nX!=nRows) {
598  throw LAP_Exception("math/linalg/core","LAP_DoubleFullGeneralMatrix::product()","incompatible size of X vector");
599  }
600 
601  if (beta==0) {
602  Y.setSize(nRows);
603  }
604  tLVectorIndex nY=Y.getSize();
605  if (nY!=nRows) {
606  throw LAP_Exception("math/linalg/core","LAP_DoubleFullGeneralMatrix::product()","incompatible size of Y vector");
607  }
608  //make the product
609  vectorProduct(isTrans,
610  nX,X.getIncrement(),&X(0),
611  alpha,
612  beta,
613  nY,Y.getIncrement(),&Y(0));
614  };
622  void vectorProduct(const tBoolean& isTrans,
623  const LAP_ConstDoubleVector& X,
624  const lapack_real& alpha,
625  const lapack_real& beta,
626  LAP_DoubleVector& Y) const {
627  //get the dimenson of Matrix
630  if (isTrans) std::swap(nRows,nCols);
631 
632  //get the diemsnion of the vector X
633  tLVectorIndex nX=X.getSize();
634 
635  //verify the dimension of X
636  if (nX!=nRows) {
637  throw LAP_Exception("math/linalg/core","LAP_DoubleFullGeneralMatrix::product()","incompatible size of X vector");
638  }
639 
640  if (beta==0) {
641  Y.setSize(nRows);
642  }
643  tLVectorIndex nY=Y.getSize();
644  if (nY!=nRows) {
645  throw LAP_Exception("math/linalg/core","LAP_DoubleFullGeneralMatrix::product()","incompatible size of Y vector");
646  }
647  //make the product
648  vectorProduct(isTrans,
649  nX,X.getIncrement(),&X(0),
650  alpha,
651  beta,
652  nY,Y.getIncrement(),&Y(0));
653 
654  };
655 
656 
657 
658 public:
671  virtual void vectorProduct(const tBoolean& isTrans,
672  const tLVectorIndex& nx,const tLVectorIncrement& incx,const double* x,
673  const lapack_real& alpha,
674  const lapack_real& beta,
675  const tLVectorIndex& ny,const tLVectorIncrement&incy,double* y) const {
676 
677  if (getRowIncrement()!=1) {
678  cout <<"WARNING:row increment matrix ignored in lapack functions. It is set to 1. \n";
679  }
683 
684  if (nRows*nCols==0) return;
685  if (nCols!=nx) {
686  throw LAP_Exception("math/linal/core","LAP_DoubleFullGeneralMatrix::product","incompatible size of X vector");
687  }
688  if (nRows!=ny) {
689  throw LAP_Exception("math/linal/core","LAP_DoubleFullGeneralMatrix::product","incompatible size of Y vector");
690  }
691 
692  if (x==y) {
693  throw LAP_Exception("math/linal/core","LAP_DoubleFullGeneralMatrix::product","x & y vector must not have same pointer");
694  }
695 
697  isTrans,
698  nRows,nCols,ld,
699  &(*this)(0,0),
700  alpha,beta,
701  ny,incy,y);
702  }
703 
704  // ----------------
705  // matrix product
706  // ----------------
707 public:
712  virtual SP::LAP_DoubleMatrix matrixProduct(const LAP_DoubleMatrix& B) const {
713  SP::LAP_DoubleFullGeneralMatrix C=LAP_DoubleFullGeneralMatrix::New();
714  matrixProduct(B,*C.get());
715  return C;
716  }
717 
724  LAP_DoubleFullGeneralMatrix& C) const;
725 
726 
727  //product with full matrix
728  //-------------------------
729 
737  LAP_DoubleFullGeneralMatrix& C) const {
738  matrixProduct(true,false,B,1.,C);
739  }
740 
741 
742 
752  void matrixProduct(const tBoolean& isLeftSide,
753  const tBoolean& isTrans,
755  const double& alpha,
756  LAP_DoubleFullGeneralMatrix& C) const {
757  tLVectorIndex nBCols=B.getColumnsNumber();
758  tLVectorIndex nBRows=B.getRowsNumber();
759 
760 
763  if (isTrans) std::swap(nCols,nRows);
764 
765  tLVectorIndex nCRows=nRows;
766  tLVectorIndex nCCols=nBCols;
767 
768  if (!isLeftSide) {
769  nCRows=nBRows;
770  nCCols=nCols;
771  if (nBCols!=nRows) throw LAP_Exception("math/linalg/core","LAPD_DoubleFullGeneralMatrix::product","incompatible size of matrices");
772  } else {
773  if (nCols!=nBRows) throw LAP_Exception("math/linalg/core","LAPD_DoubleFullGeneralMatrix::product","incompatible size of matrices");
774  }
775 
776 
777  C.setSize(nCRows,nCCols);
778  if (isLeftSide) {
779  matrixProduct(isTrans,(*this),false,B,alpha,0.,C);
780  } else {
781  matrixProduct(false,B,isTrans,(*this),alpha,0.,C);
782  }
783  };
784 
785 
786 
797  static inline void matrixProduct(const tBoolean& isTrA,
799  const tBoolean& isTrB,
801  const lapack_real& alpha,
802  const lapack_real& beta,
804  if ((A.getRowIncrement()!=1) || (B.getRowIncrement()!=1)) {
805  cout << "WARNING : Row increment in matric are ignored in lapack routines...set to 1 \n";
806  }
807  tLVectorIndex nARows=A.getRowsNumber();
808  tLVectorIndex nACols=A.getColumnsNumber();
809  tLVectorIndex nBRows=B.getRowsNumber();
810  tLVectorIndex nBCols=B.getColumnsNumber();
811  if (nARows*nACols==0) return;
812  if (nBRows*nBCols==0) return;
813 
814  matrixProduct(isTrA,nARows,nACols,A.getLeadingDimension(),&A(0,0),
815  isTrB,nBRows,nBCols,B.getLeadingDimension(),&B(0,0),
816  alpha,beta,C);
817 
818  }
836  static void matrixProduct(const tBoolean& isTrA,
837  const tLVectorIndex& nRowsA,const tLVectorIndex& nColsA,const tLVectorIndex& ldA,const double *A,
838  const tBoolean& isTrB,
839  const tLVectorIndex& nRowsB,const tLVectorIndex& nColsB,const tLVectorIndex& ldB,const double *B,
840  const lapack_real& alpha,
841  const lapack_real& beta,
843 
844 
845 
846  // ----------------------
847  // eigen values & vectors
848  // ------------------------
849 public:
850 
851 
855  LAP_DoubleVector& U);
856 
861  return computeEigenValues(A,U);
862  };
863 
870  tBoolean succeeds=computeEigenValueDecomposition(*this,U,VR);
871  copy(VR);
872  return succeeds;
873  };
874 
875 
882  LAP_DoubleFullGeneralMatrix *fVR=dynamic_cast< LAP_DoubleFullGeneralMatrix *>(&VR);
883  if (fVR!=null)
884  return computeEigenValueDecomposition(C,U,*fVR);
885  else
886  return false;
887  }
888 
889 
893  LAP_DoubleVector& U,
895 
896 
897  // ------------------------
898  // Orthogonalization
899  // ------------------------
900  inline void orthogonalize() {
901  orthogonalize(QRP);
902  }
903 
904  inline void orthogonalize(const tFlag& m) {
905  if (m==QR) {
906  QRFactorization(*this,true);
907  } else if (m==QRP) {
908  QRFactorizationWithPivotingColumns(*this,true);
909  }
910  }
911 
912 private:
916  static tBoolean QRFactorization(LAP_DoubleFullGeneralMatrix& A,const tBoolean& onlyQ);
920  static tBoolean QRFactorizationWithPivotingColumns(LAP_DoubleFullGeneralMatrix& A,const tBoolean& onlyQ);
921 
922  // ------------------------
923  // factorization
924  // ------------------------
925 
926 
927  inline int LUFactorization() {
928  if (mLUPivots!=null) delete[] mLUPivots;
931  int N=(nRows>nCols)?nRows:nCols;
932  mLUPivots=new lapack_int[N];
933  return LUFactorization(*this,mLUPivots);
934  }
935 
943  static int LUFactorization(LAP_DoubleFullGeneralMatrix&A,lapack_int *ipiv ) {
944 
945  tLVectorIndex nRows=A.getRowsNumber();
948  return DoubleFullMatrixLUFactorization(nRows,nCols,ld,&A(0,0),ipiv);
949  }
950 
951 
952 
953 
954 
955  // -----------------------
956  // linear system solvers
957  // -----------------------
958 public:
962  virtual tBoolean inverse();
963 
964 
965 public:
974  Ac.copy(*this);
977  int N=(nRows>nCols)?nRows:nCols;
978  lapack_int *ipiv=new lapack_int[N];
979  int info=LUFactorization(Ac,ipiv);
980  if (info!=0) {
981  delete[] ipiv;
982  return false;
983  }
984  tBoolean succeeds=solve(Ac,ipiv,isTr,X);
985  delete[] ipiv;
986  return succeeds;
987  }
996  int info=LUFactorization();
997  if (info!=0) return false;
998 
999  return solve(*this,mLUPivots,isTr,X);
1000  }
1001 
1002 
1011  static tBoolean solve(const LAP_DoubleFullGeneralMatrix& A,const lapack_int* ipiv,const tBoolean& isTr,LAP_DoubleFullGeneralMatrix& X);
1012 
1013 
1014 
1015 };
1016 #endif
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