Cyclops Tensor Framework
parallel arithmetic on multidimensional arrays
matrix.h
Go to the documentation of this file.
1 #ifndef __MATRIX_H__
2 #define __MATRIX_H__
3 
4 namespace CTF {
14  //template<typename dtype>
15  //class Vector : public Tensor<dtype>;
16 
17  template<typename dtype=double>
18  class Matrix : public Tensor<dtype> {
19  public:
20  int nrow, ncol, symm;
24  Matrix();
25 
26 
31  Matrix(Matrix<dtype> const & A);
32 
33 
38  Matrix(Tensor<dtype> const & A);
39 
49  Matrix(int nrow,
50  int ncol,
51  World & wrld,
53  char const * name=NULL,
54  int profile=0);
55 
65  Matrix(int nrow,
66  int ncol,
67  World & wrld,
68  char const * name,
69  int profile=0,
70  CTF_int::algstrct const & sr=Ring<dtype>());
71 
72 
73 
84  Matrix(int nrow,
85  int ncol,
86  int atr=0,
87  World & wrld=get_universe(),
89  char const * name=NULL,
90  int profile=0);
91 
102  Matrix(int nrow,
103  int ncol,
104  int atr,
105  World & wrld,
106  char const * name,
107  int profile=0,
108  CTF_int::algstrct const & sr=Ring<dtype>());
109 
110 
111 
125  Matrix(int nrow,
126  int ncol,
127  char const * idx,
128  Idx_Partition const & prl,
129  Idx_Partition const & blk=Idx_Partition(),
130  int atr=0,
131  World & wrld=get_universe(),
132  CTF_int::algstrct const & sr=Ring<dtype>(),
133  char const * name=NULL,
134  int profile=0);
135 
149  void write_mat(int mb,
150  int nb,
151  int pr,
152  int pc,
153  int rsrc,
154  int csrc,
155  int lda,
156  dtype const * data);
157 
158 
159 
179  Matrix(int nrow,
180  int ncol,
181  int mb,
182  int nb,
183  int pr,
184  int pc,
185  int rsrc,
186  int csrc,
187  int lda,
188  dtype const * data,
189  World & wrld=get_universe(),
190  CTF_int::algstrct const & sr=Ring<dtype>(),
191  char const * name=NULL,
192  int profile=0);
193 
194 
207  Matrix(int const * desc,
208  dtype const * data,
209  World & wrld=get_universe(),
210  CTF_int::algstrct const & sr=Ring<dtype>(),
211  char const * name=NULL,
212  int profile=0);
213 
227  void read_mat(int mb,
228  int nb,
229  int pr,
230  int pc,
231  int rsrc,
232  int csrc,
233  int lda,
234  dtype * data);
235 
236 
243  void get_desc(int & ictxt, int *& desc);
244 
245 
254  void read_mat(int const * desc,
255  dtype * data);
256 
257  /*
258  * \brief prints matrix by row and column (modify print(...) overload in set.h if you would like a different print format)
259  */
260  void print_matrix();
261 
262  /*
263  * \calculates the reduced QR decomposition, A = Q x R for A of dimensions m by n with m>=n
264  * \param[out] Q m-by-n matrix with orthonormal columns
265  * \param[out] R n-by-n upper-triangular matrix
266  */
267  void qr(Matrix<dtype> & Q, Matrix<dtype> & R);
268 
269  /*
270  * \calculates the singular value decomposition, M = U x S x VT, of matrix using pdgesvd from ScaLAPACK
271  * \param[out] U left singular vectors of matrix
272  * \param[out] S singular values of matrix
273  * \param[out] VT right singular vectors of matrix
274  * \param[in] rank rank of output matrices. If rank = 0, will use min(matrix.rows, matrix.columns)
275  */
276  void svd(Matrix<dtype> & U, Vector<dtype> & S, Matrix<dtype> & VT, int rank = 0);
277 
278  };
282 }
283 #include "matrix.cxx"
284 #endif
void write_mat(int mb, int nb, int pr, int pc, int rsrc, int csrc, int lda, dtype const *data)
writes a nonsymmetric matrix from a block-cyclic initial distribution this is `cheap&#39; if mb=nb=1...
Definition: matrix.cxx:203
void qr(Matrix< dtype > &Q, Matrix< dtype > &R)
Definition: matrix.cxx:425
Ring class defined by a datatype and addition and multiplicaton functions addition must have an ident...
Definition: ring.h:18
Matrix class which encapsulates a 2D tensor.
Definition: matrix.h:18
def rank(self)
Definition: core.pyx:312
Vector class which encapsulates a 1D tensor.
Definition: vector.h:14
int symm
Definition: matrix.h:20
an instance of the CTF library (world) on a MPI communicator
Definition: world.h:19
void read_mat(int mb, int nb, int pr, int pc, int rsrc, int csrc, int lda, dtype *data)
reads a nonsymmetric matrix into a block-cyclic initial distribution this is `cheap&#39; if mb=nb=1...
Definition: matrix.cxx:247
int ncol
Definition: matrix.h:20
CTF::World * wrld
distributed processor context on which tensor is defined
void svd(Matrix< dtype > &U, Vector< dtype > &S, Matrix< dtype > &VT, int rank=0)
Definition: matrix.cxx:481
void get_desc(int &ictxt, int *&desc)
get a ScaLAPACK descriptor for this Matrix, will always be in pure cyclic layout
Definition: matrix.cxx:296
algstrct * sr
algstrct on which tensor elements and operations are defined
World & get_universe()
Definition: world.cxx:309
int nrow
Definition: matrix.h:20
bool profile
whether profiling should be done for contractions/sums involving this tensor
algstrct (algebraic structure) defines the elementwise operations computed in each tensor contraction...
Definition: algstrct.h:34
Definition: apsp.cxx:17
char * data
tensor data, either the data or the key-value pairs should exist at any given time ...
an instance of a tensor within a CTF world
Definition: tensor.h:74
Matrix()
default constructor for a matrix
Definition: matrix.cxx:29
void print_matrix()
Definition: matrix.cxx:144
char * name
name given to tensor