COPASI API  4.16.103
CMatrix.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2014 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2002 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifndef COPASI_CMatrix
16 #define COPASI_CMatrix
17 
18 #include <algorithm> // for std::min
19 #include <iostream>
20 #include <assert.h>
21 #include <string.h>
22 
23 #include "copasi.h"
24 
25 #include "utilities/CVector.h"
26 
27 #undef min
28 #undef max
29 
30 template<typename CType> class CMatrix;
31 
32 template <class CType>
33 std::ostream &operator<<(std::ostream &os, const CMatrix< CType > & A);
34 
35 template <class Matrix> class CTransposeView;
36 
37 template <class Matrix>
38 std::ostream &operator << (std::ostream &os, const CTransposeView< Matrix > & A);
39 
40 template <class Matrix> class CLowerTriangularView;
41 
42 template <class Matrix>
43 std::ostream &operator<<(std::ostream &os, const CLowerTriangularView< Matrix > & A);
44 
45 template <class Matrix> class CUpperTriangularView;
46 
47 template <class Matrix>
48 std::ostream &operator<<(std::ostream &os, const CUpperTriangularView< Matrix > & A);
49 
50 template <class Matrix> class CUnitUpperTriangularView;
51 
52 template <class Matrix>
53 std::ostream &operator << (std::ostream &os, const CUnitUpperTriangularView< Matrix > & A);
54 
55 template <class Matrix> class CUnitLowerTriangularView;
56 
57 template <class Matrix>
58 std::ostream &operator << (std::ostream &os, const CUnitLowerTriangularView< Matrix > & A);
59 
60 /**
61  * Template class CMatrix < class CType >
62  * This template class is a simple matrix class allowing standard
63  * C-style and fortran style access to the elements. It also supplies
64  * an ostream operator.
65  */
66 template <class CType>
67 class CMatrix
68 {
69 public:
70  typedef CType elementType;
71 
72  // Attributes
73 protected:
74  /**
75  * Number of rows in the matrix.
76  */
77  size_t mRows;
78 
79  /**
80  * Number of columns in the matrix
81  */
82  size_t mCols;
83 
84  /**
85  * The array storing the matrix elements
86  */
87  CType * mArray;
88 
89  // Operations
90 public:
91  /**
92  * Default constructor
93  * @param size_t rows (default = 0)
94  * @param size_t cols (default = 0)
95  */
96  CMatrix(size_t rows = 0, size_t cols = 0) :
97  mRows(0),
98  mCols(0),
99  mArray(NULL)
100  {
101  resize(rows, cols);
102  }
103 
104  /**
105  * Copy constructor
106  * @param const CMatrix <CType> & src
107  */
108  CMatrix(const CMatrix <CType> & src):
109  mRows(0),
110  mCols(0),
111  mArray(NULL)
112  {
113  resize(src.mRows, src.mCols);
114 
115  if (mRows && mCols)
116  memcpy(mArray, src.mArray, mRows * mCols * sizeof(CType));
117  }
118 
119  /**
120  * Destructor.
121  */
122  virtual ~CMatrix()
123  {
124  if (mArray)
125  delete [] mArray;
126  }
127 
128  /**
129  * The number of elements stored in the matrix.
130  * @return size_t size
131  */
132  virtual size_t size() const {return mRows * mCols;}
133 
134  /**
135  * The number of rows of the matrix.
136  * @return size_t rows
137  */
138  virtual size_t numRows() const {return mRows;}
139 
140  /**
141  * The number of columns of the matrix
142  * @return size_t cols
143  */
144  virtual size_t numCols() const {return mCols;}
145 
146  /**
147  * Resize the matrix. The previous content is lost
148  * @param size_t rows
149  * @param size_t cols
150  */
151  virtual void resize(size_t rows, size_t cols, const bool & copy = false)
152  {
153  if (rows != mRows || cols != mCols)
154  {
155  size_t OldRows = mRows;
156  size_t OldCols = mCols;
157  CType * OldArray = mArray;
158  mArray = NULL;
159 
160  if (rows != 0 && cols != 0)
161  {
162  try
163  {
164  // We need to detect size_t overflow
165  if ((C_FLOAT64) rows * (C_FLOAT64) cols * (C_FLOAT64) sizeof(CType) >= (C_FLOAT64) std::numeric_limits< size_t >::max())
166  {
167  mArray = NULL;
168  }
169  else
170  {
171  mArray = new CType[rows * cols];
172  }
173  }
174 
175  catch (...)
176  {
177  mArray = NULL;
178  }
179 
180  if (mArray == NULL)
181  {
182  mRows = 0;
183  mCols = 0;
184 
185  CCopasiMessage(CCopasiMessage::EXCEPTION, MCopasiBase + 1, rows * cols * sizeof(CType));
186  }
187 
188  if (copy &&
189  mArray != NULL &&
190  OldArray != NULL)
191  {
192  // We copy the top left matrix (min(rows, OldRows), min(cols, OldCols);
193  size_t CopiedRows = std::min(rows, OldRows);
194  size_t CopiedColumns = std::min(cols, OldCols);
195 
196  CType * pOldRow = OldArray;
197  CType * pOldRowEnd = pOldRow + CopiedRows * OldCols;
198  CType * pRow = mArray;
199 
200  for (; pOldRow != pOldRowEnd; pOldRow += OldCols, pRow += cols)
201  {
202  memcpy(pRow, pOldRow, CopiedColumns * sizeof(CType));
203  }
204  }
205  }
206 
207  if (OldArray)
208  {
209  delete [] OldArray;
210  }
211  }
212 
213  mRows = rows;
214  mCols = cols;
215  }
216 
217  /**
218  * Assignment operator
219  * @param const CMatrix <CType> & rhs
220  * @return CMatrix <CType> & lhs
221  */
223  {
224  if (mRows != rhs.mRows || mCols != rhs.mCols)
225  resize(rhs.mRows, rhs.mCols);
226 
227  memcpy(mArray, rhs.mArray, mRows * mCols * sizeof(CType));
228 
229  return *this;
230  }
231 
232  /**
233  * Assignment operator
234  * @param const CType & value
235  * @return CMatrix <CType> & lhs
236  */
237  virtual CMatrix <CType> & operator = (const CType & value)
238  {
239  CType * pIt = mArray;
240  CType * pEnd = pIt + mRows * mCols;
241 
242  for (; pIt != pEnd; ++pIt) *pIt = value;
243 
244  return *this;
245  }
246 
247 #ifdef XXXX
248  /**
249  * Scalar multiplication operator
250  * @param const CType & value
251  * @return CMatrix <CType> & lhs
252  */
253  virtual CMatrix <CType> & operator *(const CType & value)
254  {
255  size_t i, imax = mRows * mCols;
256  CType * tmp = mArray;
257 
258  for (i = 0; i < imax; i++, tmp++) *tmp *= value;
259 
260  return *this;
261  }
262 
263  /**
264  * Scalar division operator
265  * @param const CType & value
266  * @return CMatrix <CType> & lhs
267  */
268  virtual CMatrix <CType> & operator / (const CType & value)
269  {return (*this) * (1.0 / value);}
270 
271  /**
272  * + operator
273  * @param const CMatrix <CType> & rhs
274  * @return CMatrix <CType> & lhs
275  */
276  virtual CMatrix <CType> & operator + (const CMatrix <CType> & rhs)
277  {
278  assert(mRows == rhs.mRows && mCols == rhs.mCols);
279 
280  size_t i, imax = mRows * mCols;
281  CType * tmp1 = mArray;
282  CType * tmp2 = rhs.mArray;
283 
284  for (i = 0; i < imax; i++, tmp1++, tmp2++) *tmp1 += *tmp2;
285 
286  return *this;
287  }
288 #endif // XXXX
289 
290  /**
291  * Retrieve a row of the matrix using c-style indexing
292  * @param size_t row
293  * @return CType * row
294  */
295  virtual inline CType * operator[](size_t row)
296  {return mArray + row * mCols;}
297 
298  /**
299  * Retrieve a row of the matrix using c-style indexing
300  * @param size_t row
301  * @return const CType * row
302  */
303  virtual inline const CType * operator[](size_t row) const
304  {return mArray + row * mCols;}
305 
306  /**
307  * Retrieve a matrix element using c-style indexing.
308  * @param const size_t & row
309  * @param const size_t & col
310  * @return const elementType & element
311  */
312  virtual inline elementType & operator()(const size_t & row,
313  const size_t & col)
314  {
315  assert(row < mRows && col < mCols);
316  return *(mArray + row * mCols + col);
317  }
318 
319  /**
320  * Retrieve a matrix element using c-style indexing.
321  * @param const size_t & row
322  * @param const size_t & col
323  * @return const elementType & element
324  */
325  virtual inline const elementType & operator()(const size_t & row,
326  const size_t & col) const
327  {
328  assert(row < mRows && col < mCols);
329  return *(mArray + row * mCols + col);
330  }
331 
332  /**
333  * Retrieve the array of the matrix elements. This is suitable
334  * for interfacing with clapack routines.
335  * @return CType * array
336  */
337  virtual CType * array() {return mArray;}
338 
339  /**
340  * Retrieve the array of the matrix elements. This is suitable
341  * for interfacing with clapack routines.
342  * @return const CType * array
343  */
344  virtual const CType * array() const {return mArray;}
345 
346  /**
347  * Reorder the rows according to the provided pivots
348  * @param const CVector<size_t> & pivot
349  * @return bool success
350  */
351  bool applyPivot(const CVector<size_t> & pivot)
352  {
353  if (pivot.size() != mRows) return false;
354 
355  CVector< bool > Applied(mRows);
356  Applied = false;
357  CType *pTmp = new CType[mCols];
358 
359  size_t i;
360  size_t to;
361  size_t from;
362 
363  for (i = 0; i < mRows; i++)
364  if (!Applied[i])
365  {
366  to = i;
367  from = pivot[i];
368 
369  if (to != from)
370  {
371  memcpy(pTmp, mArray + i * mCols, mCols * sizeof(CType));
372 
373  while (from != i)
374  {
375  memcpy(mArray + to * mCols, mArray + from * mCols, mCols * sizeof(CType));
376  Applied[to] = true;
377 
378  to = from;
379  from = pivot[to];
380  }
381 
382  memcpy(mArray + to * mCols, pTmp, mCols * sizeof(CType));
383  }
384 
385  Applied[to] = true;
386  }
387 
388  pdeletev(pTmp);
389  return true;
390  }
391 
392  /**
393  * Output stream operator
394  * @param ostream & os
395  * @param const CMatrix< CType > & A
396  * @return ostream & os
397  */
398 #if defined SWIG
399  friend std::ostream &operator <<(std::ostream &os,
400  const CMatrix< CType > & A);
401 #else
402 #if defined _MSC_VER && _MSC_VER < 1201 // 1200 Identifies Visual C++ 6.0
403  friend std::ostream &operator <<(std::ostream &os,
404  const CMatrix< CType > & A);
405 #else
406  friend std::ostream &operator << <> (std::ostream &os,
407  const CMatrix< CType > & A);
408 #endif // WIN32
409 #endif // SWIG
410 };
411 
412 template <class Matrix>
414 {
415 public:
416  typedef typename Matrix::elementType elementType;
417 
418 private:
419  Matrix & mA;
420 
421 public:
422  CFortranAccess(Matrix & A):
423  mA(A)
424  {}
425 
427 
428  /**
429  * Retrieve a row of the matrix using Fortran style indexing.
430  * @param size_t row
431  * @return elementType * row
432  */
433  inline elementType * operator[](size_t row)
434  {return mA[row - 1] - 1;}
435 
436  /**
437  * Retrieve a row of the matrix using Fortran style indexing.
438  * @param size_t row
439  * @return const elementType * row
440  */
441  inline const elementType * operator[](size_t row) const
442  {return mA[row - 1] - 1;}
443 
444  /**
445  * Retrieve a matrix element using Fortran style indexing.
446  * @param const size_t & row
447  * @param const size_t & col
448  * @return const elementType & element
449  */
450  inline elementType & operator()(const size_t & row,
451  const size_t & col)
452  {return mA(row - 1, col - 1);}
453 
454  /**
455  * Retrieve a matrix element using Fortran style indexing.
456  * @param const size_t & row
457  * @param const size_t & col
458  * @return const elementType & element
459  */
460  inline const elementType & operator()(const size_t & row,
461  const size_t & col) const
462  {return mA(row - 1, col - 1);}
463 };
464 
465 template <class Matrix>
467 {
468 public:
469  typedef typename Matrix::elementType elementType;
470 
471 private:
472  const Matrix & mA;
474 
475 public:
476  CUpperTriangularView(const Matrix & A, const elementType zero):
477  mA(A),
478  mZero(zero)
479  {}
480 
482 
483  /**
484  * The number of rows of the matrix.
485  * @return size_t rows
486  */
487  size_t numRows() const {return mA.numRows();}
488 
489  /**
490  * The number of columns of the matrix
491  * @return size_t cols
492  */
493  size_t numCols() const {return mA.numCols();}
494 
495  /**
496  * Retrieve a matrix element using the indexing style of the matrix.
497  * @param const size_t & row
498  * @param const size_t & col
499  * @return elementType element
500  */
501  inline elementType operator()(const size_t & row,
502  const size_t & col) const
503  {
504  if (row > col)
505  return mZero;
506  else
507  return mA(row, col);
508  }
509 
510  /**
511  * Output stream operator
512  * @param ostream & os
513  * @param const CUpperTriangularView< Matrix > & A
514  * @return ostream & os
515  */
516 #ifdef SWIG
517  friend
518  std::ostream &operator << (std::ostream &os,
520 #else
521 #if defined _MSC_VER && _MSC_VER < 1201 // 1200 Identifies Visual C++ 6.0
522  friend
523  std::ostream &operator << (std::ostream &os,
525 #else
526  friend
527  std::ostream &operator << <>(std::ostream &os,
529 #endif // WIN32
530 #endif // SWIG
531 };
532 
533 template <class Matrix>
535 {
536 public:
537  typedef typename Matrix::elementType elementType;
538 
539 private:
540  const Matrix & mA;
542 
543 public:
544  CLowerTriangularView(const Matrix & A, const elementType zero):
545  mA(A),
546  mZero(zero)
547  {}
548 
550 
551  /**
552  * The number of rows of the matrix.
553  * @return size_t rows
554  */
555  size_t numRows() const {return mA.numRows();}
556 
557  /**
558  * The number of columns of the matrix
559  * @return size_t cols
560  */
561  size_t numCols() const {return mA.numCols();}
562 
563  /**
564  * Retrieve a matrix element using the indexing style of the matrix.
565  * @param const size_t & row
566  * @param const size_t & col
567  * @return elementType element
568  */
569  inline elementType operator()(const size_t & row,
570  const size_t & col) const
571  {
572  if (row < col)
573  return mZero;
574  else
575  return mA(row, col);
576  }
577 
578  /**
579  * Output stream operator
580  * @param ostream & os
581  * @param const CLowerTriangularView< Matrix > & A
582  * @return ostream & os
583  */
584 #ifdef SWIG
585  friend
586  std::ostream &operator << (std::ostream &os,
588 #else
589 #if defined _MSC_VER && _MSC_VER < 1201 // 1200 Identifies Visual C++ 6.0
590  friend
591  std::ostream &operator << (std::ostream &os,
593 #else
594  friend
595  std::ostream &operator << <>(std::ostream &os,
597 #endif // WIN32
598 #endif // SWIG
599 };
600 
601 template <class Matrix>
603 {
604 public:
605  typedef typename Matrix::elementType elementType;
606 
607 private:
608  const Matrix & mA;
611 
612 public:
613  CUnitUpperTriangularView(const Matrix & A,
614  const elementType zero,
615  const elementType unit):
616  mA(A),
617  mZero(zero),
618  mUnit(unit)
619  {}
620 
622 
623  /**
624  * The number of rows of the matrix.
625  * @return size_t rows
626  */
627  size_t numRows() const {return mA.numRows();}
628 
629  /**
630  * The number of columns of the matrix
631  * @return size_t cols
632  */
633  size_t numCols() const {return mA.numCols();}
634 
635  /**
636  * Retrieve a matrix element using the indexing style of the matrix.
637  * @param const size_t & row
638  * @param const size_t & col
639  * @return elementType element
640  */
641  inline elementType operator()(const size_t & row,
642  const size_t & col) const
643  {
644  if (row < col)
645  return mA(row, col);
646  else if (row > col)
647  return mZero;
648  else
649  return mUnit;
650  }
651 
652  /**
653  * Output stream operator
654  * @param ostream & os
655  * @param const CUnitUpperTriangularView< Matrix > & A
656  * @return ostream & os
657  */
658 #ifdef SWIG
659  friend
660  std::ostream &operator << (std::ostream &os,
662 #else
663 #if defined _MSC_VER && _MSC_VER < 1201 // 1200 Identifies Visual C++ 6.0
664  friend
665  std::ostream &operator << (std::ostream &os,
667 #else
668  friend
669  std::ostream &operator << <>(std::ostream &os,
671 #endif // WIN32
672 #endif // SWIG
673 };
674 
675 template <class Matrix>
677 {
678 public:
679  typedef typename Matrix::elementType elementType;
680 
681 private:
682  const Matrix & mA;
685 
686 public:
687  CUnitLowerTriangularView(const Matrix & A,
688  const elementType zero,
689  const elementType unit):
690  mA(A),
691  mZero(zero),
692  mUnit(unit)
693  {}
694 
696 
697  /**
698  * The number of rows of the matrix.
699  * @return size_t rows
700  */
701  size_t numRows() const {return mA.numRows();}
702 
703  /**
704  * The number of columns of the matrix
705  * @return size_t cols
706  */
707  size_t numCols() const {return mA.numCols();}
708 
709  /**
710  * Retrieve a matrix element using the indexing style of the matrix.
711  * @param const size_t & row
712  * @param const size_t & col
713  * @return elementType element
714  */
715  inline elementType operator()(const size_t & row,
716  const size_t & col) const
717  {
718  if (row > col)
719  return mA(row, col);
720  else if (row < col)
721  return mZero;
722  else
723  return mUnit;
724  }
725 
726  /**
727  * Output stream operator
728  * @param ostream & os
729  * @param const CUnitLowerTriangularView< Matrix > & A
730  * @return ostream & os
731  */
732 #ifdef SWIG
733  friend
734  std::ostream &operator << (std::ostream &os,
736 #else
737 #if defined _MSC_VER && _MSC_VER < 1201 // 1200 Identifies Visual C++ 6.0
738  friend
739  std::ostream &operator << (std::ostream &os,
741 #else
742  friend
743  std::ostream &operator << <> (std::ostream &os,
745 #endif // WIN32
746 #endif // SWIG
747 };
748 
749 template <class Matrix>
750 class CTransposeView
751 {
752 public:
753  typedef typename Matrix::elementType elementType;
754 
755 private:
756  const Matrix & mA;
757 
758 public:
759  CTransposeView(const Matrix & A): mA(A) {}
760 
762 
763  /**
764  * The number of rows of the matrix.
765  * @return size_t rows
766  */
767  size_t numRows() const {return mA.numCols();}
768 
769  /**
770  * The number of columns of the matrix
771  * @return size_t cols
772  */
773  size_t numCols() const {return mA.numRows();}
774 
775  /**
776  * Retrieve a matrix element using the indexing style of the matrix.
777  * @param const size_t & row
778  * @param const size_t & col
779  * @return elementType element
780  */
781  inline elementType operator()(const size_t & row,
782  const size_t & col) const
783  {return mA(col, row);}
784 
785  /**
786  * Output stream operator
787  * @param ostream & os
788  * @param const CTransposeView< Matrix > & A
789  * @return ostream & os
790  */
791 #ifdef SWIG
792  friend
793  std::ostream &operator << (std::ostream &os,
794  const CTransposeView< Matrix > & A);
795 #else
796 #if defined _MSC_VER && _MSC_VER < 1201 // 1200 Identifies Visual C++ 6.0
797  friend
798  std::ostream &operator << (std::ostream &os,
799  const CTransposeView< Matrix > & A);
800 #else
801  friend
802  std::ostream &operator << <>(std::ostream &os,
803  const CTransposeView< Matrix > & A);
804 #endif // WIN32
805 #endif // SWIG
806 };
807 
808 template <class CType>
809 std::ostream &operator<<(std::ostream &os, const CMatrix< CType > & A)
810 {
811  os << "Matrix(" << A.mRows << "x" << A.mCols << ")" << std::endl;
812 
813  size_t i, j;
814  CType * tmp = A.mArray;
815 
816  for (i = 0; i < A.mRows; i++)
817  {
818  for (j = 0; j < A.mCols; j++)
819  os << "\t" << *(tmp++);
820 
821  os << std::endl;
822  }
823 
824  return os;
825 }
826 
827 template <class Matrix>
828 std::ostream &operator<<(std::ostream &os,
830 {
831  size_t i, imax = A.numRows();
832  size_t j, jmax = A.numCols();
833  os << "Matrix(" << imax << "x" << jmax << ")" << std::endl;
834 
835  for (i = 0; i < imax; i++)
836  {
837  for (j = 0; j < jmax; j++)
838  os << "\t" << A(i, j);
839 
840  os << std::endl;
841  }
842 
843  return os;
844 }
845 
846 template <class Matrix>
847 std::ostream &operator<<(std::ostream &os,
849 {
850  size_t i, imax = A.numRows();
851  size_t j, jmax = A.numCols();
852  os << "Matrix(" << imax << "x" << jmax << ")" << std::endl;
853 
854  for (i = 0; i < imax; i++)
855  {
856  for (j = 0; j < jmax; j++)
857  os << "\t" << A(i, j);
858 
859  os << std::endl;
860  }
861 
862  return os;
863 }
864 
865 template <class Matrix>
866 std::ostream &operator << (std::ostream &os,
868 {
869  size_t i, imax = A.numRows();
870  size_t j, jmax = A.numCols();
871  os << "Matrix(" << imax << "x" << jmax << ")" << std::endl;
872 
873  for (i = 0; i < imax; i++)
874  {
875  for (j = 0; j < jmax; j++)
876  os << "\t" << A(i, j);
877 
878  os << std::endl;
879  }
880 
881  return os;
882 }
883 
884 template <class Matrix>
885 std::ostream &operator << (std::ostream &os,
887 {
888  size_t i, imax = A.numRows();
889  size_t j, jmax = A.numCols();
890  os << "Matrix(" << imax << "x" << jmax << ")" << std::endl;
891 
892  for (i = 0; i < imax; i++)
893  {
894  for (j = 0; j < jmax; j++)
895  os << "\t" << A(i, j);
896 
897  os << std::endl;
898  }
899 
900  return os;
901 }
902 
903 template <class Matrix>
904 std::ostream &operator << (std::ostream &os,
905  const CTransposeView< Matrix > & A)
906 {
907  size_t i, imax = A.numRows();
908  size_t j, jmax = A.numCols();
909  os << "Matrix(" << imax << "x" << jmax << ")" << std::endl;
910 
911  for (i = 0; i < imax; i++)
912  {
913  for (j = 0; j < jmax; j++)
914  os << "\t" << A(i, j);
915 
916  os << std::endl;
917  }
918 
919  return os;
920 }
921 
922 #endif // COPASI_CMatrix
virtual const CType * operator[](size_t row) const
Definition: CMatrix.h:303
size_t mCols
Definition: CMatrix.h:82
friend std::ostream & operator<<(std::ostream &os, const CUnitUpperTriangularView< Matrix > &A)
Definition: CMatrix.h:866
elementType operator()(const size_t &row, const size_t &col) const
Definition: CMatrix.h:569
elementType & operator()(const size_t &row, const size_t &col)
Definition: CMatrix.h:450
friend std::ostream & operator<<(std::ostream &os, const CLowerTriangularView< Matrix > &A)
Definition: CMatrix.h:847
elementType operator()(const size_t &row, const size_t &col) const
Definition: CMatrix.h:501
virtual CMatrix< CType > & operator=(const CMatrix< CType > &rhs)
Definition: CMatrix.h:222
CTransposeView(const Matrix &A)
Definition: CMatrix.h:759
elementType mZero
Definition: CMatrix.h:473
std::ostream & operator<<(std::ostream &os, const CMatrix< CType > &A)
Definition: CMatrix.h:809
Matrix::elementType elementType
Definition: CMatrix.h:605
virtual size_t numRows() const
Definition: CMatrix.h:138
CFortranAccess(Matrix &A)
Definition: CMatrix.h:422
Matrix::elementType elementType
Definition: CMatrix.h:469
elementType * operator[](size_t row)
Definition: CMatrix.h:433
CType * mArray
Definition: CMatrix.h:87
elementType operator()(const size_t &row, const size_t &col) const
Definition: CMatrix.h:781
CUnitLowerTriangularView(const Matrix &A, const elementType zero, const elementType unit)
Definition: CMatrix.h:687
size_t numCols() const
Definition: CMatrix.h:493
size_t numRows() const
Definition: CMatrix.h:555
size_t numCols() const
Definition: CMatrix.h:773
size_t numCols() const
Definition: CMatrix.h:633
#define MCopasiBase
const Matrix & mA
Definition: CMatrix.h:472
#define pdeletev(p)
Definition: copasi.h:216
elementType operator()(const size_t &row, const size_t &col) const
Definition: CMatrix.h:641
friend std::ostream & operator<<(std::ostream &os, const CMatrix< CType > &A)
Definition: CMatrix.h:809
size_t numCols() const
Definition: CMatrix.h:707
CMatrix(size_t rows=0, size_t cols=0)
Definition: CMatrix.h:96
size_t numRows() const
Definition: CMatrix.h:767
Matrix::elementType elementType
Definition: CMatrix.h:679
virtual CType * operator[](size_t row)
Definition: CMatrix.h:295
CType elementType
Definition: CMatrix.h:70
size_t numCols() const
Definition: CMatrix.h:561
const Matrix & mA
Definition: CMatrix.h:608
virtual void resize(size_t rows, size_t cols, const bool &copy=false)
Definition: CMatrix.h:151
virtual ~CMatrix()
Definition: CMatrix.h:122
const Matrix & mA
Definition: CMatrix.h:682
size_t size() const
Definition: CVector.h:100
CUnitUpperTriangularView(const Matrix &A, const elementType zero, const elementType unit)
Definition: CMatrix.h:613
#define C_FLOAT64
Definition: copasi.h:92
bool applyPivot(const CVector< size_t > &pivot)
Definition: CMatrix.h:351
Matrix::elementType elementType
Definition: CMatrix.h:537
Matrix & mA
Definition: CMatrix.h:419
elementType operator()(const size_t &row, const size_t &col) const
Definition: CMatrix.h:715
virtual size_t size() const
Definition: CMatrix.h:132
friend std::ostream & operator<<(std::ostream &os, const CTransposeView< Matrix > &A)
Definition: CMatrix.h:904
const Matrix & mA
Definition: CMatrix.h:540
CLowerTriangularView(const Matrix &A, const elementType zero)
Definition: CMatrix.h:544
friend std::ostream & operator<<(std::ostream &os, const CUpperTriangularView< Matrix > &A)
Definition: CMatrix.h:828
virtual elementType & operator()(const size_t &row, const size_t &col)
Definition: CMatrix.h:312
const elementType * operator[](size_t row) const
Definition: CMatrix.h:441
size_t mRows
Definition: CMatrix.h:77
virtual const CType * array() const
Definition: CMatrix.h:344
size_t numRows() const
Definition: CMatrix.h:627
virtual size_t numCols() const
Definition: CMatrix.h:144
virtual const elementType & operator()(const size_t &row, const size_t &col) const
Definition: CMatrix.h:325
elementType mZero
Definition: CMatrix.h:541
CMatrix(const CMatrix< CType > &src)
Definition: CMatrix.h:108
const elementType & operator()(const size_t &row, const size_t &col) const
Definition: CMatrix.h:460
CUpperTriangularView(const Matrix &A, const elementType zero)
Definition: CMatrix.h:476
size_t numRows() const
Definition: CMatrix.h:701
virtual CType * array()
Definition: CMatrix.h:337
#define min(a, b)
Definition: f2c.h:175
Matrix::elementType elementType
Definition: CMatrix.h:753
size_t numRows() const
Definition: CMatrix.h:487
Matrix::elementType elementType
Definition: CMatrix.h:416
friend std::ostream & operator<<(std::ostream &os, const CUnitLowerTriangularView< Matrix > &A)
Definition: CMatrix.h:885
const Matrix & mA
Definition: CMatrix.h:756
#define max(a, b)
Definition: f2c.h:176