newmat.h
Go to the documentation of this file.
1 
6 
7 // Copyright (C) 2004: R B Davies
8 
9 #ifndef NEWMAT_LIB
10 #define NEWMAT_LIB 0
11 
12 #include "include.h"
13 
14 #include "myexcept.h"
15 
16 
17 #ifdef use_namespace
18 namespace NEWMAT { using namespace RBD_COMMON; }
19 namespace RBD_LIBRARIES { using namespace NEWMAT; }
20 namespace NEWMAT {
21 #endif
22 
23 //#define DO_REPORT // to activate REPORT
24 
25 #ifdef NO_LONG_NAMES
26 #define UpperTriangularMatrix UTMatrix
27 #define LowerTriangularMatrix LTMatrix
28 #define SymmetricMatrix SMatrix
29 #define DiagonalMatrix DMatrix
30 #define BandMatrix BMatrix
31 #define UpperBandMatrix UBMatrix
32 #define LowerBandMatrix LBMatrix
33 #define SymmetricBandMatrix SBMatrix
34 #define BandLUMatrix BLUMatrix
35 #endif
36 
37 // ************************** general utilities ****************************/
38 
39 class GeneralMatrix; // defined later
40 class BaseMatrix; // defined later
41 class MatrixInput; // defined later
42 
43 void MatrixErrorNoSpace(const void*);
44 
48 {
50  int sign_val;
51 public:
52  LogAndSign() { log_val=0.0; sign_val=1; }
54  void operator*=(Real);
55  void pow_eq(int k);
56  void PowEq(int k) { pow_eq(k); }
57  void ChangeSign() { sign_val = -sign_val; }
58  void change_sign() { sign_val = -sign_val; }
59  Real LogValue() const { return log_val; }
60  Real log_value() const { return log_val; }
61  int Sign() const { return sign_val; }
62  int sign() const { return sign_val; }
63  Real value() const;
64  Real Value() const { return value(); }
66 };
67 
68 // the following class is for counting the number of times a piece of code
69 // is executed. It is used for locating any code not executed by test
70 // routines. Use turbo GREP locate all places this code is called and
71 // check which ones are not accessed.
72 // Somewhat implementation dependent as it relies on "cout" still being
73 // present when ExeCounter objects are destructed.
74 
75 #ifdef DO_REPORT
76 
77 class ExeCounter
78 {
79  int line; // code line number
80  int fileid; // file identifier
81  long nexe; // number of executions
82  static int nreports; // number of reports
83 public:
84  ExeCounter(int,int);
85  void operator++() { nexe++; }
86  ~ExeCounter(); // prints out reports
87 };
88 
89 #endif
90 
91 
92 // ************************** class MatrixType *****************************
93 
97 
99 {
100 public:
101  enum Attribute { Valid = 1,
102  Diagonal = 2, // order of these is important
103  Symmetric = 4,
104  Band = 8,
105  Lower = 16,
106  Upper = 32,
107  Square = 64,
108  Skew = 128,
109  LUDeco = 256,
110  Ones = 512 };
111 
112  enum { US = 0,
113  UT = Valid + Upper + Square,
114  LT = Valid + Lower + Square,
115  Rt = Valid,
116  Sq = Valid + Square,
117  Sm = Valid + Symmetric + Square,
118  Sk = Valid + Skew + Square,
119  Dg = Valid + Diagonal + Band + Lower + Upper + Symmetric
120  + Square,
121  Id = Valid + Diagonal + Band + Lower + Upper + Symmetric
122  + Square + Ones,
123  RV = Valid, // do not separate out
124  CV = Valid, // vectors
125  BM = Valid + Band + Square,
126  UB = Valid + Band + Upper + Square,
127  LB = Valid + Band + Lower + Square,
128  SB = Valid + Band + Symmetric + Square,
129  KB = Valid + Band + Skew + Square,
130  Ct = Valid + LUDeco + Square,
131  BC = Valid + Band + LUDeco + Square,
132  Mask = ~Square
133  };
134 
135 
136  static int nTypes() { return 13; } // number of different types
137  // exclude Ct, US, BC
138 public:
140  bool DataLossOK; // true if data loss is OK when
141  // this represents a destination
142 public:
143  MatrixType () : DataLossOK(false) {}
144  MatrixType (int i) : attribute(i), DataLossOK(false) {}
145  MatrixType (int i, bool dlok) : attribute(i), DataLossOK(dlok) {}
146  MatrixType (const MatrixType& mt)
147  : attribute(mt.attribute), DataLossOK(mt.DataLossOK) {}
148  void operator=(const MatrixType& mt)
149  { attribute = mt.attribute; DataLossOK = mt.DataLossOK; }
150  void SetDataLossOK() { DataLossOK = true; }
151  int operator+() const { return attribute; }
153  { return MatrixType(attribute & mt.attribute); }
154  MatrixType operator*(const MatrixType&) const;
155  MatrixType SP(const MatrixType&) const;
156  MatrixType KP(const MatrixType&) const;
157  MatrixType operator|(const MatrixType& mt) const
158  { return MatrixType(attribute & mt.attribute & Valid); }
159  MatrixType operator&(const MatrixType& mt) const
160  { return MatrixType(attribute & mt.attribute & Valid); }
161  bool operator>=(MatrixType mt) const
162  { return ( attribute & ~mt.attribute & Mask ) == 0; }
163  bool operator<(MatrixType mt) const // for MS Visual C++ 4
164  { return ( attribute & ~mt.attribute & Mask ) != 0; }
165  bool operator==(MatrixType t) const
166  { return (attribute == t.attribute); }
167  bool operator!=(MatrixType t) const
168  { return (attribute != t.attribute); }
169  bool operator!() const { return (attribute & Valid) == 0; }
170  MatrixType i() const;
171  MatrixType t() const;
173  { return MatrixType(attribute & (Valid + Symmetric + Square)); }
174  MatrixType MultRHS() const;
175  MatrixType sub() const
176  { return MatrixType(attribute & Valid); }
177  MatrixType ssub() const
178  { return MatrixType(attribute); } // not for selection matrix
179  GeneralMatrix* New() const;
180  GeneralMatrix* New(int,int,BaseMatrix*) const;
182  const char* value() const;
183  const char* Value() const { return value(); }
184  friend bool Rectangular(MatrixType a, MatrixType b, MatrixType c);
185  friend bool Compare(const MatrixType&, MatrixType&);
187  bool is_band() const { return (attribute & Band) != 0; }
188  bool is_diagonal() const { return (attribute & Diagonal) != 0; }
189  bool is_symmetric() const { return (attribute & Symmetric) != 0; }
190  bool CannotConvert() const { return (attribute & LUDeco) != 0; }
191  // used by operator==
193 };
194 
195 
196 // *********************** class MatrixBandWidth ***********************/
197 
203 {
204 public:
207  MatrixBandWidth(const int l, const int u) : lower_val(l), upper_val(u) {}
208  MatrixBandWidth(const int i) : lower_val(i), upper_val(i) {}
212  MatrixBandWidth t() const { return MatrixBandWidth(upper_val,lower_val); }
213  bool operator==(const MatrixBandWidth& bw) const
214  { return (lower_val == bw.lower_val) && (upper_val == bw.upper_val); }
215  bool operator!=(const MatrixBandWidth& bw) const { return !operator==(bw); }
216  int Upper() const { return upper_val; }
217  int upper() const { return upper_val; }
218  int Lower() const { return lower_val; }
219  int lower() const { return lower_val; }
221 };
222 
223 
224 // ********************* Array length specifier ************************/
225 
229 
231 {
232  int v;
233 public:
234  int Value() const { return v; }
235  int value() const { return v; }
236  ArrayLengthSpecifier(int l) : v(l) {}
237 };
238 
239 // ************************* Matrix routines ***************************/
240 
241 
242 class MatrixRowCol; // defined later
243 class MatrixRow;
244 class MatrixCol;
245 class MatrixColX;
246 
247 class GeneralMatrix; // defined later
248 class AddedMatrix;
249 class MultipliedMatrix;
250 class SubtractedMatrix;
251 class SPMatrix;
252 class KPMatrix;
253 class ConcatenatedMatrix;
254 class StackedMatrix;
255 class SolvedMatrix;
256 class ShiftedMatrix;
257 class NegShiftedMatrix;
258 class ScaledMatrix;
259 class TransposedMatrix;
260 class ReversedMatrix;
261 class NegatedMatrix;
262 class InvertedMatrix;
263 class RowedMatrix;
264 class ColedMatrix;
265 class DiagedMatrix;
266 class MatedMatrix;
267 class GetSubMatrix;
268 class ReturnMatrix;
269 class Matrix;
270 class SquareMatrix;
271 class nricMatrix;
272 class RowVector;
273 class ColumnVector;
274 class SymmetricMatrix;
277 class DiagonalMatrix;
278 class CroutMatrix;
279 class BandMatrix;
280 class LowerBandMatrix;
281 class UpperBandMatrix;
282 class SymmetricBandMatrix;
284 class GenericMatrix;
285 
286 
287 #define MatrixTypeUnSp 0
288 //static MatrixType MatrixTypeUnSp(MatrixType::US);
289 // // AT&T needs this
290 
292 class BaseMatrix : public Janitor
293 {
294 protected:
295  virtual int search(const BaseMatrix*) const = 0;
296  // count number of times matrix is referred to
297 public:
298  virtual GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp) = 0;
299  // evaluate temporary
300  // for old version of G++
301  // virtual GeneralMatrix* Evaluate(MatrixType mt) = 0;
302  // GeneralMatrix* Evaluate() { return Evaluate(MatrixTypeUnSp); }
303  AddedMatrix operator+(const BaseMatrix&) const; // results of operations
304  MultipliedMatrix operator*(const BaseMatrix&) const;
305  SubtractedMatrix operator-(const BaseMatrix&) const;
306  ConcatenatedMatrix operator|(const BaseMatrix&) const;
307  StackedMatrix operator&(const BaseMatrix&) const;
309  ScaledMatrix operator*(Real) const;
310  ScaledMatrix operator/(Real) const;
312  TransposedMatrix t() const;
313 // TransposedMatrix t;
314  NegatedMatrix operator-() const; // change sign of elements
315  ReversedMatrix reverse() const;
316  ReversedMatrix Reverse() const;
317  InvertedMatrix i() const;
318 // InvertedMatrix i;
319  RowedMatrix as_row() const;
320  RowedMatrix AsRow() const;
321  ColedMatrix as_column() const;
322  ColedMatrix AsColumn() const;
323  DiagedMatrix as_diagonal() const;
324  DiagedMatrix AsDiagonal() const;
325  MatedMatrix as_matrix(int,int) const;
326  MatedMatrix AsMatrix(int m, int n) const;
327  GetSubMatrix submatrix(int,int,int,int) const;
328  GetSubMatrix SubMatrix(int fr, int lr, int fc, int lc) const;
329  GetSubMatrix sym_submatrix(int,int) const;
330  GetSubMatrix SymSubMatrix(int f, int l) const;
331  GetSubMatrix row(int) const;
332  GetSubMatrix rows(int,int) const;
333  GetSubMatrix column(int) const;
334  GetSubMatrix columns(int,int) const;
335  GetSubMatrix Row(int f) const;
336  GetSubMatrix Rows(int f, int l) const;
337  GetSubMatrix Column(int f) const;
338  GetSubMatrix Columns(int f, int l) const;
339  Real as_scalar() const; // conversion of 1 x 1 matrix
340  Real AsScalar() const;
341  virtual LogAndSign log_determinant() const;
343  Real determinant() const;
344  Real Determinant() const { return determinant(); }
345  virtual Real sum_square() const;
346  Real SumSquare() const { return sum_square(); }
347  Real norm_Frobenius() const;
348  Real norm_frobenius() const { return norm_Frobenius(); }
349  Real NormFrobenius() const { return norm_Frobenius(); }
350  virtual Real sum_absolute_value() const;
352  virtual Real sum() const;
353  virtual Real Sum() const { return sum(); }
354  virtual Real maximum_absolute_value() const;
356  virtual Real maximum_absolute_value1(int& i) const;
358  { return maximum_absolute_value1(i); }
359  virtual Real maximum_absolute_value2(int& i, int& j) const;
360  Real MaximumAbsoluteValue2(int& i, int& j) const
361  { return maximum_absolute_value2(i,j); }
362  virtual Real minimum_absolute_value() const;
364  virtual Real minimum_absolute_value1(int& i) const;
366  { return minimum_absolute_value1(i); }
367  virtual Real minimum_absolute_value2(int& i, int& j) const;
368  Real MinimumAbsoluteValue2(int& i, int& j) const
369  { return minimum_absolute_value2(i,j); }
370  virtual Real maximum() const;
371  Real Maximum() const { return maximum(); }
372  virtual Real maximum1(int& i) const;
373  Real Maximum1(int& i) const { return maximum1(i); }
374  virtual Real maximum2(int& i, int& j) const;
375  Real Maximum2(int& i, int& j) const { return maximum2(i,j); }
376  virtual Real minimum() const;
377  Real Minimum() const { return minimum(); }
378  virtual Real minimum1(int& i) const;
379  Real Minimum1(int& i) const { return minimum1(i); }
380  virtual Real minimum2(int& i, int& j) const;
381  Real Minimum2(int& i, int& j) const { return minimum2(i,j); }
382  virtual Real trace() const;
383  Real Trace() const { return trace(); }
384  Real norm1() const;
385  Real Norm1() const { return norm1(); }
386  Real norm_infinity() const;
387  Real NormInfinity() const { return norm_infinity(); }
388  virtual MatrixBandWidth bandwidth() const; // bandwidths of band matrix
389  virtual MatrixBandWidth BandWidth() const { return bandwidth(); }
390  void IEQND() const; // called by ineq. ops
391  ReturnMatrix sum_square_columns() const;
392  ReturnMatrix sum_square_rows() const;
393  ReturnMatrix sum_columns() const;
394  ReturnMatrix sum_rows() const;
395  virtual void cleanup() {}
396  void CleanUp() { cleanup(); }
397 
398 // virtual ReturnMatrix Reverse() const; // reverse order of elements
399 //protected:
400 // BaseMatrix() : t(this), i(this) {}
401 
402  friend class GeneralMatrix;
403  friend class Matrix;
404  friend class SquareMatrix;
405  friend class nricMatrix;
406  friend class RowVector;
407  friend class ColumnVector;
408  friend class SymmetricMatrix;
409  friend class UpperTriangularMatrix;
410  friend class LowerTriangularMatrix;
411  friend class DiagonalMatrix;
412  friend class CroutMatrix;
413  friend class BandMatrix;
414  friend class LowerBandMatrix;
415  friend class UpperBandMatrix;
416  friend class SymmetricBandMatrix;
417  friend class AddedMatrix;
418  friend class MultipliedMatrix;
419  friend class SubtractedMatrix;
420  friend class SPMatrix;
421  friend class KPMatrix;
422  friend class ConcatenatedMatrix;
423  friend class StackedMatrix;
424  friend class SolvedMatrix;
425  friend class ShiftedMatrix;
426  friend class NegShiftedMatrix;
427  friend class ScaledMatrix;
428  friend class TransposedMatrix;
429  friend class ReversedMatrix;
430  friend class NegatedMatrix;
431  friend class InvertedMatrix;
432  friend class RowedMatrix;
433  friend class ColedMatrix;
434  friend class DiagedMatrix;
435  friend class MatedMatrix;
436  friend class GetSubMatrix;
437  friend class ReturnMatrix;
438  friend class LinearEquationSolver;
439  friend class GenericMatrix;
441 };
442 
443 
444 // ***************************** working classes **************************/
445 
447 class GeneralMatrix : public BaseMatrix // declarable matrix types
448 {
449  virtual GeneralMatrix* Image() const; // copy of matrix
450 protected:
451  int tag_val; // shows whether can reuse
452  int nrows_val, ncols_val; // dimensions
453  int storage; // total store required
454  Real* store; // point to store (0=not set)
455  GeneralMatrix(); // initialise with no store
456  GeneralMatrix(ArrayLengthSpecifier); // constructor getting store
457  void Add(GeneralMatrix*, Real); // sum of GM and Real
458  void Add(Real); // add Real to this
459  void NegAdd(GeneralMatrix*, Real); // Real - GM
460  void NegAdd(Real); // this = this - Real
461  void Multiply(GeneralMatrix*, Real); // product of GM and Real
462  void Multiply(Real); // multiply this by Real
463  void Negate(GeneralMatrix*); // change sign
464  void Negate(); // change sign
465  void ReverseElements(); // internal reverse of elements
466  void ReverseElements(GeneralMatrix*); // reverse order of elements
467  void operator=(Real); // set matrix to constant
468  Real* GetStore(); // get store or copy
469  GeneralMatrix* BorrowStore(GeneralMatrix*, MatrixType);
470  // temporarily access store
471  void GetMatrix(const GeneralMatrix*); // used by = and initialise
472  void Eq(const BaseMatrix&, MatrixType); // used by =
473  void Eq(const GeneralMatrix&); // version with no conversion
474  void Eq(const BaseMatrix&, MatrixType, bool);// used by <<
475  void Eq2(const BaseMatrix&, MatrixType); // cut down version of Eq
476  int search(const BaseMatrix*) const;
477  virtual GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
478  void CheckConversion(const BaseMatrix&); // check conversion OK
479  void resize(int, int, int); // change dimensions
480  virtual short SimpleAddOK(const GeneralMatrix*) { return 0; }
481  // see bandmat.cpp for explanation
482  virtual void MiniCleanUp()
483  { store = 0; storage = 0; nrows_val = 0; ncols_val = 0; tag_val = -1;}
484  // CleanUp when the data array has already been deleted
485  void PlusEqual(const GeneralMatrix& gm);
486  void MinusEqual(const GeneralMatrix& gm);
487  void PlusEqual(Real f);
488  void MinusEqual(Real f);
489  void swap(GeneralMatrix& gm); // swap values
490 public:
492  virtual MatrixType type() const = 0; // type of a matrix
493  MatrixType Type() const { return type(); }
494  int Nrows() const { return nrows_val; } // get dimensions
495  int Ncols() const { return ncols_val; }
496  int Storage() const { return storage; }
497  Real* Store() const { return store; }
498  // updated names
499  int nrows() const { return nrows_val; } // get dimensions
500  int ncols() const { return ncols_val; }
501  int size() const { return storage; }
502  Real* data() { return store; }
503  const Real* data() const { return store; }
504  const Real* const_data() const { return store; }
505  virtual ~GeneralMatrix(); // delete store if set
506  void tDelete(); // delete if tag_val permits
507  bool reuse(); // true if tag_val allows reuse
508  void protect() { tag_val=-1; } // cannot delete or reuse
509  void Protect() { tag_val=-1; } // cannot delete or reuse
510  int tag() const { return tag_val; }
511  int Tag() const { return tag_val; }
512  bool is_zero() const; // test matrix has all zeros
513  bool IsZero() const { return is_zero(); } // test matrix has all zeros
514  void Release() { tag_val=1; } // del store after next use
515  void Release(int t) { tag_val=t; } // del store after t accesses
516  void ReleaseAndDelete() { tag_val=0; } // delete matrix after use
517  void release() { tag_val=1; } // del store after next use
518  void release(int t) { tag_val=t; } // del store after t accesses
519  void release_and_delete() { tag_val=0; } // delete matrix after use
520  void operator<<(const double*); // assignment from an array
521  void operator<<(const float*); // assignment from an array
522  void operator<<(const int*); // assignment from an array
523  void operator<<(const BaseMatrix& X)
524  { Eq(X,this->type(),true); } // = without checking type
525  void inject(const GeneralMatrix&); // copy stored els only
526  void Inject(const GeneralMatrix& GM) { inject(GM); }
527  void operator+=(const BaseMatrix&);
528  void operator-=(const BaseMatrix&);
529  void operator*=(const BaseMatrix&);
530  void operator|=(const BaseMatrix&);
531  void operator&=(const BaseMatrix&);
532  void operator+=(Real);
533  void operator-=(Real r) { operator+=(-r); }
534  void operator*=(Real);
535  void operator/=(Real r) { operator*=(1.0/r); }
536  virtual GeneralMatrix* MakeSolver(); // for solving
537  virtual void Solver(MatrixColX&, const MatrixColX&) {}
538  virtual void GetRow(MatrixRowCol&) = 0; // Get matrix row
539  virtual void RestoreRow(MatrixRowCol&) {} // Restore matrix row
540  virtual void NextRow(MatrixRowCol&); // Go to next row
541  virtual void GetCol(MatrixRowCol&) = 0; // Get matrix col
542  virtual void GetCol(MatrixColX&) = 0; // Get matrix col
543  virtual void RestoreCol(MatrixRowCol&) {} // Restore matrix col
544  virtual void RestoreCol(MatrixColX&) {} // Restore matrix col
545  virtual void NextCol(MatrixRowCol&); // Go to next col
546  virtual void NextCol(MatrixColX&); // Go to next col
547  Real sum_square() const;
548  Real sum_absolute_value() const;
549  Real sum() const;
550  Real maximum_absolute_value1(int& i) const;
551  Real minimum_absolute_value1(int& i) const;
552  Real maximum1(int& i) const;
553  Real minimum1(int& i) const;
555  Real maximum_absolute_value2(int& i, int& j) const;
557  Real minimum_absolute_value2(int& i, int& j) const;
558  Real maximum() const;
559  Real maximum2(int& i, int& j) const;
560  Real minimum() const;
561  Real minimum2(int& i, int& j) const;
562  LogAndSign log_determinant() const;
563  virtual bool IsEqual(const GeneralMatrix&) const;
564  // same type, same values
565  void CheckStore() const; // check store is non-zero
566  virtual void SetParameters(const GeneralMatrix*) {}
567  // set parameters in GetMatrix
568  operator ReturnMatrix() const; // for building a ReturnMatrix
569  ReturnMatrix for_return() const;
570  ReturnMatrix ForReturn() const;
571  //virtual bool SameStorageType(const GeneralMatrix& A) const;
572  //virtual void ReSizeForAdd(const GeneralMatrix& A, const GeneralMatrix& B);
573  //virtual void ReSizeForSP(const GeneralMatrix& A, const GeneralMatrix& B);
574  virtual void resize(const GeneralMatrix& A);
575  virtual void ReSize(const GeneralMatrix& A) { resize(A); }
576  MatrixInput operator<<(double); // for loading a list
577  MatrixInput operator<<(float); // for loading a list
578  MatrixInput operator<<(int f);
579 // ReturnMatrix Reverse() const; // reverse order of elements
580  void cleanup(); // to clear store
581 
582  friend class Matrix;
583  friend class SquareMatrix;
584  friend class nricMatrix;
585  friend class SymmetricMatrix;
586  friend class UpperTriangularMatrix;
587  friend class LowerTriangularMatrix;
588  friend class DiagonalMatrix;
589  friend class CroutMatrix;
590  friend class RowVector;
591  friend class ColumnVector;
592  friend class BandMatrix;
593  friend class LowerBandMatrix;
594  friend class UpperBandMatrix;
595  friend class SymmetricBandMatrix;
596  friend class BaseMatrix;
597  friend class AddedMatrix;
598  friend class MultipliedMatrix;
599  friend class SubtractedMatrix;
600  friend class SPMatrix;
601  friend class KPMatrix;
602  friend class ConcatenatedMatrix;
603  friend class StackedMatrix;
604  friend class SolvedMatrix;
605  friend class ShiftedMatrix;
606  friend class NegShiftedMatrix;
607  friend class ScaledMatrix;
608  friend class TransposedMatrix;
609  friend class ReversedMatrix;
610  friend class NegatedMatrix;
611  friend class InvertedMatrix;
612  friend class RowedMatrix;
613  friend class ColedMatrix;
614  friend class DiagedMatrix;
615  friend class MatedMatrix;
616  friend class GetSubMatrix;
617  friend class ReturnMatrix;
618  friend class LinearEquationSolver;
619  friend class GenericMatrix;
621 };
622 
623 
625 class Matrix : public GeneralMatrix
626 {
627  GeneralMatrix* Image() const; // copy of matrix
628 public:
629  Matrix() {}
630  ~Matrix() {}
631  Matrix(int, int); // standard declaration
632  Matrix(const BaseMatrix&); // evaluate BaseMatrix
633  void operator=(const BaseMatrix&);
635  void operator=(const Matrix& m) { Eq(m); }
636  MatrixType type() const;
637  Real& operator()(int, int); // access element
638  Real& element(int, int); // access element
639  Real operator()(int, int) const; // access element
640  Real element(int, int) const; // access element
641 #ifdef SETUP_C_SUBSCRIPTS
642  Real* operator[](int m) { return store+m*ncols_val; }
643  const Real* operator[](int m) const { return store+m*ncols_val; }
644  // following for Numerical Recipes in C++
645  Matrix(Real, int, int);
646  Matrix(const Real*, int, int);
647 #endif
648  Matrix(const Matrix& gm) : GeneralMatrix() { GetMatrix(&gm); }
649  GeneralMatrix* MakeSolver();
650  Real trace() const;
651  void GetRow(MatrixRowCol&);
652  void GetCol(MatrixRowCol&);
653  void GetCol(MatrixColX&);
654  void RestoreCol(MatrixRowCol&);
655  void RestoreCol(MatrixColX&);
656  void NextRow(MatrixRowCol&);
657  void NextCol(MatrixRowCol&);
658  void NextCol(MatrixColX&);
659  virtual void resize(int,int); // change dimensions
660  // virtual so we will catch it being used in a vector called as a matrix
661  virtual void resize_keep(int,int);
662  virtual void ReSize(int m, int n) { resize(m, n); }
663  void resize(const GeneralMatrix& A);
664  void ReSize(const GeneralMatrix& A) { resize(A); }
665  Real maximum_absolute_value2(int& i, int& j) const;
666  Real minimum_absolute_value2(int& i, int& j) const;
667  Real maximum2(int& i, int& j) const;
668  Real minimum2(int& i, int& j) const;
669  void operator+=(const Matrix& M) { PlusEqual(M); }
670  void operator-=(const Matrix& M) { MinusEqual(M); }
674  friend Real dotproduct(const Matrix& A, const Matrix& B);
676 };
677 
679 class SquareMatrix : public Matrix
680 {
681  GeneralMatrix* Image() const; // copy of matrix
682 public:
685  SquareMatrix(ArrayLengthSpecifier); // standard declaration
686  SquareMatrix(const BaseMatrix&); // evaluate BaseMatrix
687  void operator=(const BaseMatrix&);
689  void operator=(const SquareMatrix& m) { Eq(m); }
690  void operator=(const Matrix& m);
691  MatrixType type() const;
692  SquareMatrix(const SquareMatrix& gm) : Matrix() { GetMatrix(&gm); }
693  SquareMatrix(const Matrix& gm);
694  void resize(int); // change dimensions
695  void ReSize(int m) { resize(m); }
696  void resize_keep(int);
697  void resize_keep(int,int);
698  void resize(int,int); // change dimensions
699  void ReSize(int m, int n) { resize(m, n); }
700  void resize(const GeneralMatrix& A);
701  void ReSize(const GeneralMatrix& A) { resize(A); }
702  void operator+=(const Matrix& M) { PlusEqual(M); }
703  void operator-=(const Matrix& M) { MinusEqual(M); }
708 };
709 
711 class nricMatrix : public Matrix
712 {
713  GeneralMatrix* Image() const; // copy of matrix
714  Real** row_pointer; // points to rows
715  void MakeRowPointer(); // build rowpointer
716  void DeleteRowPointer();
717 public:
719  nricMatrix(int m, int n) // standard declaration
720  : Matrix(m,n) { MakeRowPointer(); }
721  nricMatrix(const BaseMatrix& bm) // evaluate BaseMatrix
722  : Matrix(bm) { MakeRowPointer(); }
723  void operator=(const BaseMatrix& bm)
724  { DeleteRowPointer(); Matrix::operator=(bm); MakeRowPointer(); }
726  void operator=(const nricMatrix& m)
727  { DeleteRowPointer(); Eq(m); MakeRowPointer(); }
728  void operator<<(const BaseMatrix& X)
729  { DeleteRowPointer(); Eq(X,this->type(),true); MakeRowPointer(); }
730  nricMatrix(const nricMatrix& gm) : Matrix()
731  { GetMatrix(&gm); MakeRowPointer(); }
732  void resize(int m, int n) // change dimensions
733  { DeleteRowPointer(); Matrix::resize(m,n); MakeRowPointer(); }
734  void resize_keep(int m, int n) // change dimensions
735  { DeleteRowPointer(); Matrix::resize_keep(m,n); MakeRowPointer(); }
736  void ReSize(int m, int n) // change dimensions
737  { DeleteRowPointer(); Matrix::resize(m,n); MakeRowPointer(); }
738  void resize(const GeneralMatrix& A);
739  void ReSize(const GeneralMatrix& A) { resize(A); }
740  ~nricMatrix() { DeleteRowPointer(); }
741  Real** nric() const { CheckStore(); return row_pointer-1; }
742  void cleanup(); // to clear store
743  void MiniCleanUp();
744  void operator+=(const Matrix& M) { PlusEqual(M); }
745  void operator-=(const Matrix& M) { MinusEqual(M); }
748  void swap(nricMatrix& gm);
750 };
751 
754 {
755  GeneralMatrix* Image() const; // copy of matrix
756 public:
760  SymmetricMatrix(const BaseMatrix&);
761  void operator=(const BaseMatrix&);
763  void operator=(const SymmetricMatrix& m) { Eq(m); }
764  Real& operator()(int, int); // access element
765  Real& element(int, int); // access element
766  Real operator()(int, int) const; // access element
767  Real element(int, int) const; // access element
768 #ifdef SETUP_C_SUBSCRIPTS
769  Real* operator[](int m) { return store+(m*(m+1))/2; }
770  const Real* operator[](int m) const { return store+(m*(m+1))/2; }
771 #endif
772  MatrixType type() const;
774  : GeneralMatrix() { GetMatrix(&gm); }
775  Real sum_square() const;
776  Real sum_absolute_value() const;
777  Real sum() const;
778  Real trace() const;
779  void GetRow(MatrixRowCol&);
780  void GetCol(MatrixRowCol&);
781  void GetCol(MatrixColX&);
783  void RestoreCol(MatrixColX&);
785  void resize(int); // change dimensions
786  void ReSize(int m) { resize(m); }
787  void resize_keep(int);
788  void resize(const GeneralMatrix& A);
789  void ReSize(const GeneralMatrix& A) { resize(A); }
790  void operator+=(const SymmetricMatrix& M) { PlusEqual(M); }
791  void operator-=(const SymmetricMatrix& M) { MinusEqual(M); }
796 };
797 
800 {
801  GeneralMatrix* Image() const; // copy of matrix
802 public:
806  void operator=(const BaseMatrix&);
807  void operator=(const UpperTriangularMatrix& m) { Eq(m); }
810  : GeneralMatrix() { GetMatrix(&gm); }
812  Real& operator()(int, int); // access element
813  Real& element(int, int); // access element
814  Real operator()(int, int) const; // access element
815  Real element(int, int) const; // access element
816 #ifdef SETUP_C_SUBSCRIPTS
817  Real* operator[](int m) { return store+m*ncols_val-(m*(m+1))/2; }
818  const Real* operator[](int m) const
819  { return store+m*ncols_val-(m*(m+1))/2; }
820 #endif
821  MatrixType type() const;
822  GeneralMatrix* MakeSolver() { return this; } // for solving
823  void Solver(MatrixColX&, const MatrixColX&);
824  LogAndSign log_determinant() const;
825  Real trace() const;
826  void GetRow(MatrixRowCol&);
827  void GetCol(MatrixRowCol&);
828  void GetCol(MatrixColX&);
829  void RestoreCol(MatrixRowCol&);
831  void NextRow(MatrixRowCol&);
832  void resize(int); // change dimensions
833  void ReSize(int m) { resize(m); }
834  void resize(const GeneralMatrix& A);
835  void ReSize(const GeneralMatrix& A) { resize(A); }
836  void resize_keep(int);
837  MatrixBandWidth bandwidth() const;
838  void operator+=(const UpperTriangularMatrix& M) { PlusEqual(M); }
839  void operator-=(const UpperTriangularMatrix& M) { MinusEqual(M); }
845 };
846 
849 {
850  GeneralMatrix* Image() const; // copy of matrix
851 public:
856  : GeneralMatrix() { GetMatrix(&gm); }
858  void operator=(const BaseMatrix&);
860  void operator=(const LowerTriangularMatrix& m) { Eq(m); }
861  Real& operator()(int, int); // access element
862  Real& element(int, int); // access element
863  Real operator()(int, int) const; // access element
864  Real element(int, int) const; // access element
865 #ifdef SETUP_C_SUBSCRIPTS
866  Real* operator[](int m) { return store+(m*(m+1))/2; }
867  const Real* operator[](int m) const { return store+(m*(m+1))/2; }
868 #endif
869  MatrixType type() const;
870  GeneralMatrix* MakeSolver() { return this; } // for solving
871  void Solver(MatrixColX&, const MatrixColX&);
872  LogAndSign log_determinant() const;
873  Real trace() const;
874  void GetRow(MatrixRowCol&);
875  void GetCol(MatrixRowCol&);
876  void GetCol(MatrixColX&);
877  void RestoreCol(MatrixRowCol&);
879  void NextRow(MatrixRowCol&);
880  void resize(int); // change dimensions
881  void ReSize(int m) { resize(m); }
882  void resize_keep(int);
883  void resize(const GeneralMatrix& A);
884  void ReSize(const GeneralMatrix& A) { resize(A); }
885  MatrixBandWidth bandwidth() const;
886  void operator+=(const LowerTriangularMatrix& M) { PlusEqual(M); }
887  void operator-=(const LowerTriangularMatrix& M) { MinusEqual(M); }
893 };
894 
897 {
898  GeneralMatrix* Image() const; // copy of matrix
899 public:
903  DiagonalMatrix(const BaseMatrix&);
905  : GeneralMatrix() { GetMatrix(&gm); }
906  void operator=(const BaseMatrix&);
908  void operator=(const DiagonalMatrix& m) { Eq(m); }
909  Real& operator()(int, int); // access element
910  Real& operator()(int); // access element
911  Real operator()(int, int) const; // access element
912  Real operator()(int) const;
913  Real& element(int, int); // access element
914  Real& element(int); // access element
915  Real element(int, int) const; // access element
916  Real element(int) const; // access element
917 #ifdef SETUP_C_SUBSCRIPTS
918  Real& operator[](int m) { return store[m]; }
919  const Real& operator[](int m) const { return store[m]; }
920 #endif
921  MatrixType type() const;
922 
923  LogAndSign log_determinant() const;
924  Real trace() const;
925  void GetRow(MatrixRowCol&);
926  void GetCol(MatrixRowCol&);
927  void GetCol(MatrixColX&);
928  void NextRow(MatrixRowCol&);
929  void NextCol(MatrixRowCol&);
930  void NextCol(MatrixColX&);
931  GeneralMatrix* MakeSolver() { return this; } // for solving
932  void Solver(MatrixColX&, const MatrixColX&);
934  void resize(int); // change dimensions
935  void ReSize(int m) { resize(m); }
936  void resize_keep(int);
937  void resize(const GeneralMatrix& A);
938  void ReSize(const GeneralMatrix& A) { resize(A); }
939  Real* nric() const
940  { CheckStore(); return store-1; } // for use by NRIC
941  MatrixBandWidth bandwidth() const;
942 // ReturnMatrix Reverse() const; // reverse order of elements
943  void operator+=(const DiagonalMatrix& M) { PlusEqual(M); }
944  void operator-=(const DiagonalMatrix& M) { MinusEqual(M); }
950 };
951 
953 class RowVector : public Matrix
954 {
955  GeneralMatrix* Image() const; // copy of matrix
956 public:
957  RowVector() { nrows_val = 1; }
959  RowVector(ArrayLengthSpecifier n) : Matrix(1,n.Value()) {}
960  RowVector(const BaseMatrix&);
961  RowVector(const RowVector& gm) : Matrix() { GetMatrix(&gm); }
962  void operator=(const BaseMatrix&);
964  void operator=(const RowVector& m) { Eq(m); }
965  Real& operator()(int); // access element
966  Real& element(int); // access element
967  Real operator()(int) const; // access element
968  Real element(int) const; // access element
969 #ifdef SETUP_C_SUBSCRIPTS
970  Real& operator[](int m) { return store[m]; }
971  const Real& operator[](int m) const { return store[m]; }
972  // following for Numerical Recipes in C++
973  RowVector(Real a, int n) : Matrix(a, 1, n) {}
974  RowVector(const Real* a, int n) : Matrix(a, 1, n) {}
975 #endif
976  MatrixType type() const;
977  void GetCol(MatrixRowCol&);
978  void GetCol(MatrixColX&);
979  void NextCol(MatrixRowCol&);
980  void NextCol(MatrixColX&);
982  void RestoreCol(MatrixColX& c);
984  void resize(int); // change dimensions
985  void ReSize(int m) { resize(m); }
986  void resize_keep(int);
987  void resize_keep(int,int);
988  void resize(int,int); // in case access is matrix
989  void ReSize(int m,int n) { resize(m, n); }
990  void resize(const GeneralMatrix& A);
991  void ReSize(const GeneralMatrix& A) { resize(A); }
992  Real* nric() const
993  { CheckStore(); return store-1; } // for use by NRIC
994  void cleanup(); // to clear store
995  void MiniCleanUp()
996  { store = 0; storage = 0; nrows_val = 1; ncols_val = 0; tag_val = -1; }
997  // friend ReturnMatrix GetMatrixRow(Matrix& A, int row);
998  void operator+=(const Matrix& M) { PlusEqual(M); }
999  void operator-=(const Matrix& M) { MinusEqual(M); }
1002  void swap(RowVector& gm)
1005 };
1006 
1008 class ColumnVector : public Matrix
1009 {
1010  GeneralMatrix* Image() const; // copy of matrix
1011 public:
1012  ColumnVector() { ncols_val = 1; }
1015  ColumnVector(const BaseMatrix&);
1016  ColumnVector(const ColumnVector& gm) : Matrix() { GetMatrix(&gm); }
1017  void operator=(const BaseMatrix&);
1019  void operator=(const ColumnVector& m) { Eq(m); }
1020  Real& operator()(int); // access element
1021  Real& element(int); // access element
1022  Real operator()(int) const; // access element
1023  Real element(int) const; // access element
1024 #ifdef SETUP_C_SUBSCRIPTS
1025  Real& operator[](int m) { return store[m]; }
1026  const Real& operator[](int m) const { return store[m]; }
1027  // following for Numerical Recipes in C++
1028  ColumnVector(Real a, int m) : Matrix(a, m, 1) {}
1029  ColumnVector(const Real* a, int m) : Matrix(a, m, 1) {}
1030 #endif
1031  MatrixType type() const;
1033  void resize(int); // change dimensions
1034  void ReSize(int m) { resize(m); }
1035  void resize_keep(int);
1036  void resize_keep(int,int);
1037  void resize(int,int); // in case access is matrix
1038  void ReSize(int m,int n) { resize(m, n); }
1039  void resize(const GeneralMatrix& A);
1040  void ReSize(const GeneralMatrix& A) { resize(A); }
1041  Real* nric() const
1042  { CheckStore(); return store-1; } // for use by NRIC
1043  void cleanup(); // to clear store
1045  { store = 0; storage = 0; nrows_val = 0; ncols_val = 1; tag_val = -1; }
1046 // ReturnMatrix Reverse() const; // reverse order of elements
1047  void operator+=(const Matrix& M) { PlusEqual(M); }
1048  void operator-=(const Matrix& M) { MinusEqual(M); }
1051  void swap(ColumnVector& gm)
1054 };
1055 
1060 {
1061  int* indx;
1062  bool d; // number of row swaps = even or odd
1063  bool sing;
1064  void ludcmp();
1065  void get_aux(CroutMatrix&); // for copying indx[] etc
1066  GeneralMatrix* Image() const; // copy of matrix
1067 public:
1068  CroutMatrix(const BaseMatrix&);
1069  CroutMatrix() : indx(0), d(true), sing(true) {}
1070  CroutMatrix(const CroutMatrix&);
1071  void operator=(const CroutMatrix&);
1072  GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
1073  MatrixType type() const;
1074  void lubksb(Real*, int=0);
1075  ~CroutMatrix();
1076  GeneralMatrix* MakeSolver() { return this; } // for solving
1077  LogAndSign log_determinant() const;
1078  void Solver(MatrixColX&, const MatrixColX&);
1079  void GetRow(MatrixRowCol&);
1080  void GetCol(MatrixRowCol&);
1082  void cleanup(); // to clear store
1083  void MiniCleanUp();
1084  bool IsEqual(const GeneralMatrix&) const;
1085  bool is_singular() const { return sing; }
1086  bool IsSingular() const { return sing; }
1087  const int* const_data_indx() const { return indx; }
1088  bool even_exchanges() const { return d; }
1089  void swap(CroutMatrix& gm);
1091 };
1092 
1093 // ***************************** band matrices ***************************/
1094 
1097 {
1098  GeneralMatrix* Image() const; // copy of matrix
1099 protected:
1100  void CornerClear() const; // set unused elements to zero
1101  short SimpleAddOK(const GeneralMatrix* gm);
1102 public:
1103  int lower_val, upper_val; // band widths
1104  BandMatrix() { lower_val=0; upper_val=0; CornerClear(); }
1106  BandMatrix(int n,int lb,int ub) { resize(n,lb,ub); CornerClear(); }
1107  // standard declaration
1108  BandMatrix(const BaseMatrix&); // evaluate BaseMatrix
1109  void operator=(const BaseMatrix&);
1111  void operator=(const BandMatrix& m) { Eq(m); }
1112  MatrixType type() const;
1113  Real& operator()(int, int); // access element
1114  Real& element(int, int); // access element
1115  Real operator()(int, int) const; // access element
1116  Real element(int, int) const; // access element
1117 #ifdef SETUP_C_SUBSCRIPTS
1118  Real* operator[](int m) { return store+(upper_val+lower_val)*m+lower_val; }
1119  const Real* operator[](int m) const
1120  { return store+(upper_val+lower_val)*m+lower_val; }
1121 #endif
1122  BandMatrix(const BandMatrix& gm) : GeneralMatrix() { GetMatrix(&gm); }
1123  LogAndSign log_determinant() const;
1124  GeneralMatrix* MakeSolver();
1125  Real trace() const;
1127  { CornerClear(); return GeneralMatrix::sum_square(); }
1129  { CornerClear(); return GeneralMatrix::sum_absolute_value(); }
1130  Real sum() const
1131  { CornerClear(); return GeneralMatrix::sum(); }
1133  { CornerClear(); return GeneralMatrix::maximum_absolute_value(); }
1135  { int i, j; return GeneralMatrix::minimum_absolute_value2(i, j); }
1136  Real maximum() const { int i, j; return GeneralMatrix::maximum2(i, j); }
1137  Real minimum() const { int i, j; return GeneralMatrix::minimum2(i, j); }
1138  void GetRow(MatrixRowCol&);
1139  void GetCol(MatrixRowCol&);
1140  void GetCol(MatrixColX&);
1141  void RestoreCol(MatrixRowCol&);
1143  void NextRow(MatrixRowCol&);
1144  virtual void resize(int, int, int); // change dimensions
1145  virtual void ReSize(int m, int n, int b) { resize(m, n, b); }
1146  void resize(const GeneralMatrix& A);
1147  void ReSize(const GeneralMatrix& A) { resize(A); }
1148  //bool SameStorageType(const GeneralMatrix& A) const;
1149  //void ReSizeForAdd(const GeneralMatrix& A, const GeneralMatrix& B);
1150  //void ReSizeForSP(const GeneralMatrix& A, const GeneralMatrix& B);
1151  MatrixBandWidth bandwidth() const;
1152  void SetParameters(const GeneralMatrix*);
1153  MatrixInput operator<<(double); // will give error
1154  MatrixInput operator<<(float); // will give error
1155  MatrixInput operator<<(int f);
1156  void operator<<(const double* r); // will give error
1157  void operator<<(const float* r); // will give error
1158  void operator<<(const int* r); // will give error
1159  // the next is included because Zortech and Borland
1160  // cannot find the copy in GeneralMatrix
1162  void swap(BandMatrix& gm);
1164 };
1165 
1168 {
1169  GeneralMatrix* Image() const; // copy of matrix
1170 public:
1173  UpperBandMatrix(int n, int ubw) // standard declaration
1174  : BandMatrix(n, 0, ubw) {}
1175  UpperBandMatrix(const BaseMatrix&); // evaluate BaseMatrix
1176  void operator=(const BaseMatrix&);
1178  void operator=(const UpperBandMatrix& m) { Eq(m); }
1179  MatrixType type() const;
1180  UpperBandMatrix(const UpperBandMatrix& gm) : BandMatrix() { GetMatrix(&gm); }
1181  GeneralMatrix* MakeSolver() { return this; }
1182  void Solver(MatrixColX&, const MatrixColX&);
1183  LogAndSign log_determinant() const;
1184  void resize(int, int, int); // change dimensions
1185  void ReSize(int m, int n, int b) { resize(m, n, b); }
1186  void resize(int n,int ubw) // change dimensions
1187  { BandMatrix::resize(n,0,ubw); }
1188  void ReSize(int n,int ubw) // change dimensions
1189  { BandMatrix::resize(n,0,ubw); }
1190  void resize(const GeneralMatrix& A) { BandMatrix::resize(A); }
1191  void ReSize(const GeneralMatrix& A) { BandMatrix::resize(A); }
1192  Real& operator()(int, int);
1193  Real operator()(int, int) const;
1194  Real& element(int, int);
1195  Real element(int, int) const;
1196 #ifdef SETUP_C_SUBSCRIPTS
1197  Real* operator[](int m) { return store+upper_val*m; }
1198  const Real* operator[](int m) const { return store+upper_val*m; }
1199 #endif
1201  { BandMatrix::swap((BandMatrix&)gm); }
1203 };
1204 
1207 {
1208  GeneralMatrix* Image() const; // copy of matrix
1209 public:
1212  LowerBandMatrix(int n, int lbw) // standard declaration
1213  : BandMatrix(n, lbw, 0) {}
1214  LowerBandMatrix(const BaseMatrix&); // evaluate BaseMatrix
1215  void operator=(const BaseMatrix&);
1217  void operator=(const LowerBandMatrix& m) { Eq(m); }
1218  MatrixType type() const;
1219  LowerBandMatrix(const LowerBandMatrix& gm) : BandMatrix() { GetMatrix(&gm); }
1220  GeneralMatrix* MakeSolver() { return this; }
1221  void Solver(MatrixColX&, const MatrixColX&);
1222  LogAndSign log_determinant() const;
1223  void resize(int, int, int); // change dimensions
1224  void ReSize(int m, int n, int b) { resize(m, n, b); }
1225  void resize(int n,int lbw) // change dimensions
1226  { BandMatrix::resize(n,lbw,0); }
1227  void ReSize(int n,int lbw) // change dimensions
1228  { BandMatrix::resize(n,lbw,0); }
1229  void resize(const GeneralMatrix& A) { BandMatrix::resize(A); }
1230  void ReSize(const GeneralMatrix& A) { BandMatrix::resize(A); }
1231  Real& operator()(int, int);
1232  Real operator()(int, int) const;
1233  Real& element(int, int);
1234  Real element(int, int) const;
1235 #ifdef SETUP_C_SUBSCRIPTS
1236  Real* operator[](int m) { return store+lower_val*(m+1); }
1237  const Real* operator[](int m) const { return store+lower_val*(m+1); }
1238 #endif
1240  { BandMatrix::swap((BandMatrix&)gm); }
1242 };
1243 
1246 {
1247  GeneralMatrix* Image() const; // copy of matrix
1248  void CornerClear() const; // set unused elements to zero
1249  short SimpleAddOK(const GeneralMatrix* gm);
1250 public:
1251  int lower_val; // lower band width
1252  SymmetricBandMatrix() { lower_val=0; CornerClear(); }
1254  SymmetricBandMatrix(int n, int lb) { resize(n,lb); CornerClear(); }
1256  void operator=(const BaseMatrix&);
1258  void operator=(const SymmetricBandMatrix& m) { Eq(m); }
1259  Real& operator()(int, int); // access element
1260  Real& element(int, int); // access element
1261  Real operator()(int, int) const; // access element
1262  Real element(int, int) const; // access element
1263 #ifdef SETUP_C_SUBSCRIPTS
1264  Real* operator[](int m) { return store+lower_val*(m+1); }
1265  const Real* operator[](int m) const { return store+lower_val*(m+1); }
1266 #endif
1267  MatrixType type() const;
1269  : GeneralMatrix() { GetMatrix(&gm); }
1270  GeneralMatrix* MakeSolver();
1271  Real sum_square() const;
1272  Real sum_absolute_value() const;
1273  Real sum() const;
1275  { CornerClear(); return GeneralMatrix::maximum_absolute_value(); }
1277  { int i, j; return GeneralMatrix::minimum_absolute_value2(i, j); }
1278  Real maximum() const { int i, j; return GeneralMatrix::maximum2(i, j); }
1279  Real minimum() const { int i, j; return GeneralMatrix::minimum2(i, j); }
1280  Real trace() const;
1281  LogAndSign log_determinant() const;
1282  void GetRow(MatrixRowCol&);
1283  void GetCol(MatrixRowCol&);
1284  void GetCol(MatrixColX&);
1286  void RestoreCol(MatrixColX&);
1288  void resize(int,int); // change dimensions
1289  void ReSize(int m,int b) { resize(m, b); }
1290  void resize(const GeneralMatrix& A);
1291  void ReSize(const GeneralMatrix& A) { resize(A); }
1292  //bool SameStorageType(const GeneralMatrix& A) const;
1293  //void ReSizeForAdd(const GeneralMatrix& A, const GeneralMatrix& B);
1294  //void ReSizeForSP(const GeneralMatrix& A, const GeneralMatrix& B);
1295  MatrixBandWidth bandwidth() const;
1296  void SetParameters(const GeneralMatrix*);
1297  void operator<<(const double* r); // will give error
1298  void operator<<(const float* r); // will give error
1299  void operator<<(const int* r); // will give error
1301  void swap(SymmetricBandMatrix& gm);
1303 };
1304 
1307 {
1308  int* indx;
1309  bool d;
1310  bool sing; // true if singular
1313  int m1,m2; // lower and upper
1314  void ludcmp();
1315  void get_aux(BandLUMatrix&); // for copying indx[] etc
1316  GeneralMatrix* Image() const; // copy of matrix
1317 public:
1318  BandLUMatrix(const BaseMatrix&);
1320  : indx(0), d(true), sing(true), store2(0), storage2(0), m1(0), m2(0) {}
1321  BandLUMatrix(const BandLUMatrix&);
1322  void operator=(const BandLUMatrix&);
1323  GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
1324  MatrixType type() const;
1325  void lubksb(Real*, int=0);
1326  ~BandLUMatrix();
1327  GeneralMatrix* MakeSolver() { return this; } // for solving
1328  LogAndSign log_determinant() const;
1329  void Solver(MatrixColX&, const MatrixColX&);
1330  void GetRow(MatrixRowCol&);
1331  void GetCol(MatrixRowCol&);
1333  void cleanup(); // to clear store
1334  void MiniCleanUp();
1335  bool IsEqual(const GeneralMatrix&) const;
1336  bool is_singular() const { return sing; }
1337  bool IsSingular() const { return sing; }
1338  const Real* const_data2() const { return store2; }
1339  int size2() const { return storage2; }
1340  const int* const_data_indx() const { return indx; }
1341  bool even_exchanges() const { return d; }
1342  MatrixBandWidth bandwidth() const;
1343  void swap(BandLUMatrix& gm);
1345 };
1346 
1347 // ************************** special matrices ****************************
1348 
1351 {
1352  GeneralMatrix* Image() const; // copy of matrix
1353 public:
1357  { nrows_val = ncols_val = n.Value(); *store = 1; }
1359  : GeneralMatrix() { GetMatrix(&gm); }
1360  IdentityMatrix(const BaseMatrix&);
1361  void operator=(const BaseMatrix&);
1362  void operator=(const IdentityMatrix& m) { Eq(m); }
1364  MatrixType type() const;
1365 
1366  LogAndSign log_determinant() const;
1367  Real trace() const;
1368  Real sum_square() const;
1369  Real sum_absolute_value() const;
1370  Real sum() const { return trace(); }
1371  void GetRow(MatrixRowCol&);
1372  void GetCol(MatrixRowCol&);
1373  void GetCol(MatrixColX&);
1374  void NextRow(MatrixRowCol&);
1375  void NextCol(MatrixRowCol&);
1376  void NextCol(MatrixColX&);
1377  GeneralMatrix* MakeSolver() { return this; } // for solving
1378  void Solver(MatrixColX&, const MatrixColX&);
1380  void resize(int n);
1381  void ReSize(int n) { resize(n); }
1382  void resize(const GeneralMatrix& A);
1383  void ReSize(const GeneralMatrix& A) { resize(A); }
1384  MatrixBandWidth bandwidth() const;
1385 // ReturnMatrix Reverse() const; // reverse order of elements
1389 };
1390 
1391 
1392 
1393 
1394 // ************************** GenericMatrix class ************************/
1395 
1398 {
1400  int search(const BaseMatrix* bm) const;
1401  friend class BaseMatrix;
1402 public:
1403  GenericMatrix() : gm(0) {}
1405  { gm = ((BaseMatrix&)bm).Evaluate(); gm = gm->Image(); }
1407  { gm = bm.gm->Image(); }
1408  void operator=(const GenericMatrix&);
1409  void operator=(const BaseMatrix&);
1410  void operator+=(const BaseMatrix&);
1411  void operator-=(const BaseMatrix&);
1412  void operator*=(const BaseMatrix&);
1413  void operator|=(const BaseMatrix&);
1414  void operator&=(const BaseMatrix&);
1415  void operator+=(Real);
1416  void operator-=(Real r) { operator+=(-r); }
1417  void operator*=(Real);
1418  void operator/=(Real r) { operator*=(1.0/r); }
1419  ~GenericMatrix() { delete gm; }
1420  void cleanup() { delete gm; gm = 0; }
1421  void Release() { gm->Release(); }
1422  void release() { gm->release(); }
1424  MatrixBandWidth bandwidth() const;
1425  void swap(GenericMatrix& x);
1427 };
1428 
1429 // *************************** temporary classes *************************/
1430 
1434 {
1435 protected:
1436  // if these union statements cause problems, simply remove them
1437  // and declare the items individually
1438  union { const BaseMatrix* bm1; GeneralMatrix* gm1; };
1439  // pointers to summands
1440  union { const BaseMatrix* bm2; GeneralMatrix* gm2; };
1441  MultipliedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1442  : bm1(bm1x),bm2(bm2x) {}
1443  int search(const BaseMatrix*) const;
1444  friend class BaseMatrix;
1445  friend class GeneralMatrix;
1446  friend class GenericMatrix;
1447 public:
1450  MatrixBandWidth bandwidth() const;
1452 };
1453 
1457 {
1458 protected:
1459  AddedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1460  : MultipliedMatrix(bm1x,bm2x) {}
1461 
1462  friend class BaseMatrix;
1463  friend class GeneralMatrix;
1464  friend class GenericMatrix;
1465 public:
1468  MatrixBandWidth bandwidth() const;
1470 };
1471 
1474 class SPMatrix : public AddedMatrix
1475 {
1476 protected:
1477  SPMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1478  : AddedMatrix(bm1x,bm2x) {}
1479 
1480  friend class BaseMatrix;
1481  friend class GeneralMatrix;
1482  friend class GenericMatrix;
1483 public:
1486  MatrixBandWidth bandwidth() const;
1487 
1488  friend SPMatrix SP(const BaseMatrix&, const BaseMatrix&);
1489 
1491 };
1492 
1496 {
1497 protected:
1498  KPMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1499  : MultipliedMatrix(bm1x,bm2x) {}
1500 
1501  friend class BaseMatrix;
1502  friend class GeneralMatrix;
1503  friend class GenericMatrix;
1504 public:
1506  MatrixBandWidth bandwidth() const;
1508  friend KPMatrix KP(const BaseMatrix&, const BaseMatrix&);
1510 };
1511 
1515 {
1516 protected:
1517  ConcatenatedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1518  : MultipliedMatrix(bm1x,bm2x) {}
1519 
1520  friend class BaseMatrix;
1521  friend class GeneralMatrix;
1522  friend class GenericMatrix;
1523 public:
1525  MatrixBandWidth bandwidth() const;
1528 };
1529 
1533 {
1534 protected:
1535  StackedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1536  : ConcatenatedMatrix(bm1x,bm2x) {}
1537 
1538  friend class BaseMatrix;
1539  friend class GeneralMatrix;
1540  friend class GenericMatrix;
1541 public:
1545 };
1546 
1550 {
1551  SolvedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1552  : MultipliedMatrix(bm1x,bm2x) {}
1553  friend class BaseMatrix;
1554  friend class InvertedMatrix; // for operator*
1555 public:
1558  MatrixBandWidth bandwidth() const;
1560 };
1561 
1565 {
1566  SubtractedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1567  : AddedMatrix(bm1x,bm2x) {}
1568  friend class BaseMatrix;
1569  friend class GeneralMatrix;
1570  friend class GenericMatrix;
1571 public:
1575 };
1576 
1580 {
1581 protected:
1582  union { const BaseMatrix* bm; GeneralMatrix* gm; };
1584  ShiftedMatrix(const BaseMatrix* bmx, Real fx) : bm(bmx),f(fx) {}
1585  int search(const BaseMatrix*) const;
1586  friend class BaseMatrix;
1587  friend class GeneralMatrix;
1588  friend class GenericMatrix;
1589 public:
1592  friend ShiftedMatrix operator+(Real f, const BaseMatrix& BM);
1594 };
1595 
1599 {
1600 protected:
1601  NegShiftedMatrix(Real fx, const BaseMatrix* bmx) : ShiftedMatrix(bmx,fx) {}
1602  friend class BaseMatrix;
1603  friend class GeneralMatrix;
1604  friend class GenericMatrix;
1605 public:
1608  friend NegShiftedMatrix operator-(Real, const BaseMatrix&);
1610 };
1611 
1615 {
1616  ScaledMatrix(const BaseMatrix* bmx, Real fx) : ShiftedMatrix(bmx,fx) {}
1617  friend class BaseMatrix;
1618  friend class GeneralMatrix;
1619  friend class GenericMatrix;
1620 public:
1623  MatrixBandWidth bandwidth() const;
1624  friend ScaledMatrix operator*(Real f, const BaseMatrix& BM);
1626 };
1627 
1631 {
1632 protected:
1633  union { const BaseMatrix* bm; GeneralMatrix* gm; };
1634  NegatedMatrix(const BaseMatrix* bmx) : bm(bmx) {}
1635  int search(const BaseMatrix*) const;
1636 private:
1637  friend class BaseMatrix;
1638 public:
1641  MatrixBandWidth bandwidth() const;
1643 };
1644 
1648 {
1650  friend class BaseMatrix;
1651 public:
1654  MatrixBandWidth bandwidth() const;
1656 };
1657 
1661 {
1663  friend class BaseMatrix;
1664 public:
1668 };
1669 
1673 {
1675 public:
1677  SolvedMatrix operator*(const BaseMatrix&) const; // inverse(A) * B
1679  friend class BaseMatrix;
1681  MatrixBandWidth bandwidth() const;
1683 };
1684 
1688 {
1689  RowedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
1690  friend class BaseMatrix;
1691 public:
1694  MatrixBandWidth bandwidth() const;
1696 };
1697 
1701 {
1702  ColedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
1703  friend class BaseMatrix;
1704 public:
1707  MatrixBandWidth bandwidth() const;
1709 };
1710 
1714 {
1715  DiagedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
1716  friend class BaseMatrix;
1717 public:
1720  MatrixBandWidth bandwidth() const;
1722 };
1723 
1727 {
1728  int nr, nc;
1729  MatedMatrix(const BaseMatrix* bmx, int nrx, int ncx)
1730  : NegatedMatrix(bmx), nr(nrx), nc(ncx) {}
1731  friend class BaseMatrix;
1732 public:
1735  MatrixBandWidth bandwidth() const;
1737 };
1738 
1741 class ReturnMatrix : public BaseMatrix
1742 {
1744  int search(const BaseMatrix*) const;
1745 public:
1747  GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
1748  friend class BaseMatrix;
1749  ReturnMatrix(const ReturnMatrix& tm) : BaseMatrix(), gm(tm.gm) {}
1750  ReturnMatrix(const GeneralMatrix* gmx) : gm((GeneralMatrix*&)gmx) {}
1751 // ReturnMatrix(GeneralMatrix&);
1752  MatrixBandWidth bandwidth() const;
1754 };
1755 
1756 
1757 // ************************** submatrices ******************************/
1758 
1762 {
1767  bool IsSym;
1768 
1769  GetSubMatrix
1770  (const BaseMatrix* bmx, int rs, int rn, int cs, int cn, bool is)
1771  : NegatedMatrix(bmx),
1772  row_skip(rs), row_number(rn), col_skip(cs), col_number(cn), IsSym(is) {}
1773  void SetUpLHS();
1774  friend class BaseMatrix;
1775 public:
1777  : NegatedMatrix(g.bm), row_skip(g.row_skip), row_number(g.row_number),
1778  col_skip(g.col_skip), col_number(g.col_number), IsSym(g.IsSym) {}
1781  void operator=(const BaseMatrix&);
1782  void operator+=(const BaseMatrix&);
1783  void operator-=(const BaseMatrix&);
1784  void operator=(const GetSubMatrix& m) { operator=((const BaseMatrix&)m); }
1785  void operator<<(const BaseMatrix&);
1786  void operator<<(const double*); // copy from array
1787  void operator<<(const float*); // copy from array
1788  void operator<<(const int*); // copy from array
1789  MatrixInput operator<<(double); // for loading a list
1790  MatrixInput operator<<(float); // for loading a list
1791  MatrixInput operator<<(int f);
1792  void operator=(Real); // copy from constant
1793  void operator+=(Real); // add constant
1794  void operator-=(Real r) { operator+=(-r); } // subtract constant
1795  void operator*=(Real); // multiply by constant
1796  void operator/=(Real r) { operator*=(1.0/r); } // divide by constant
1797  void inject(const GeneralMatrix&); // copy stored els only
1798  void Inject(const GeneralMatrix& GM) { inject(GM); }
1799  MatrixBandWidth bandwidth() const;
1801 };
1802 
1803 // ******************** linear equation solving ****************************/
1804 
1810 {
1812  int search(const BaseMatrix*) const { return 0; }
1813  friend class BaseMatrix;
1814 public:
1815  LinearEquationSolver(const BaseMatrix& bm);
1816  ~LinearEquationSolver() { delete gm; }
1817  void cleanup() { delete gm; }
1819  // probably should have an error message if MatrixType != UnSp
1821 };
1822 
1823 // ************************** matrix input *******************************/
1824 
1828 
1830 {
1831  int n; // number values still to be read
1832  Real* r; // pointer to next location to be read to
1833 public:
1834  MatrixInput(const MatrixInput& mi) : n(mi.n), r(mi.r) {}
1835  MatrixInput(int nx, Real* rx) : n(nx), r(rx) {}
1836  ~MatrixInput();
1837  MatrixInput operator<<(double);
1838  MatrixInput operator<<(float);
1839  MatrixInput operator<<(int f);
1840  friend class GeneralMatrix;
1841 };
1842 
1843 
1844 
1845 // **************** a very simple integer array class ********************/
1846 
1851 
1852 class SimpleIntArray : public Janitor
1853 {
1854 protected:
1855  int* a;
1856  int n;
1857 public:
1858  SimpleIntArray(int xn);
1859  SimpleIntArray() : a(0), n(0) {}
1860  ~SimpleIntArray();
1861  int& operator[](int i);
1862  int operator[](int i) const;
1864  void operator=(int ai);
1865  void operator=(const SimpleIntArray& b);
1867  SimpleIntArray(const SimpleIntArray& b);
1869  int Size() const { return n; }
1871  int size() const { return n; }
1873  int* Data() { return a; }
1874  const int* Data() const { return a; }
1875  int* data() { return a; }
1876  const int* data() const { return a; }
1877  const int* const_data() const { return a; }
1878  void resize(int i, bool keep = false);
1880  void ReSize(int i, bool keep = false) { resize(i, keep); }
1882  void resize_keep(int i) { resize(i, true); }
1884  void cleanup() { resize(0); }
1885  void CleanUp() { resize(0); }
1887 };
1888 
1889 // ********************** C subscript classes ****************************
1890 
1893 {
1894  Real** a;
1895 public:
1896  RealStarStar(Matrix& A);
1897  ~RealStarStar() { delete [] a; }
1898  operator Real**() { return a; }
1899 };
1900 
1903 {
1904  const Real** a;
1905 public:
1906  ConstRealStarStar(const Matrix& A);
1907  ~ConstRealStarStar() { delete [] a; }
1908  operator const Real**() { return a; }
1909 };
1910 
1911 // *************************** exceptions ********************************/
1912 
1915 {
1916 public:
1917  static unsigned long Select;
1918  NPDException(const GeneralMatrix&);
1919 };
1920 
1923 {
1924 public:
1925  static unsigned long Select;
1927  ConvergenceException(const char* c);
1928 };
1929 
1932 {
1933 public:
1934  static unsigned long Select;
1935  SingularException(const GeneralMatrix& A);
1936 };
1937 
1940 {
1941 public:
1942  static unsigned long Select;
1943  OverflowException(const char* c);
1944 };
1945 
1948 {
1949 protected:
1950  ProgramException();
1951 public:
1952  static unsigned long Select;
1953  ProgramException(const char* c);
1954  ProgramException(const char* c, const GeneralMatrix&);
1955  ProgramException(const char* c, const GeneralMatrix&, const GeneralMatrix&);
1956  ProgramException(const char* c, MatrixType, MatrixType);
1957 };
1958 
1961 {
1962 public:
1963  static unsigned long Select;
1964  IndexException(int i, const GeneralMatrix& A);
1965  IndexException(int i, int j, const GeneralMatrix& A);
1966  // next two are for access via element function
1967  IndexException(int i, const GeneralMatrix& A, bool);
1968  IndexException(int i, int j, const GeneralMatrix& A, bool);
1969 };
1970 
1973 {
1974 public:
1975  static unsigned long Select;
1976  VectorException();
1977  VectorException(const GeneralMatrix& A);
1978 };
1979 
1982 {
1983 public:
1984  static unsigned long Select;
1987 };
1988 
1991 {
1992 public:
1993  static unsigned long Select;
1995 };
1996 
1999 {
2000 public:
2001  static unsigned long Select;
2005 };
2006 
2009 {
2010 public:
2011  static unsigned long Select;
2012  NotDefinedException(const char* op, const char* matrix);
2013 };
2014 
2017 {
2018 public:
2019  static unsigned long Select;
2020  CannotBuildException(const char* matrix);
2021 };
2022 
2023 
2026 {
2027 public:
2028  static unsigned long Select; // for identifying exception
2029  InternalException(const char* c);
2030 };
2031 
2032 // ************************ functions ************************************ //
2033 
2034 bool operator==(const GeneralMatrix& A, const GeneralMatrix& B);
2035 bool operator==(const BaseMatrix& A, const BaseMatrix& B);
2036 inline bool operator!=(const GeneralMatrix& A, const GeneralMatrix& B)
2037  { return ! (A==B); }
2038 inline bool operator!=(const BaseMatrix& A, const BaseMatrix& B)
2039  { return ! (A==B); }
2040 
2041  // inequality operators are dummies included for compatibility
2042  // with STL. They throw an exception if actually called.
2043 inline bool operator<=(const BaseMatrix& A, const BaseMatrix&)
2044  { A.IEQND(); return true; }
2045 inline bool operator>=(const BaseMatrix& A, const BaseMatrix&)
2046  { A.IEQND(); return true; }
2047 inline bool operator<(const BaseMatrix& A, const BaseMatrix&)
2048  { A.IEQND(); return true; }
2049 inline bool operator>(const BaseMatrix& A, const BaseMatrix&)
2050  { A.IEQND(); return true; }
2051 
2052 bool is_zero(const BaseMatrix& A);
2053 inline bool IsZero(const BaseMatrix& A) { return is_zero(A); }
2054 
2055 Real dotproduct(const Matrix& A, const Matrix& B);
2056 Matrix crossproduct(const Matrix& A, const Matrix& B);
2057 ReturnMatrix crossproduct_rows(const Matrix& A, const Matrix& B);
2058 ReturnMatrix crossproduct_columns(const Matrix& A, const Matrix& B);
2059 
2060 inline Real DotProduct(const Matrix& A, const Matrix& B)
2061  { return dotproduct(A, B); }
2062 inline Matrix CrossProduct(const Matrix& A, const Matrix& B)
2063  { return crossproduct(A, B); }
2064 inline ReturnMatrix CrossProductRows(const Matrix& A, const Matrix& B)
2065  { return crossproduct_rows(A, B); }
2066 inline ReturnMatrix CrossProductColumns(const Matrix& A, const Matrix& B)
2067  { return crossproduct_columns(A, B); }
2068 
2069 void newmat_block_copy(int n, Real* from, Real* to);
2070 
2071 // ********************* friend functions ******************************** //
2072 
2073 // Functions declared as friends - G++ wants them declared externally as well
2074 
2076 bool Compare(const MatrixType&, MatrixType&);
2077 Real dotproduct(const Matrix& A, const Matrix& B);
2078 SPMatrix SP(const BaseMatrix&, const BaseMatrix&);
2079 KPMatrix KP(const BaseMatrix&, const BaseMatrix&);
2080 ShiftedMatrix operator+(Real f, const BaseMatrix& BM);
2082 ScaledMatrix operator*(Real f, const BaseMatrix& BM);
2083 
2084 // ********************* inline functions ******************************** //
2085 
2087  { return B.log_determinant(); }
2089  { return B.log_determinant(); }
2090 inline Real determinant(const BaseMatrix& B)
2091  { return B.determinant(); }
2092 inline Real Determinant(const BaseMatrix& B)
2093  { return B.determinant(); }
2094 inline Real sum_square(const BaseMatrix& B) { return B.sum_square(); }
2095 inline Real SumSquare(const BaseMatrix& B) { return B.sum_square(); }
2096 inline Real norm_Frobenius(const BaseMatrix& B) { return B.norm_Frobenius(); }
2097 inline Real norm_frobenius(const BaseMatrix& B) { return B.norm_Frobenius(); }
2098 inline Real NormFrobenius(const BaseMatrix& B) { return B.norm_Frobenius(); }
2099 inline Real trace(const BaseMatrix& B) { return B.trace(); }
2100 inline Real Trace(const BaseMatrix& B) { return B.trace(); }
2102  { return B.sum_absolute_value(); }
2104  { return B.sum_absolute_value(); }
2105 inline Real sum(const BaseMatrix& B)
2106  { return B.sum(); }
2107 inline Real Sum(const BaseMatrix& B)
2108  { return B.sum(); }
2110  { return B.maximum_absolute_value(); }
2112  { return B.maximum_absolute_value(); }
2114  { return B.minimum_absolute_value(); }
2116  { return B.minimum_absolute_value(); }
2117 inline Real maximum(const BaseMatrix& B) { return B.maximum(); }
2118 inline Real Maximum(const BaseMatrix& B) { return B.maximum(); }
2119 inline Real minimum(const BaseMatrix& B) { return B.minimum(); }
2120 inline Real Minimum(const BaseMatrix& B) { return B.minimum(); }
2121 inline Real norm1(const BaseMatrix& B) { return B.norm1(); }
2122 inline Real Norm1(const BaseMatrix& B) { return B.norm1(); }
2123 inline Real norm1(RowVector& RV) { return RV.maximum_absolute_value(); }
2124 inline Real Norm1(RowVector& RV) { return RV.maximum_absolute_value(); }
2125 inline Real norm_infinity(const BaseMatrix& B) { return B.norm_infinity(); }
2126 inline Real NormInfinity(const BaseMatrix& B) { return B.norm_infinity(); }
2128  { return CV.maximum_absolute_value(); }
2130  { return CV.maximum_absolute_value(); }
2131 inline bool IsZero(const GeneralMatrix& A) { return A.IsZero(); }
2132 inline bool is_zero(const GeneralMatrix& A) { return A.is_zero(); }
2133 
2134 
2135 inline MatrixInput MatrixInput::operator<<(int f) { return *this << (Real)f; }
2136 inline MatrixInput GeneralMatrix::operator<<(int f) { return *this << (Real)f; }
2137 inline MatrixInput BandMatrix::operator<<(int f) { return *this << (Real)f; }
2138 inline MatrixInput GetSubMatrix::operator<<(int f) { return *this << (Real)f; }
2139 
2140 inline ReversedMatrix BaseMatrix::Reverse() const { return reverse(); }
2141 inline RowedMatrix BaseMatrix::AsRow() const { return as_row(); }
2142 inline ColedMatrix BaseMatrix::AsColumn() const { return as_column(); }
2143 inline DiagedMatrix BaseMatrix::AsDiagonal() const { return as_diagonal(); }
2144 inline MatedMatrix BaseMatrix::AsMatrix(int m, int n) const
2145  { return as_matrix(m, n); }
2146 inline GetSubMatrix BaseMatrix::SubMatrix(int fr, int lr, int fc, int lc) const
2147  { return submatrix(fr, lr, fc, lc); }
2148 inline GetSubMatrix BaseMatrix::SymSubMatrix(int f, int l) const
2149  { return sym_submatrix(f, l); }
2150 inline GetSubMatrix BaseMatrix::Row(int f) const { return row(f); }
2151 inline GetSubMatrix BaseMatrix::Rows(int f, int l) const { return rows(f, l); }
2152 inline GetSubMatrix BaseMatrix::Column(int f) const { return column(f); }
2153 inline GetSubMatrix BaseMatrix::Columns(int f, int l) const
2154  { return columns(f, l); }
2155 inline Real BaseMatrix::AsScalar() const { return as_scalar(); }
2156 
2157 inline ReturnMatrix GeneralMatrix::ForReturn() const { return for_return(); }
2158 
2159 inline void swap(Matrix& A, Matrix& B) { A.swap(B); }
2160 inline void swap(SquareMatrix& A, SquareMatrix& B) { A.swap(B); }
2161 inline void swap(nricMatrix& A, nricMatrix& B) { A.swap(B); }
2163  { A.swap(B); }
2165  { A.swap(B); }
2166 inline void swap(SymmetricMatrix& A, SymmetricMatrix& B) { A.swap(B); }
2167 inline void swap(DiagonalMatrix& A, DiagonalMatrix& B) { A.swap(B); }
2168 inline void swap(RowVector& A, RowVector& B) { A.swap(B); }
2169 inline void swap(ColumnVector& A, ColumnVector& B) { A.swap(B); }
2170 inline void swap(CroutMatrix& A, CroutMatrix& B) { A.swap(B); }
2171 inline void swap(BandMatrix& A, BandMatrix& B) { A.swap(B); }
2172 inline void swap(UpperBandMatrix& A, UpperBandMatrix& B) { A.swap(B); }
2173 inline void swap(LowerBandMatrix& A, LowerBandMatrix& B) { A.swap(B); }
2174 inline void swap(SymmetricBandMatrix& A, SymmetricBandMatrix& B) { A.swap(B); }
2175 inline void swap(BandLUMatrix& A, BandLUMatrix& B) { A.swap(B); }
2176 inline void swap(IdentityMatrix& A, IdentityMatrix& B) { A.swap(B); }
2177 inline void swap(GenericMatrix& A, GenericMatrix& B) { A.swap(B); }
2178 
2179 #ifdef OPT_COMPATIBLE // for compatibility with opt++
2180 
2181 inline Real Norm2(const ColumnVector& CV) { return CV.norm_Frobenius(); }
2182 inline Real Dot(ColumnVector& CV1, ColumnVector& CV2)
2183  { return dotproduct(CV1, CV2); }
2184 
2185 #endif
2186 
2187 
2188 #ifdef use_namespace
2189 }
2190 #endif
2191 
2192 
2193 #endif
2194 
2195 // body file: newmat1.cpp
2196 // body file: newmat2.cpp
2197 // body file: newmat3.cpp
2198 // body file: newmat4.cpp
2199 // body file: newmat5.cpp
2200 // body file: newmat6.cpp
2201 // body file: newmat7.cpp
2202 // body file: newmat8.cpp
2203 // body file: newmatex.cpp
2204 // body file: bandmat.cpp
2205 // body file: submat.cpp
2206 
2207 
2208 
2210 
2211 
2212 
2213 
static unsigned long Select
Definition: newmat.h:1917
void Add(GeneralMatrix *, Real)
Definition: newmat5.cpp:327
void operator<<(const BaseMatrix &)
Definition: submat.cpp:102
bool is_symmetric() const
Definition: newmat.h:189
StackedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1535
virtual Real minimum_absolute_value() const
Definition: newmat8.cpp:476
void RestoreCol(MatrixRowCol &)
Definition: newmat.h:1285
void swap(UpperBandMatrix &gm)
Definition: newmat.h:1200
MatrixType Type() const
Definition: newmat.h:493
virtual short SimpleAddOK(const GeneralMatrix *)
Definition: newmat.h:480
LogAndSign LogDeterminant(const BaseMatrix &B)
Definition: newmat.h:2088
Real minimum2(int &i, int &j) const
Definition: newmat8.cpp:341
void operator-=(const Matrix &M)
Definition: newmat.h:670
void operator=(Real f)
Definition: newmat.h:725
Real maximum_absolute_value() const
Definition: newmat.h:1274
void ReSize(int m, int n, int b)
Definition: newmat.h:1224
void operator=(const BaseMatrix &bm)
Definition: newmat.h:723
~RealStarStar()
Definition: newmat.h:1897
RowVector(const RowVector &gm)
Definition: newmat.h:961
Real minimum() const
Definition: newmat.h:1279
void operator-=(const Matrix &M)
Definition: newmat.h:1048
void operator=(const SymmetricMatrix &m)
Definition: newmat.h:763
GeneralMatrix * gm
Definition: newmat.h:1811
~DiagonalMatrix()
Definition: newmat.h:901
bool operator!=(const MatrixBandWidth &bw) const
Definition: newmat.h:215
Real minimum() const
Definition: newmat.h:1137
~SymmetricMatrix()
Definition: newmat.h:758
void swap(SymmetricBandMatrix &gm)
Definition: newmat4.cpp:1301
MatrixBandWidth bandwidth() const
Definition: newmat4.cpp:746
LogAndSign log_determinant(const BaseMatrix &B)
Definition: newmat.h:2086
Real norm_Frobenius() const
Definition: newmat8.cpp:443
bool even_exchanges() const
Definition: newmat.h:1341
void Release()
Definition: newmat.h:514
void swap(DiagonalMatrix &gm)
Definition: newmat.h:947
bool is_singular() const
Definition: newmat.h:1336
Real Sum(const BaseMatrix &B)
Definition: newmat.h:2107
void operator+=(const BaseMatrix &)
Definition: newmat6.cpp:492
void operator=(Real f)
Definition: newmat.h:762
void operator+=(const Matrix &M)
Definition: newmat.h:744
bool operator<(MatrixType mt) const
Definition: newmat.h:163
void operator-=(Real r)
Definition: newmat.h:1416
void operator=(const RowVector &m)
Definition: newmat.h:964
MatrixType sub() const
< type of submatrix
Definition: newmat.h:175
Real * nric() const
Definition: newmat.h:1041
GeneralMatrix * MakeSolver()
Definition: newmat.h:1181
void ReSize(int m, int n, int b)
Definition: newmat.h:1185
ostream & operator<<(ostream &s, const BaseMatrix &X)
Definition: newmat9.cpp:35
ReturnMatrix crossproduct_rows(const Matrix &A, const Matrix &B)
Definition: newmat7.cpp:977
MatrixBandWidth(const int i)
Definition: newmat.h:208
Miscellaneous exception (details in character string).
Definition: newmat.h:1947
LogAndSign LogDeterminant() const
Definition: newmat.h:342
MatrixType(int i)
Definition: newmat.h:144
void operator+=(Real f)
Definition: newmat.h:671
void resize_keep(int i)
change length, keep data
Definition: newmat.h:1882
virtual void RestoreRow(MatrixRowCol &)
Definition: newmat.h:539
void operator=(const MatrixType &mt)
Definition: newmat.h:148
void operator<<(const BaseMatrix &X)
Definition: newmat.h:1161
void ReSize(int m)
Definition: newmat.h:786
void ReSize(int m)
Definition: newmat.h:1034
ScaledMatrix(const BaseMatrix *bmx, Real fx)
Definition: newmat.h:1616
bool is_singular() const
Definition: newmat.h:1085
int * data()
pointer to the data
Definition: newmat.h:1875
int Sign() const
Definition: newmat.h:61
void ReSize(int m, int n)
Definition: newmat.h:699
bool operator!=(MatrixType t) const
Definition: newmat.h:167
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:884
Real maximum(const BaseMatrix &B)
Definition: newmat.h:2117
void MiniCleanUp()
Definition: newmat.h:1044
int value() const
Definition: newmat.h:235
bool operator==(const MatrixBandWidth &bw) const
Definition: newmat.h:213
void operator=(Real f)
Definition: newmat.h:907
void change_sign()
change sign
Definition: newmat.h:58
SolvedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1551
Real Value() const
Definition: newmat.h:64
Matrix()
Definition: newmat.h:629
virtual Real sum_square() const
Definition: newmat8.cpp:437
virtual void cleanup()
Definition: newmat.h:395
virtual Real maximum() const
Definition: newmat8.cpp:494
ShiftedMatrix(const BaseMatrix *bmx, Real fx)
Definition: newmat.h:1584
virtual void resize(int, int, int)
Definition: bandmat.cpp:50
void protect()
Definition: newmat.h:508
Matrix crossproduct(const Matrix &A, const Matrix &B)
Definition: newmat7.cpp:953
GetSubMatrix Columns(int f, int l) const
Definition: newmat.h:2153
Real Maximum1(int &i) const
Definition: newmat.h:373
Real Minimum(const BaseMatrix &B)
Definition: newmat.h:2120
void swap(Matrix &gm)
Definition: newmat.h:673
void Release(int t)
Definition: newmat.h:515
static unsigned long Select
Definition: newmat.h:1963
~ColumnVector()
Definition: newmat.h:1013
ReturnMatrix CrossProductColumns(const Matrix &A, const Matrix &B)
Definition: newmat.h:2066
void operator=(Real f)
Definition: newmat.h:1257
IdentityMatrix(ArrayLengthSpecifier n)
Definition: newmat.h:1356
Real norm1(const BaseMatrix &B)
Definition: newmat.h:2121
NegShiftedMatrix operator-(Real, const BaseMatrix &)
Definition: newmat6.cpp:305
void operator-=(Real f)
Definition: newmat.h:946
MatrixBandWidth(const int l, const int u)
Definition: newmat.h:207
MatrixType ssub() const
< type of sym submatrix
Definition: newmat.h:177
void swap(SquareMatrix &gm)
Definition: newmat.h:706
Real sum() const
Definition: newmat.h:1370
LowerBandMatrix(const LowerBandMatrix &gm)
Definition: newmat.h:1219
void operator-=(const Matrix &M)
Definition: newmat.h:703
int * Data()
pointer to the data
Definition: newmat.h:1873
void release_and_delete()
Definition: newmat.h:519
int * a
pointer to the array
Definition: newmat.h:1855
bool is_band() const
Definition: newmat.h:187
Real * r
Definition: newmat.h:1832
Internal newmat exception - shouldn&#39;t happen.
Definition: newmat.h:2025
Real norm_frobenius(const BaseMatrix &B)
Definition: newmat.h:2097
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:1383
int upper_val
Definition: newmat.h:1103
Real SumAbsoluteValue() const
Definition: newmat.h:351
ColumnVector()
Definition: newmat.h:1012
nricMatrix()
Definition: newmat.h:718
SPMatrix SP(const BaseMatrix &, const BaseMatrix &)
Definition: newmat6.cpp:278
void swap(Matrix &A, Matrix &B)
Definition: newmat.h:2159
Real Maximum(const BaseMatrix &B)
Definition: newmat.h:2118
Real Norm1() const
Definition: newmat.h:385
void operator+=(const Matrix &M)
Definition: newmat.h:702
const int * const_data_indx() const
Definition: newmat.h:1087
void operator=(const nricMatrix &m)
Definition: newmat.h:726
Real DotProduct(const Matrix &A, const Matrix &B)
Definition: newmat.h:2060
Cannot build matrix with these properties exception.
Definition: newmat.h:2016
GeneralMatrix * gm
Definition: newmat.h:1399
void MiniCleanUp()
Definition: newmat.h:995
Real Minimum2(int &i, int &j) const
Definition: newmat.h:381
virtual void ReSize(int m, int n)
Definition: newmat.h:662
void GetCol(MatrixColX &c)
Definition: newmat.h:1332
virtual void MiniCleanUp()
Definition: newmat.h:482
void operator=(const DiagonalMatrix &m)
Definition: newmat.h:908
const int * Data() const
pointer to the data
Definition: newmat.h:1874
virtual Real trace() const
Definition: newmat8.cpp:617
ShiftedMatrix operator+(Real f, const BaseMatrix &BM)
Definition: newmat6.cpp:302
void swap(GenericMatrix &x)
Definition: newmat4.cpp:1324
int size2() const
Definition: newmat.h:1339
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:789
const int * const_data_indx() const
Definition: newmat.h:1340
void Inject(const GeneralMatrix &GM)
Definition: newmat.h:526
~AddedMatrix()
Definition: newmat.h:1466
Real Maximum2(int &i, int &j) const
Definition: newmat.h:375
virtual Real Sum() const
Definition: newmat.h:353
Real minimum(const BaseMatrix &B)
Definition: newmat.h:2119
ReversedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1662
void ReSize(int m)
Definition: newmat.h:985
ColumnVector(const ColumnVector &gm)
Definition: newmat.h:1016
Real * nric() const
Definition: newmat.h:992
virtual void ReSize(const GeneralMatrix &A)
Definition: newmat.h:575
double Real
Definition: include.h:307
bool operator>=(MatrixType mt) const
Definition: newmat.h:161
static unsigned long Select
Definition: newmat.h:2019
AddedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1459
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:991
NegShiftedMatrix(Real fx, const BaseMatrix *bmx)
Definition: newmat.h:1601
LowerTriangularMatrix(const LowerTriangularMatrix &gm)
Definition: newmat.h:855
int n
length of the array
Definition: newmat.h:1856
friend class LinearEquationSolver
Definition: newmat.h:438
void operator-=(Real f)
Definition: newmat.h:705
void operator=(Real f)
Definition: newmat.h:634
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:938
void operator-=(const SymmetricMatrix &M)
Definition: newmat.h:791
void PowEq(int k)
Definition: newmat.h:56
void IEQND() const
Definition: newmatex.cpp:318
void swap(IdentityMatrix &gm)
Definition: newmat.h:1386
virtual MatrixBandWidth bandwidth() const
Definition: newmat4.cpp:671
#define FREE_CHECK(Class)
Definition: myexcept.h:328
GeneralMatrix * Evaluate(MatrixType mt=MatrixTypeUnSp)
Definition: newmat5.cpp:85
void operator=(const ColumnVector &m)
Definition: newmat.h:1019
Matrix(const Matrix &gm)
Definition: newmat.h:648
Quaternion operator/(const Real c, const Quaternion &q)
Overload / operator, division by a scalar.
Definition: quaternion.cpp:542
Real ** nric() const
Definition: newmat.h:741
int attribute
Definition: newmat.h:139
static void Add(GeneralMatrix *gm, GeneralMatrix *gm1, GeneralMatrix *gm2)
Definition: newmat7.cpp:131
Real norm1() const
Definition: newmat7.cpp:712
MatrixType()
Definition: newmat.h:143
void release()
Definition: newmat.h:1422
Real log_val
Definition: newmat.h:49
void operator=(Real f)
Definition: newmat.h:1216
Real sum() const
Definition: newmat8.cpp:172
bool is_zero() const
Definition: newmat7.cpp:865
void operator=(const UpperTriangularMatrix &m)
Definition: newmat.h:807
DiagonalMatrix(const DiagonalMatrix &gm)
Definition: newmat.h:904
void operator=(Real)
Definition: newmat6.cpp:346
~BandMatrix()
Definition: newmat.h:1105
LogAndSign()
Definition: newmat.h:52
void ReSize(int m)
Definition: newmat.h:935
virtual void ReSize(int m, int n, int b)
Definition: newmat.h:1145
MatrixType operator|(const MatrixType &mt) const
Definition: newmat.h:157
MultipliedMatrix operator*(const BaseMatrix &) const
Definition: newmat6.cpp:284
UpperBandMatrix(const UpperBandMatrix &gm)
Definition: newmat.h:1180
void swap(nricMatrix &gm)
Definition: newmat4.cpp:1275
GenericMatrix(const BaseMatrix &bm)
Definition: newmat.h:1404
const int * data() const
pointer to the data
Definition: newmat.h:1876
Real SumSquare(const BaseMatrix &B)
Definition: newmat.h:2095
void CleanUp()
set length to zero
Definition: newmat.h:1885
nricMatrix(const BaseMatrix &bm)
Definition: newmat.h:721
void operator+=(Real f)
Definition: newmat.h:704
int Nrows() const
Definition: newmat.h:494
KPMatrix KP(const BaseMatrix &, const BaseMatrix &)
Definition: newmat6.cpp:281
Real MinimumAbsoluteValue1(int &i) const
Definition: newmat.h:365
int sign_val
Definition: newmat.h:50
BandMatrix()
Definition: newmat.h:1104
bool sing
Definition: newmat.h:1063
int search(const BaseMatrix *) const
Definition: newmat.h:1812
int lower() const
Definition: newmat.h:219
ReversedMatrix Reverse() const
Definition: newmat.h:2140
bool CannotConvert() const
Definition: newmat.h:190
Real minimum_absolute_value() const
Definition: newmat.h:1276
virtual MatrixBandWidth BandWidth() const
Definition: newmat.h:389
void Inject(const GeneralMatrix &GM)
Definition: newmat.h:1798
Upper triangular band matrix.
Definition: newmat.h:1167
void operator+=(const Matrix &M)
Definition: newmat.h:998
CroutMatrix()
Definition: newmat.h:1069
GeneralMatrix * MakeSolver()
Definition: newmat.h:822
void operator=(Real f)
Definition: newmat.h:1363
int upper() const
Definition: newmat.h:217
void operator+=(Real f)
Definition: newmat.h:792
void ReSize(int m, int n)
Definition: newmat.h:1038
GeneralMatrix * gm
Definition: newmat.h:1633
int col_number
Definition: newmat.h:1766
void RestoreCol(MatrixColX &c)
Definition: newmat.h:830
void operator<<(const BaseMatrix &X)
Definition: newmat.h:1300
SPMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1477
Real maximum_absolute_value() const
Definition: newmat8.cpp:218
GenericMatrix(const GenericMatrix &bm)
Definition: newmat.h:1406
int row_skip
Definition: newmat.h:1763
void operator/=(Real r)
Definition: newmat.h:1418
Real * data()
Definition: newmat.h:502
void operator=(const UpperBandMatrix &m)
Definition: newmat.h:1178
SquareMatrix()
Definition: newmat.h:683
~SolvedMatrix()
Definition: newmat.h:1556
~ReturnMatrix()
Definition: newmat.h:1746
~GetSubMatrix()
Definition: newmat.h:1779
void operator=(const LowerBandMatrix &m)
Definition: newmat.h:1217
Real sum() const
Definition: newmat.h:1130
int Storage() const
Definition: newmat.h:496
GeneralMatrix * MakeSolver()
Definition: newmat.h:931
int nrows_val
Definition: newmat.h:452
A matrix is not square exception.
Definition: newmat.h:1981
void operator+=(Real f)
Definition: newmat.h:888
Real MaximumAbsoluteValue() const
Definition: newmat.h:355
bool IsSingular() const
Definition: newmat.h:1086
IdentityMatrix(const IdentityMatrix &gm)
Definition: newmat.h:1358
~ColedMatrix()
Definition: newmat.h:1705
void operator/=(Real r)
Definition: newmat.h:1796
bool is_zero(const BaseMatrix &A)
Definition: newmat7.cpp:878
ReturnMatrix(const GeneralMatrix *gmx)
Definition: newmat.h:1750
int tag_val
Definition: newmat.h:451
virtual Real minimum() const
Definition: newmat8.cpp:512
Upper triangular matrix.
Definition: newmat.h:799
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:1291
int row_number
Definition: newmat.h:1764
MatedMatrix(const BaseMatrix *bmx, int nrx, int ncx)
Definition: newmat.h:1729
int Value() const
Definition: newmat.h:234
Square matrix.
Definition: newmat.h:679
void operator+=(Real f)
Definition: newmat.h:945
ColedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1702
Real LogValue() const
Definition: newmat.h:59
void ReleaseAndDelete()
Definition: newmat.h:516
void operator+=(Real f)
Definition: newmat.h:840
UpperBandMatrix(int n, int ubw)
Definition: newmat.h:1173
KPMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1498
void operator-=(Real f)
Definition: newmat.h:1001
GeneralMatrix * Evaluate(MatrixType mt=MatrixTypeUnSp)
Definition: newmat7.cpp:484
int Upper() const
Definition: newmat.h:216
bool is_diagonal() const
Definition: newmat.h:188
void operator-=(Real r)
Definition: newmat.h:533
void ReSize(int m, int n)
Definition: newmat.h:989
void operator-=(const Matrix &M)
Definition: newmat.h:745
bool operator!() const
Definition: newmat.h:169
void resize(int n, int lbw)
Definition: newmat.h:1225
bool even_exchanges() const
Definition: newmat.h:1088
GetSubMatrix Column(int f) const
Definition: newmat.h:2152
void operator-=(const BaseMatrix &)
Definition: newmat6.cpp:505
void resize(int n, int ubw)
Definition: newmat.h:1186
Real MinimumAbsoluteValue2(int &i, int &j) const
Definition: newmat.h:368
FloatVector * d
bool operator<=(const BaseMatrix &A, const BaseMatrix &)
Definition: newmat.h:2043
Real Trace() const
Definition: newmat.h:383
Real sum_absolute_value() const
Definition: newmat8.cpp:164
ScaledMatrix operator*(Real t) const
Definition: newmat.h:1678
Real Minimum1(int &i) const
Definition: newmat.h:379
void operator+=(Real f)
Definition: newmat.h:1000
Real maximum2(int &i, int &j) const
Definition: newmat8.cpp:326
RowedMatrix AsRow() const
Definition: newmat.h:2141
Real NormInfinity(const BaseMatrix &B)
Definition: newmat.h:2126
ArrayLengthSpecifier(int l)
Definition: newmat.h:236
void swap(GeneralMatrix &gm)
Definition: newmat4.cpp:1264
int size() const
Definition: newmat.h:501
int Tag() const
Definition: newmat.h:511
Real Norm1(const BaseMatrix &B)
Definition: newmat.h:2122
void swap(SymmetricMatrix &gm)
Definition: newmat.h:794
MatrixInput operator<<(double)
Definition: newmat5.cpp:500
Band matrix.
Definition: newmat.h:1096
Real * nric() const
Definition: newmat.h:939
MatrixBandWidth t() const
Definition: newmat.h:212
void operator/=(Real r)
Definition: newmat.h:535
void operator-=(Real f)
Definition: newmat.h:672
void operator+=(const Matrix &M)
Definition: newmat.h:1047
GeneralMatrix * MakeSolver()
Definition: newmat.h:1076
void operator=(Real f)
Definition: newmat.h:811
bool IsZero() const
Definition: newmat.h:513
int storage2
Definition: newmat.h:1312
Real * Store() const
Definition: newmat.h:497
void operator=(const SymmetricBandMatrix &m)
Definition: newmat.h:1258
nricMatrix(int m, int n)
Definition: newmat.h:719
void swap(RowVector &gm)
Definition: newmat.h:1002
virtual Real sum_absolute_value() const
Definition: newmat8.cpp:446
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:1230
Real sum_square() const
Definition: newmat8.cpp:156
bool Compare(const MatrixType &, MatrixType &)
Definition: newmat4.cpp:980
void operator-=(Real f)
Definition: newmat.h:889
NegatedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1634
void operator+=(const SymmetricMatrix &M)
Definition: newmat.h:790
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:835
int tag() const
Definition: newmat.h:510
void ReSize(int n, int lbw)
Definition: newmat.h:1227
void resize(const GeneralMatrix &A)
resize BandMatrix
Definition: newmat.h:1190
Real Trace(const BaseMatrix &B)
Definition: newmat.h:2100
Real norm_frobenius() const
Definition: newmat.h:348
virtual Real maximum_absolute_value() const
Definition: newmat8.cpp:458
void operator-=(Real f)
Definition: newmat.h:793
void swap(LowerTriangularMatrix &gm)
Definition: newmat.h:890
ReturnMatrix(const ReturnMatrix &tm)
Definition: newmat.h:1749
Real MaximumAbsoluteValue2(int &i, int &j) const
Definition: newmat.h:360
GeneralMatrix * gm
Definition: newmat.h:1743
Real MaximumAbsoluteValue(const BaseMatrix &B)
Definition: newmat.h:2111
ColumnVector(ArrayLengthSpecifier n)
Definition: newmat.h:1014
Real NormFrobenius() const
Definition: newmat.h:349
SquareMatrix(const SquareMatrix &gm)
Definition: newmat.h:692
Singular matrix exception.
Definition: newmat.h:1931
ReturnMatrix crossproduct_columns(const Matrix &A, const Matrix &B)
Definition: newmat7.cpp:1000
void RestoreCol(MatrixColX &c)
Definition: newmat.h:878
void operator-=(Real f)
Definition: newmat.h:747
MatrixBandWidth bandwidth() const
Definition: newmat4.cpp:687
bool operator==(const GeneralMatrix &A, const GeneralMatrix &B)
Definition: newmat7.cpp:839
bool IsSingular() const
Definition: newmat.h:1337
void operator+=(const Matrix &M)
Definition: newmat.h:669
Matrix CrossProduct(const Matrix &A, const Matrix &B)
Definition: newmat.h:2062
Real minimum_absolute_value() const
Definition: newmat.h:1134
Real dotproduct(const Matrix &A, const Matrix &B)
Definition: newmat8.cpp:530
void operator-=(Real r)
Definition: newmat.h:1794
void cleanup()
Definition: newmat.h:1420
Real norm_infinity(const BaseMatrix &B)
Definition: newmat.h:2125
int Size() const
return the size of the array
Definition: newmat.h:1869
virtual void RestoreCol(MatrixColX &)
Definition: newmat.h:544
Real NormFrobenius(const BaseMatrix &B)
Definition: newmat.h:2098
void RestoreCol(MatrixRowCol &)
Definition: newmat.h:782
Real maximum_absolute_value() const
Definition: newmat.h:1132
ScaledMatrix operator*(Real f, const BaseMatrix &BM)
Definition: newmat6.cpp:314
Real minimum_absolute_value(const BaseMatrix &B)
Definition: newmat.h:2113
SymmetricMatrix(const SymmetricMatrix &gm)
Definition: newmat.h:773
void ReSize(int m)
Definition: newmat.h:881
void resize(const GeneralMatrix &A)
resize BandMatrix
Definition: newmat.h:1229
Base of the matrix classes.
Definition: newmat.h:292
int * indx
Definition: newmat.h:1308
~DiagedMatrix()
Definition: newmat.h:1718
Real sum_square(const BaseMatrix &B)
Definition: newmat.h:2094
const Real * const_data2() const
Definition: newmat.h:1338
void ReSize(int m, int b)
Definition: newmat.h:1289
GeneralMatrix * MakeSolver()
Definition: newmat.h:1327
void operator=(const IdentityMatrix &m)
Definition: newmat.h:1362
bool DataLossOK
Definition: newmat.h:140
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:739
~MatedMatrix()
Definition: newmat.h:1733
BandLUMatrix()
Definition: newmat.h:1319
Let matrix simulate a C type two dimensional array.
Definition: newmat.h:1892
const Real * const_data() const
Definition: newmat.h:504
void GetCol(MatrixColX &c)
Definition: newmat.h:1081
void operator+=(const LowerTriangularMatrix &M)
Definition: newmat.h:886
Real norm_infinity() const
Definition: newmat7.cpp:724
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:664
The usual rectangular matrix.
Definition: newmat.h:625
Real maximum() const
Definition: newmat.h:1278
GeneralMatrix * MakeSolver()
Definition: newmat.h:1377
MatrixType operator&(const MatrixType &mt) const
Definition: newmat.h:159
Real * store
Definition: newmat.h:454
SymmetricBandMatrix(int n, int lb)
Definition: newmat.h:1254
LowerBandMatrix(int n, int lbw)
Definition: newmat.h:1212
void swap(LowerBandMatrix &gm)
Definition: newmat.h:1239
~SPMatrix()
Definition: newmat.h:1484
GetSubMatrix SymSubMatrix(int f, int l) const
Definition: newmat.h:2148
const int * const_data() const
pointer to the data
Definition: newmat.h:1877
Real Determinant() const
Definition: newmat.h:344
~RowedMatrix()
Definition: newmat.h:1692
Real SumSquare() const
Definition: newmat.h:346
static unsigned long Select
Definition: newmat.h:1952
Real SumAbsoluteValue(const BaseMatrix &B)
Definition: newmat.h:2103
void release(int t)
Definition: newmat.h:518
static unsigned long Select
Definition: newmat.h:1984
Incompatible dimensions exception.
Definition: newmat.h:1998
Rectangular matrix for use with Numerical Recipes in C.
Definition: newmat.h:711
void operator=(const SquareMatrix &m)
Definition: newmat.h:689
Real determinant() const
Definition: newmat8.cpp:719
Submatrix dimension exception.
Definition: newmat.h:1990
Real norm_Frobenius(const BaseMatrix &B)
Definition: newmat.h:2096
MatrixInput(const MatrixInput &mi)
Definition: newmat.h:1834
Real ** row_pointer
Definition: newmat.h:714
void resize(int m, int n)
Definition: newmat.h:732
FloatVector FloatVector * a
void operator+=(Real f)
Definition: newmat.h:1049
Index exception.
Definition: newmat.h:1960
void Release()
Definition: newmat.h:1421
void operator=(Real f)
Definition: newmat.h:688
bool Rectangular(MatrixType a, MatrixType b, MatrixType c)
Definition: newmat1.cpp:108
bool sing
Definition: newmat.h:1310
bool operator>(const BaseMatrix &A, const BaseMatrix &)
Definition: newmat.h:2049
int Ncols() const
Definition: newmat.h:495
Real minimum_absolute_value2(int &i, int &j) const
Definition: newmat8.cpp:311
LU decomposition of a band matrix.
Definition: newmat.h:1306
BandMatrix(const BandMatrix &gm)
Definition: newmat.h:1122
static unsigned long Select
Definition: newmat.h:1975
Real Minimum() const
Definition: newmat.h:377
bool operator<(const BaseMatrix &A, const BaseMatrix &)
Definition: newmat.h:2047
void operator<<(const BaseMatrix &X)
Definition: newmat.h:523
Real trace(const BaseMatrix &B)
Definition: newmat.h:2099
~RowVector()
Definition: newmat.h:958
MatedMatrix AsMatrix(int m, int n) const
Definition: newmat.h:2144
BandMatrix(int n, int lb, int ub)
Definition: newmat.h:1106
Real * store2
Definition: newmat.h:1311
virtual GeneralMatrix * Evaluate(MatrixType mt=MatrixTypeUnSp)=0
void MatrixErrorNoSpace(const void *)
test for allocation fails
Definition: newmatex.cpp:301
void swap(CroutMatrix &gm)
Definition: newmat4.cpp:1282
void CleanUp()
Definition: newmat.h:396
bool operator>=(const BaseMatrix &A, const BaseMatrix &)
Definition: newmat.h:2045
SymmetricBandMatrix(const SymmetricBandMatrix &gm)
Definition: newmat.h:1268
int sign() const
sign of the value
Definition: newmat.h:62
Real AsScalar() const
Definition: newmat.h:2155
void operator=(const BandMatrix &m)
Definition: newmat.h:1111
void RestoreCol(MatrixColX &c)
Definition: newmat.h:1142
GeneralMatrix * Evaluate(MatrixType)
Definition: newmat.h:1818
Diagonal matrix.
Definition: newmat.h:896
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:1147
nricMatrix(const nricMatrix &gm)
Definition: newmat.h:730
Real NormInfinity() const
Definition: newmat.h:387
void RestoreCol(MatrixRowCol &)
Definition: newmat.h:981
const char * Value() const
Definition: newmat.h:183
bool d
Definition: newmat.h:1062
static unsigned long Select
Definition: newmat.h:1925
bool operator!=(const GeneralMatrix &A, const GeneralMatrix &B)
Definition: newmat.h:2036
void operator+=(const UpperTriangularMatrix &M)
Definition: newmat.h:838
#define MatrixTypeUnSp
Definition: newmat.h:287
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:1040
Lower triangular matrix.
Definition: newmat.h:848
UpperTriangularMatrix(const UpperTriangularMatrix &gm)
Definition: newmat.h:809
~StackedMatrix()
Definition: newmat.h:1542
void operator=(const BaseMatrix &)
Definition: newmat6.cpp:349
Real ** a
Definition: newmat.h:1894
virtual void RestoreCol(MatrixRowCol &)
Definition: newmat.h:543
GetSubMatrix Row(int f) const
Definition: newmat.h:2150
const Real ** a
Definition: newmat.h:1904
GetSubMatrix(const GetSubMatrix &g)
Definition: newmat.h:1776
int size() const
return the size of the array
Definition: newmat.h:1871
void swap(BandLUMatrix &gm)
Definition: newmat4.cpp:1309
void swap(ColumnVector &gm)
Definition: newmat.h:1051
static unsigned long Select
Definition: newmat.h:2011
MatrixInput(int nx, Real *rx)
Definition: newmat.h:1835
GetSubMatrix SubMatrix(int fr, int lr, int fc, int lc) const
Definition: newmat.h:2146
int ncols() const
Definition: newmat.h:500
Real overflow exception.
Definition: newmat.h:1939
Symmetric band matrix.
Definition: newmat.h:1245
void operator-=(const UpperTriangularMatrix &M)
Definition: newmat.h:839
~KPMatrix()
Definition: newmat.h:1505
Lower triangular band matrix.
Definition: newmat.h:1206
void operator=(const Matrix &m)
Definition: newmat.h:635
void operator-=(const Matrix &M)
Definition: newmat.h:999
virtual void resize(int, int)
Definition: newmat4.cpp:289
MatrixType(const MatrixType &mt)
Definition: newmat.h:146
DiagedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1715
void operator-=(const LowerTriangularMatrix &M)
Definition: newmat.h:887
ReturnMatrix ForReturn() const
Definition: newmat.h:2157
RowedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1689
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:701
void ReSize(int m, int n)
Definition: newmat.h:736
SimpleIntArray()
build an array length 0
Definition: newmat.h:1859
Real sum_absolute_value(const BaseMatrix &B)
Definition: newmat.h:2101
void newmat_block_copy(int n, Real *from, Real *to)
Definition: newmat4.cpp:807
ConcatenatedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1517
Real sum(const BaseMatrix &B)
Definition: newmat.h:2105
MatrixType(int i, bool dlok)
Definition: newmat.h:145
DiagedMatrix AsDiagonal() const
Definition: newmat.h:2143
Not positive definite exception.
Definition: newmat.h:1914
Not defined exception.
Definition: newmat.h:2008
~SquareMatrix()
Definition: newmat.h:684
void operator<<(const double *)
Definition: newmat6.cpp:440
Real Determinant(const BaseMatrix &B)
Definition: newmat.h:2092
Real maximum() const
Definition: newmat.h:1136
void SetDataLossOK()
Definition: newmat.h:150
int nrows() const
Definition: newmat.h:499
GeneralMatrix * gm2
Definition: newmat.h:1440
static unsigned long Select
Definition: newmat.h:1934
static unsigned long Select
Definition: newmat.h:2028
Real determinant(const BaseMatrix &B)
Definition: newmat.h:2090
void operator=(Real f)
Definition: newmat.h:859
void operator+=(Real f)
Definition: newmat.h:746
int operator+() const
Definition: newmat.h:151
void cleanup()
set length to zero
Definition: newmat.h:1884
void operator=(const GetSubMatrix &m)
Definition: newmat.h:1784
Covergence failure exception.
Definition: newmat.h:1922
void ChangeSign()
Definition: newmat.h:57
DiagonalMatrix()
Definition: newmat.h:900
Row vector.
Definition: newmat.h:953
void operator=(Real f)
Definition: newmat.h:1018
ColedMatrix AsColumn() const
Definition: newmat.h:2142
static unsigned long Select
Definition: newmat.h:1993
static int nTypes()
Definition: newmat.h:136
virtual void Solver(MatrixColX &, const MatrixColX &)
Definition: newmat.h:537
void operator-=(Real f)
Definition: newmat.h:841
Real MinimumAbsoluteValue(const BaseMatrix &B)
Definition: newmat.h:2115
Real MaximumAbsoluteValue1(int &i) const
Definition: newmat.h:357
Real sum_square() const
Definition: newmat.h:1126
void Protect()
Definition: newmat.h:509
int Lower() const
Definition: newmat.h:218
int storage
Definition: newmat.h:453
int * indx
Definition: newmat.h:1061
static unsigned long Select
Definition: newmat.h:1942
Column vector.
Definition: newmat.h:1008
void swap(BandMatrix &gm)
Definition: newmat4.cpp:1292
RowVector()
Definition: newmat.h:957
MatrixType operator+(MatrixType mt) const
Definition: newmat.h:152
void operator-=(const DiagonalMatrix &M)
Definition: newmat.h:944
GeneralMatrix * gm1
Definition: newmat.h:1438
virtual void resize_keep(int, int)
Definition: newmat4.cpp:432
Real MinimumAbsoluteValue() const
Definition: newmat.h:363
The classes for matrices that can contain data are derived from this.
Definition: newmat.h:447
void operator=(Real f)
Definition: newmat.h:1110
MultipliedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1441
void operator+=(const DiagonalMatrix &M)
Definition: newmat.h:943
bool IsZero(const BaseMatrix &A)
Definition: newmat.h:2053
GeneralMatrix * MakeSolver()
Definition: newmat.h:1220
virtual GeneralMatrix * Image() const
Definition: newmat4.cpp:1068
~NegatedMatrix()
Definition: newmat.h:1639
void swap(UpperTriangularMatrix &gm)
Definition: newmat.h:842
~nricMatrix()
Definition: newmat.h:740
Cannot convert to vector exception.
Definition: newmat.h:1972
static unsigned long Select
Definition: newmat.h:2001
void operator=(const LowerTriangularMatrix &m)
Definition: newmat.h:860
void operator=(Real f)
Definition: newmat.h:1177
#define NEW_DELETE(Class)
Definition: myexcept.h:350
virtual Real sum() const
Definition: newmat8.cpp:452
void ReSize(int n, int ubw)
Definition: newmat.h:1188
~ShiftedMatrix()
Definition: newmat.h:1590
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:1191
~GenericMatrix()
Definition: newmat.h:1419
int col_skip
Definition: newmat.h:1765
void ReSize(int m)
Definition: newmat.h:833
Real sum_absolute_value() const
Definition: newmat.h:1128
~ScaledMatrix()
Definition: newmat.h:1621
SubtractedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1566
MatrixType AddEqualEl() const
< add constant to matrix
Definition: newmat.h:172
A matrix which can be of any GeneralMatrix type.
Definition: newmat.h:1397
void resize_keep(int m, int n)
Definition: newmat.h:734
TransposedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1649
GeneralMatrix * Evaluate(MatrixType=MatrixTypeUnSp)
Definition: newmat5.cpp:107
virtual void SetParameters(const GeneralMatrix *)
Definition: newmat.h:566
GeneralMatrix * MakeSolver()
Definition: newmat.h:870
GeneralMatrix * gm
Definition: newmat.h:1582
RowVector(ArrayLengthSpecifier n)
Definition: newmat.h:959
bool IsSym
Definition: newmat.h:1767
GetSubMatrix Rows(int f, int l) const
Definition: newmat.h:2151
void operator=(Real f)
Definition: newmat.h:963
void release()
Definition: newmat.h:517
MatrixInput operator<<(double)
Definition: newmat5.cpp:407
Real maximum_absolute_value(const BaseMatrix &B)
Definition: newmat.h:2109
Identity matrix.
Definition: newmat.h:1350
Let matrix simulate a C type const two dimensional array.
Definition: newmat.h:1902
bool operator==(MatrixType t) const
Definition: newmat.h:165
void ReSize(int m)
Definition: newmat.h:695
ReturnMatrix CrossProductRows(const Matrix &A, const Matrix &B)
Definition: newmat.h:2064
void ReSize(int n)
Definition: newmat.h:1381
Symmetric matrix.
Definition: newmat.h:753
void ReSize(int i, bool keep=false)
change length, keep data if keep = true
Definition: newmat.h:1880
Real log_value() const
log of the absolute value
Definition: newmat.h:60
InvertedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1674
const Real * data() const
Definition: newmat.h:503
void operator<<(const BaseMatrix &X)
Definition: newmat.h:728
void operator-=(Real f)
Definition: newmat.h:1050
Real Maximum() const
Definition: newmat.h:371
~Matrix()
Definition: newmat.h:630
virtual LogAndSign log_determinant() const
Definition: newmat8.cpp:690


kni
Author(s): Martin Günther
autogenerated on Fri Jun 7 2019 22:06:45