Toast++  1.0.2 (r.539)
Forward and inverse modelling in optical tomography
crmatrix.h
1 // -*-C++-*-
2 // ==========================================================================
3 // Module mathlib
4 // File crmatrix.h
5 // Declaration of template class TCompRowMatrix ('template compressed-row
6 // matrix')
7 //
8 // The following typedefs for specific template types have been defined
9 // for convenience:
10 // RCompRowMatrix = TCompRowMatrix<double> ('real')
11 // FCompRowMatrix = TCompRowMatrix<float> ('float')
12 // CCompRowMatrix = TCompRowMatrix<complex> ('complex')
13 // ICompRowMatrix = TCompRowMatrix<int> ('integer')
14 //
15 // Inheritance:
16 // ------------
17 // TGenericSparseMatrix ----> TCompRowMatrix
18 //
19 // Notes:
20 // ------
21 // * TCompRowMatrix does not support dynamic growth, i.e. a write operation
22 // must not address a non-existing entry. If you need dynamic growth,
23 // use a TCoordMatrix and convert it to a TCompRowMatrix once it is fully
24 // assembled.
25 // ==========================================================================
26 
27 #ifndef __CRMATRIX_H
28 #define __CRMATRIX_H
29 
30 #include "gsmatrix.h"
31 
32 // ==========================================================================
33 // Nonmember declarations
34 
35 template<class MT>class TCompRowMatrix;
36 template<class MT>class TCoordMatrix;
37 template<class MT>class TPrecon_IC;
38 template<class MT>class TDenseMatrix;
39 template<class MT>class TDiagMatrix;
40 
41 void BlockExpand (int *rowptr, int *colidx, int n,
42  int *&browptr, int *&bcolidx, int &bn,
43  int blockn, int blockm);
44 // expand the nonsparsity structure (rowptr,colidx) of an (n x m) matrix
45 // into a (n blockn x m blockm) matrix structure (browptr, bcolidx) by
46 // expanding every entry in the original matrix into an (blockn x blockm)
47 // block
48 
49 template<class MT>
50 TCompRowMatrix<MT>transp (const TCompRowMatrix<MT> &m);
51 
52 template<class MT>
53 double l2norm (const TCompRowMatrix<MT> &A);
54 
55 template<class MT>
57  const TCompRowMatrix<MT> &B);
58 
59 template<class MT>
61  const TCompRowMatrix<MT> &B);
62 
63 template<class MT>
65  const TCompRowMatrix<MT> &B);
66 
67 template<class MT>
68 bool CholeskyFactorize (const TCompRowMatrix<MT> &A, TCompRowMatrix<MT> &L,
69  TVector<MT> &d, bool recover = false);
70 
71 template<class MT>
72 bool IncompleteCholeskyFactorize (const TCompRowMatrix<MT> &A,
73  TCompRowMatrix<MT> &L, TVector<MT> &d, bool recover = false);
74 // Perform an incomplete Cholesky factorisation without creating additional
75 // fillin. Lower triangle (without diagonal) stored in L, diagonal stored in
76 // d. If recover==true, then non-SPD matrices will not cause a fatal error.
77 
78 template<class MT>
79 void LUFactorize (TCompRowMatrix<MT> &A, bool LUrealloc = true);
80 
81 template<class MT>
82 void CholeskySolve (const TCompRowMatrix<MT> &L, const TVector<MT> &d,
83  const TVector<MT> &b, TVector<MT> &x);
84 
85 template<class MT>
86 TVector<MT> CholeskySolve (const TCompRowMatrix<MT> &L, const TVector<MT> &d,
87  const TVector<MT> &b);
88 
89 template<class MT>
90 void CholeskySolve (const TCompRowMatrix<MT> &L, const TVector<MT> &d,
91  const TDenseMatrix<MT> &BT, TDenseMatrix<MT> &XT, int n = 0);
92 
93 template<class MT>
94 void LUSolve (const TCompRowMatrix<MT> &LU, const TVector<MT> &b,
95  TVector<MT> &x);
96 
97 template<class MT>
98 void LU (TCompRowMatrix<MT> &A, const TVector<MT> &b, TVector<MT> &x);
99 
100 template<class MT>
101 int ILUSolve (TCompRowMatrix<MT> &A, const TVector<MT> &b, TVector<MT> &x,
102  double tol = 1e-10, double droptol = 1e-3, int maxit = 500);
103 // solve general system Ax=b with ILU solver
104 
105 template<class MT>
106 int ILUSymSolve (TCompRowMatrix<MT> &A, const TVector<MT> &b, TVector<MT> &x,
107  double tol = 1e-10, double droptol = 1e-3, int maxit = 500);
108 // solve symmetric system Ax=b with ILU solver
109 
110 #ifdef USE_CUDA_FLOAT
111 template<class MT>
112 int PCG (const TCompRowMatrix<MT> &A, const TVector<MT> &b,
113  TVector<MT> &x, double &tol, TPreconditioner<MT> *precon = 0,
114  int maxit = 0);
115 
116 template<class MT>
117 void PCG (const TCompRowMatrix<MT> &A, const TVector<MT> *b,
118  TVector<MT> *x, int nrhs, double tol, int maxit = 0,
119  TPreconditioner<MT> *precon = 0, IterativeSolverResult *res = 0);
120 
121 template<class MT>
122 int BiCGSTAB (const TCompRowMatrix<MT> &A, const TVector<MT> &b,
123  TVector<MT> &x, double &tol, TPreconditioner<MT> *precon = 0,
124  int maxit = 0);
125 
126 template<class MT>
127 void BiCGSTAB (const TCompRowMatrix<MT> &A, const TVector<MT> *b,
128  TVector<MT> *x, int nrhs, double tol, int maxit = 0,
129  TPreconditioner<MT> *precon = 0, IterativeSolverResult *res = 0);
130 #endif // USE_CUDA_FLOAT
131 
132 
133 #ifdef ML_INTERFACE
134 
135 template<class MT>
136 int ML_matvec (ML_Operator *Amat, int in_length, double p[],
137  int out_length, double ap[]);
138 
139 template<class MT>
140 int ML_getrow (ML_Operator *Amat, int N_requested_rows,
141  int requested_rows[], int allocated_space, int columns[],
142  double values[], int row_lenghts[]);
143 
144 #endif // ML_INTERFACE
145 
146 template<class MT>
147 std::istream &operator>> (std::istream &is, TCompRowMatrix<MT> &m);
148 
149 template<class MT>
150 std::ostream &operator<< (std::ostream &os,
151  const TCompRowMatrix<MT> &m);
152 
153 // ==========================================================================
154 // class TCompRowMatrix
155 // ==========================================================================
170 template<class MT> class TCompRowMatrix: public TGenericSparseMatrix<MT> {
171 
172  friend class TPrecon_IC<MT>;
173  friend class CForwardSolver;
174  friend class CForwardSolverPP;
175  friend class SCCompRowMatrixMixed;
176 
177 public:
178 
182  TCompRowMatrix ();
183 
191  TCompRowMatrix (int rows, int cols);
192 
206  TCompRowMatrix (int rows, int cols,
207  const idxtype *_rowptr, const idxtype *_colidx,
208  const MT *data = 0);
209 
210  TCompRowMatrix (int rows, int cols,
211  idxtype *_rowptr, idxtype *_colidx,
212  MT *data, CopyMode cmode);
213 
221 
222  TCompRowMatrix (const TCoordMatrix<MT> &m);
223  TCompRowMatrix (const TDenseMatrix<MT> &m);
224  ~TCompRowMatrix ();
225 
227 
228  TCompRowMatrix<MT> Submatrix (int r1, int r2, int c1, int c2) const;
229  // return a submatrix of dimension r2-r1 x c2-c1 consisting of the block
230  // (r1 ... r2-1) x (c1 ... c2-1)
231 
232  TCompRowMatrix<MT> Subrows (int r1, int r2) const
233  { return Submatrix (r1, r2, 0, this->cols); }
234  // return a submatrix of dimension r2-r1 x cols consisting of the block
235  // (r1 ... r2-1) x (0 ... cols-1)
236 
237  TCompRowMatrix<MT> Subcols (int c1, int c2) const
238  { return Submatrix (0, this->rows, c1, c2); }
239  // return a submatrix of dimension rows x c2-c1 consisting of the block
240  // (0 ... rows-1) x (c1 ... c2-1)
241 
243  (const TCompRowMatrix<double> &A);
244  // type conversion
245 
246  TCoordMatrix<MT> MakeCoordMatrix () const;
247  // Convert *this into a coordinate storage matrix
248 
249  void New (int nrows, int ncols);
250  // reset logical dimension to nrows x ncols
251  // deallocate data and index lists, i.e. reset entries to zero
252  // Disables column access (call SetColumnAccess to enable)
253 
254  void Identity (int n);
255  // reset logical dimension to n x n, and set to identity matrix
256 
257  void DiagV (const TVector<MT> &x);
258  // reset to diagonal matrix
259 
260  void Unlink ();
261 
262  void Initialise (const idxtype *_rowptr, const idxtype *_colidx,
263  const MT *data = 0);
264  // Redefine sparse structure and assign data
265  // If data are not provided, all entries are set to zero
266 
267  int GetSparseStructure (const idxtype **_rowptr, const idxtype **_colidx) const
268  { *_rowptr = rowptr, *_colidx = colidx;
270 
271  TCompRowMatrix &operator= (const TCompRowMatrix<MT> &m);
272  // assignment
273 
274  TCompRowMatrix &operator= (const TCoordMatrix<MT> &m);
275  // assignment from coordinate storage matrix
276 
277  TCompRowMatrix<MT> operator- () const;
278  // unary minus
279 
280  TCompRowMatrix<MT> operator* (MT f) const;
281  // *this * f
282 
283  TCompRowMatrix<MT> operator* (const TDiagMatrix<MT> &D) const;
284  // TCompRowMatrix<MT> operator* ( RDiagMatrix &D) const;
285  // this * diagonal D
286 
287  inline TVector<MT> operator* (const TVector<MT> &x) const
288  { TVector<MT> b(TMatrix<MT>::rows); Ax(x,b); return b; }
289  // Multiplies *this with x and returns the result
290 
291  inline TCompRowMatrix<MT> operator* (const TCompRowMatrix<MT> &m) const
292  { TCompRowMatrix<MT> res; AB(m, res); return res; }
293  // Matrix multiplication: returns *this * m
294 
295  TCompRowMatrix<MT> operator+ (const TCompRowMatrix<MT> &m) const;
296  // *this + m
297 
298  TCompRowMatrix<MT> operator- (const TCompRowMatrix<MT> &m) const
299  { return operator+(-m); }
300  // *this - m
301 
302  TCompRowMatrix<MT> &operator+= (const TCompRowMatrix<MT> &m);
303 
304  TCompRowMatrix<MT> &operator-= (const TCompRowMatrix<MT> &m)
305  { return operator+=(-m); }
306 
316  friend TCompRowMatrix<MT> cath<> (const TCompRowMatrix<MT> &A,
317  const TCompRowMatrix<MT> &B);
318 
329  friend TCompRowMatrix<MT> catv<> (const TCompRowMatrix<MT> &A,
330  const TCompRowMatrix<MT> &B);
331 
332  TCompRowMatrix &merge (const TCompRowMatrix<MT> &m);
333  // Merges (adds) 'm' into 'this'. m can have different dimensions and
334  // different fill structure
335 
336  MT &operator() (int r, int c);
337  MT Get (int r, int c) const;
338  // access to element in row r, col c.
339  // First version for write access, second for read access
340 
341  bool Exists (int r, int c) const;
342  // true if an entry for the element is allocated
343 
344  TVector<MT> Row (int r) const;
345  // Returns row r as a vector
346 
347  TVector<MT> Col (int c) const;
348  // Returns column c as a vector
349 
350  int SparseRow (int r, idxtype *ci, MT *rv) const;
351  // See TMatrix
352 
353  void SetRow (int r, const TVector<MT> &row);
354  // Replace row r with 'row', removing zero elements
355 
356  void SetRows (int r0, const TCompRowMatrix<MT> &rows);
357  // starting with row r0, replace matrix rows with 'rows'
358 
359  void RemoveRow(int c);
360  //Remove row c;
361 
362  void ColScale (const TVector<MT> &scale);
363  // scales the columns with 'scale'
364 
365  void RowScale (const TVector<MT> &scale);
366  // scales the rows with 'scale'
367 
368  MT GetNext (int &r, int &c) const;
369 
370  void Ax (const TVector<MT> &x, TVector<MT> &b) const;
371  void Ax (const TVector<MT> &x, TVector<MT> &b, int r1, int r2) const;
372  void ATx (const TVector<MT> &x, TVector<MT> &b) const;
373 
374  void Ax_cplx (const TVector<std::complex<double> > &x,
375  TVector<std::complex<double> > &b)
376  const;
377  // special case: multiply with complex vector (only instantiated for
378  // real matrix)
379 
380  void ATx_cplx (const TVector<std::complex<double> > &x,
381  TVector<std::complex<double> > &b)const;
382  // special case: multiply transpose with complex vector (only instantiated
383  // for real matrix)
384 
385  void Ax (const TVector<MT> *x, TVector<MT> *b, int nrhs) const;
386 
387  void AB (const TCompRowMatrix<MT> &B, TCompRowMatrix<MT> &C) const;
388  // sparse matrix x matrix multiplication: C = *this * B
389 
390  void Transpone ();
391  // Replace matrix with its transpose
392 
393  friend TCompRowMatrix<MT> transp<> (const TCompRowMatrix<MT> &m);
394  // returns transpose of m
395 
396  friend double l2norm<> (const TCompRowMatrix<MT> &A);
397 
398  friend TCompRowMatrix<MT> kron<> (const TCompRowMatrix<MT> &A,
399  const TCompRowMatrix<MT> &B);
400  // Kronecker matrix product
401 
402  MT RowMult (int r, MT *x) const;
403  // inner product of row r with full vector given by x
404  // where dimension(x) >= ncols
405 
406  void Sort() const;
407  // sort row entries for ascending column index
408 
409  int Shrink ();
410  // Remove all entries with zero value. Return value is the number of
411  // eliminated entries.
412 
413  void SetColAccess (bool yes = true) const;
414  // Initialise or remove index lists required for column access
415 
416  void SetDiagAccess (bool yes = true) const;
417  // Initialise or remove index list required for diagonal access
418 
419  double LargestInRow (int r, int i = 0) const;
420  // Returns magnitude of the largest entry in row r, starting from the
421  // row's i-th entry
422 
423  double LargestInCol (int c, int i = 0) const;
424  // Returns magnitude of the largest entry in column c, starting from the
425  // column's i-th entry
426 
427  // Explicit linear solvers
428 
429  int pcg (const TVector<MT> &b, TVector<MT> &x,
430  double &tol, TPreconditioner<MT> *precon = 0, int maxit = 0)
431  const;
432 
433  void pcg (const TVector<MT> *b, TVector<MT> *x, int nrhs, double tol,
434  int maxit = 0, TPreconditioner<MT> *precon = 0,
435  IterativeSolverResult *res = 0) const;
436 
437  int bicgstab (const TVector<MT> &b, TVector<MT> &x,
438  double &tol, TPreconditioner<MT> *precon = 0, int maxit = 0)
439  const;
440 
441  void bicgstab (const TVector<MT> *b, TVector<MT> *x, int nrhs, double tol,
442  int maxit = 0, TPreconditioner<MT> *precon = 0,
443  IterativeSolverResult *res = 0) const;
444 
445  void SymbolicCholeskyFactorize (idxtype *&frowptr, idxtype *&fcolidx)
446  const;
447  // Calculate the sparse fill-in structure of the lower triangle of
448  // the Cholesky factorisation of the matrix (excluding diagonal)
449  // and return in index lists `frowptr' and 'fcolidx'
450 
451  void CalculateIncompleteCholeskyFillin (idxtype *&frowptr,
452  idxtype *&fcolidx) const;
453  // Calculate sparse structure for the lower triangle of the the
454  // incomplete Cholesky factorisation of the matrix. This is simply the
455  // structure of the lower triangle of the original matrix, excluding the
456  // diagonal. No additional fill-in is considered.
457 
458  friend bool CholeskyFactorize<> (const TCompRowMatrix<MT> &A,
459  TCompRowMatrix<MT> &L, TVector<MT> &d, bool recover);
460  // Perform Cholesky factorisation of A and return the result in lower
461  // triangle L and diagonal d (L does not contain diagonal elements)
462  // L must have been initialised with the index lists returned from
463  // A.CalculateCholeskyFillin()
464 
465  friend bool IncompleteCholeskyFactorize<> (const TCompRowMatrix<MT> &A,
466  TCompRowMatrix<MT> &L, TVector<MT> &d, bool recover);
467  // As above, but does not create additional fill-in. The structure of L
468  // must have been set according to A.CalculateIncompleteCholeskyFillin()
469 
470  friend void LUFactorize<> (TCompRowMatrix<MT> &A, bool LUrealloc);
471  // Perform LU factorisation of A and return result in LU
472  // Fill-in is calculated on the fly if data length of LU is 0
473  // Otherwise LU is expected to have correct fillin structure (e.g. from
474  // previous call to LUFactorize)
475 
476  friend void CholeskySolve<> (const TCompRowMatrix<MT> &L,
477  const TVector<MT> &d, const TVector<MT> &b, TVector<MT> &x);
478  // Returns solution of LL^T x = b in x
479  // d contains the diagonal elements of L, as returned by CholeskyFactorize
480 
481  friend TVector<MT> CholeskySolve<> (const TCompRowMatrix<MT> &L,
482  const TVector<MT> &d, const TVector<MT> &b);
483  // As above, but returns solution directly as function result (involves
484  // local vector construction)
485 
486  friend void CholeskySolve<> (const TCompRowMatrix<MT> &L,
487  const TVector<MT> &d, const TDenseMatrix<MT> &BT, TDenseMatrix<MT> &XT,
488  int n);
489  // Computes the solution of LL^T XT^T = BT^T for up to n columns of BT^T
490  // If n==0 then all columns of BT^T are used
491 
492  friend void LUSolve<> (const TCompRowMatrix<MT> &LU, const TVector<MT> &b,
493  TVector<MT> &x);
494  // Returns solution of LU x = b
495 
496  friend int ILUSolve<> (TCompRowMatrix<MT> &A, const TVector<MT> &b,
497  TVector<MT> &x, double tol, double droptol, int maxit);
498  // solve general system Ax=b with ILU solver
499 
500  friend int ILUSymSolve<> (TCompRowMatrix<MT> &A, const TVector<MT> &b,
501  TVector<MT> &x, double tol, double droptol, int maxit);
502  // solve symmetric system Ax=b with ILU solver
503 
504 #ifdef USE_CUDA_FLOAT
505  friend int PCG<> (const TCompRowMatrix<MT> &A,
506  const TVector<MT> &b, TVector<MT> &x, double &tol,
507  TPreconditioner<MT> *precon, int maxit);
508 
509  friend void PCG<> (const TCompRowMatrix<MT> &A,
510  const TVector<MT> *b, TVector<MT> *x, int nrhs, double tol, int maxit,
512 
513  friend int BiCGSTAB<> (const TCompRowMatrix<MT> &A,
514  const TVector<MT> &b, TVector<MT> &x, double &tol,
515  TPreconditioner<MT> *precon, int maxit);
516  // biconjugate gradient stabilised method.
517 
518  friend void BiCGSTAB<> (const TCompRowMatrix<MT> &A,
519  const TVector<MT> *b, TVector<MT> *x, int nrhs, double tol, int maxit,
521 
522 #endif
523 
524  void ExportHB (std::ostream &os);
525  // output matrix in Harwell-Boeing format
526 
542  void ExportRCV (std::ostream &os);
543 
544  void SplitExport (const char *rootname);
545  // write row index, column index and data in separate files
546 
547  friend std::istream &operator>> <> (std::istream &is,
548  TCompRowMatrix<MT> &m);
549  friend std::ostream &operator<< <> (std::ostream &os,
550  const TCompRowMatrix<MT> &m);
551  // IO in generic format
552 
553 protected:
554  void ReplaceRow (int row, int nz, int *rcolidx, MT *rval = 0);
555  // Replace 'row' with the nonzero structure defined by 'rcolindex' (nz
556  // entries). Assign values if provided.
557  // This method is expensive if nz is different from the current entry
558  // count of 'row' (requires memory re-allocation)
559 
560  void ReplaceRow (int row, const TVector<MT>& vec);
561  // Replace 'row' with the nonzero entries of the full row stored in
562  // vector 'data'
563 
564  MT row_mult (int r1, int r2, int from, int to) const;
565  // Returns dot product of rows r1 and r2, between columns `from' and 'to'
566  // REQUIRES ROWS TO BE SORTED WITH ASCENDING COLUMN INDEX
567 
568  MT sparsevec_mult (int *idx1, MT *val1, int n1,
569  int *idx2, MT *val2, int n2) const;
570  // Returns dot product of two sparse vectors given by index lists idx and
571  // data array val (n is length of sparse array)
572  // REQUIRES ROWS TO BE SORTED WITH ASCENDING COLUMN INDEX
573 
574 public:
575  idxtype *rowptr;
576  idxtype *colidx;
577 
578 private:
579  int Get_index (int r, int c) const;
580  // returns offset into data array of element at row r and column c
581  // returns -1 if entry does not exist
582 
583  MT Get_sorted (int r, int c) const;
584  void Put_sorted (int r, int c, MT v);
585  int Get_index_sorted (int r, int c) const;
586  // get or set entries assuming the matrix is sorted
587 
588  void CholeskySubst (const TVector<MT> &d, const MT *b, MT *x) const;
589  // Low-level driver routine for Cholesky forward and backward substitution
590 
591  mutable int iterator_pos;
592 
593  mutable bool sorted; // true if row entries are sorted
594 
595  mutable bool diag_access;
596  // true if diagonal access has been initialised
597  mutable int *diagptr;
598  // val[diagptr[i]] retrieves the diagonal element of row i
599  // if diagptr[i] < 0 then i has no diagonal entry
600 
601  mutable bool col_access; // true if column access has been initialised
602  // the following lists are only valid if col_access == true
603  mutable idxtype *colptr;
604  // offset to the first entry for column i in rowidx
605  mutable idxtype *rowidx;
606  // rowidx[colptr[i]+j] contains the row number of the j-th entry of col i
607  mutable idxtype *vofs;
608  // vofs[colptr[i]+j] contains the offset into data array val of the j-th
609  // entry of column i
610 
611 #ifdef ML_INTERFACE
612 friend int ML_matvec<> (ML_Operator *Amat, int in_length, double p[],
613  int out_length, double ap[]);
614 friend int ML_getrow<> (ML_Operator *Amat, int N_requested_rows,
615  int requested_rows[], int allocated_space, int columns[],
616  double values[], int row_lenghts[]);
617 #endif // ML_INTERFACE
618 
619 };
620 
621 // ==========================================================================
622 // typedefs for specific instances of `TCompRowMatrix'
623 
624 typedef TCompRowMatrix<double> RCompRowMatrix; // 'real'
625 typedef TCompRowMatrix<float> FCompRowMatrix; // 'float'
627 typedef TCompRowMatrix<std::complex<float> > SCCompRowMatrix; // 'single complex'
628 typedef TCompRowMatrix<int> ICompRowMatrix; // 'integer'
629 
630 // ==========================================================================
631 // extern declarations of TCompRowMatrix (only required for VS)
632 
633 #ifdef UNDEF
634 //#ifndef __CRMATRIX_CC
635 extern template class MATHLIB TCompRowMatrix<double>;
636 extern template class MATHLIB TCompRowMatrix<float>;
637 extern template class MATHLIB TCompRowMatrix<std::complex<double> >;
638 extern template class MATHLIB TCompRowMatrix<std::complex<float> >;
639 extern template class MATHLIB TCompRowMatrix<int>;
640 #endif // !__CRMATRIX_CC
641 
642 #endif // !__CRMATRIX_H
Virtual base class for sparse matrix types.
Definition: gsmatrix.h:47
void New(int nrows, int ncols)
Reset the matrix dimensions.
Definition: crmatrix_cm.h:37
TCompRowMatrix()
Creates a compressed-row matrix of dimension 0 x 0.
compressed row storage (sparse)
Definition: matrix.h:25
Coordinate-storage sparse matrix class.
Definition: cdmatrix.h:26
Definition: gsmatrix.h:48
MatrixStorage
Definition: matrix.h:20
int SparseRow(int r, idxtype *ci, MT *rv) const
Returns a row of the matrix in sparse format.
Diagonal matrix class.
Definition: crmatrix.h:39
MatrixStorage StorageType() const
Matrix storage class.
Definition: crmatrix.h:226
Compressed-row sparse matrix class.
Definition: cdmatrix.h:27
TVector< MT > Row(int r) const
Returns a vector containing a copy of row `r'.
MT Get(int r, int c) const
Retrieve a matrix element.
Virtual base class for all matrix types (dense and sparse)
Definition: matrix.h:43
void ExportRCV(std::ostream &os)
Write sparse matrix to ASCII output stream.
Dense matrix class.
Definition: crmatrix.h:38
Definition: crmatrix.h:37
bool Exists(int r, int c) const
Checks allocation of a matrix element.
Definition: matrix.h:34
void SetRow(int r, const TVector< MT > &row)
Substitute a row of the matrix.
TVector< MT > Col(int c) const
Returns a vector containing a copy of column 'c'.