OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
newmat.h
Go to the documentation of this file.
1 //$$ newmat.h definition file for new version of matrix package
2 
3 // Copyright (C) 1991,2,3,4,7,2000,2,3: R B Davies
4 
5 #ifndef NEWMAT_LIB
6 #define NEWMAT_LIB 0
7 
8 #include <ossim/matrix/include.h>
9 
10 #include <ossim/matrix/myexcept.h>
11 
12 
13 #ifdef use_namespace
14 namespace NEWMAT { using namespace RBD_COMMON; }
15 namespace RBD_LIBRARIES { using namespace NEWMAT; }
16 namespace NEWMAT {
17 #endif
18 
19 //#define DO_REPORT // to activate REPORT
20 
21 #ifdef NO_LONG_NAMES
22 #define UpperTriangularMatrix UTMatrix
23 #define LowerTriangularMatrix LTMatrix
24 #define SymmetricMatrix SMatrix
25 #define DiagonalMatrix DMatrix
26 #define BandMatrix BMatrix
27 #define UpperBandMatrix UBMatrix
28 #define LowerBandMatrix LBMatrix
29 #define SymmetricBandMatrix SBMatrix
30 #define BandLUMatrix BLUMatrix
31 #endif
32 
33 // ************************** general utilities ****************************/
34 
35 class GeneralMatrix;
36 
37 void MatrixErrorNoSpace(const void*); // no space handler
38 
40 // Return from LogDeterminant function
41 // - value of the log plus the sign (+, - or 0)
42 {
44  int sign;
45 public:
46  LogAndSign() { log_value=0.0; sign=1; }
48  void operator*=(Real);
49  void PowEq(int k); // raise to power of k
50  void ChangeSign() { sign = -sign; }
51  Real LogValue() const { return log_value; }
52  int Sign() const { return sign; }
53  Real Value() const;
55 };
56 
57 // the following class is for counting the number of times a piece of code
58 // is executed. It is used for locating any code not executed by test
59 // routines. Use turbo GREP locate all places this code is called and
60 // check which ones are not accessed.
61 // Somewhat implementation dependent as it relies on "cout" still being
62 // present when ExeCounter objects are destructed.
63 
64 #ifdef DO_REPORT
65 
66 class ExeCounter
67 {
68  int line; // code line number
69  int fileid; // file identifier
70  long nexe; // number of executions
71  static int nreports; // number of reports
72 public:
73  ExeCounter(int,int);
74  void operator++() { nexe++; }
75  ~ExeCounter(); // prints out reports
76 };
77 
78 #endif
79 
80 
81 // ************************** class MatrixType *****************************/
82 
83 // Is used for finding the type of a matrix resulting from the binary operations
84 // +, -, * and identifying what conversions are permissible.
85 // This class must be updated when new matrix types are added.
86 
87 class GeneralMatrix; // defined later
88 class BaseMatrix; // defined later
89 class MatrixInput; // defined later
90 
92 {
93 public:
94  enum Attribute { Valid = 1,
95  Diagonal = 2, // order of these is important
96  Symmetric = 4,
97  Band = 8,
98  Lower = 16,
99  Upper = 32,
100  Square = 64,
101  Skew = 128,
102  LUDeco = 256,
103  Ones = 512 };
104 
105  enum { US = 0,
106  UT = Valid + Upper + Square,
107  LT = Valid + Lower + Square,
108  Rt = Valid,
109  Sq = Valid + Square,
110  Sm = Valid + Symmetric + Square,
111  Sk = Valid + Skew + Square,
112  Dg = Valid + Diagonal + Band + Lower + Upper + Symmetric
113  + Square,
114  Id = Valid + Diagonal + Band + Lower + Upper + Symmetric
115  + Square + Ones,
116  RV = Valid, // do not separate out
117  CV = Valid, // vectors
118  BM = Valid + Band + Square,
119  UB = Valid + Band + Upper + Square,
120  LB = Valid + Band + Lower + Square,
121  SB = Valid + Band + Symmetric + Square,
122  Ct = Valid + LUDeco + Square,
123  BC = Valid + Band + LUDeco + Square,
124  Mask = ~Square
125  };
126 
127 
128  static int nTypes() { return 12; } // number of different types
129  // exclude Ct, US, BC
130 public:
132  bool DataLossOK; // true if data loss is OK when
133  // this represents a destination
134 public:
135  MatrixType () : DataLossOK(false) {}
136  MatrixType (int i) : attribute(i), DataLossOK(false) {}
137  MatrixType (int i, bool dlok) : attribute(i), DataLossOK(dlok) {}
138  MatrixType (const MatrixType& mt)
139  : attribute(mt.attribute), DataLossOK(mt.DataLossOK) {}
140  void operator=(const MatrixType& mt)
141  { attribute = mt.attribute; DataLossOK = mt.DataLossOK; }
142  void SetDataLossOK() { DataLossOK = true; }
143  int operator+() const { return attribute; }
145  { return MatrixType(attribute & mt.attribute); }
146  MatrixType operator*(const MatrixType&) const;
147  MatrixType SP(const MatrixType&) const;
148  MatrixType KP(const MatrixType&) const;
149  MatrixType operator|(const MatrixType& mt) const
150  { return MatrixType(attribute & mt.attribute & Valid); }
151  MatrixType operator&(const MatrixType& mt) const
152  { return MatrixType(attribute & mt.attribute & Valid); }
153  bool operator>=(MatrixType mt) const
154  { return ( attribute & ~mt.attribute & Mask ) == 0; }
155  bool operator<(MatrixType mt) const // for MS Visual C++ 4
156  { return ( attribute & ~mt.attribute & Mask ) != 0; }
157  bool operator==(MatrixType t) const
158  { return (attribute == t.attribute); }
159  bool operator!=(MatrixType t) const
160  { return (attribute != t.attribute); }
161  bool operator!() const { return (attribute & Valid) == 0; }
162  MatrixType i() const; // type of inverse
163  MatrixType t() const; // type of transpose
164  MatrixType AddEqualEl() const // Add constant to matrix
165  { return MatrixType(attribute & (Valid + Symmetric + Square)); }
166  MatrixType MultRHS() const; // type for rhs of multiply
167  MatrixType sub() const // type of submatrix
168  { return MatrixType(attribute & Valid); }
169  MatrixType ssub() const // type of sym submatrix
170  { return MatrixType(attribute); } // not for selection matrix
171  GeneralMatrix* New() const; // new matrix of given type
172  GeneralMatrix* New(int,int,BaseMatrix*) const;
173  // new matrix of given type
174  const char* Value() const; // to print type
175  friend bool Rectangular(MatrixType a, MatrixType b, MatrixType c);
176  friend bool Compare(const MatrixType&, MatrixType&);
177  // compare and check conv.
178  bool IsBand() const { return (attribute & Band) != 0; }
179  bool IsDiagonal() const { return (attribute & Diagonal) != 0; }
180  bool IsSymmetric() const { return (attribute & Symmetric) != 0; }
181  bool CannotConvert() const { return (attribute & LUDeco) != 0; }
182  // used by operator==
184 };
185 
186 
187 // *********************** class MatrixBandWidth ***********************/
188 
190 {
191 public:
192  int lower;
193  int upper;
194  MatrixBandWidth(const int l, const int u) : lower(l), upper (u) {}
195  MatrixBandWidth(const int i) : lower(i), upper(i) {}
198  MatrixBandWidth minimum(const MatrixBandWidth&) const;
199  MatrixBandWidth t() const { return MatrixBandWidth(upper,lower); }
200  bool operator==(const MatrixBandWidth& bw) const
201  { return (lower == bw.lower) && (upper == bw.upper); }
202  bool operator!=(const MatrixBandWidth& bw) const { return !operator==(bw); }
203  int Upper() const { return upper; }
204  int Lower() const { return lower; }
206 };
207 
208 
209 // ********************* Array length specifier ************************/
210 
211 // This class is introduced to avoid constructors such as
212 // ColumnVector(int)
213 // being used for conversions
214 
216 {
217  int value;
218 public:
219  int Value() const { return value; }
220  ArrayLengthSpecifier(int l) : value(l) {}
221 };
222 
223 // ************************* Matrix routines ***************************/
224 
225 
226 class MatrixRowCol; // defined later
227 class MatrixRow;
228 class MatrixCol;
229 class MatrixColX;
230 
231 class GeneralMatrix; // defined later
232 class AddedMatrix;
233 class MultipliedMatrix;
234 class SubtractedMatrix;
235 class SPMatrix;
236 class KPMatrix;
237 class ConcatenatedMatrix;
238 class StackedMatrix;
239 class SolvedMatrix;
240 class ShiftedMatrix;
241 class NegShiftedMatrix;
242 class ScaledMatrix;
243 class TransposedMatrix;
244 class ReversedMatrix;
245 class NegatedMatrix;
246 class InvertedMatrix;
247 class RowedMatrix;
248 class ColedMatrix;
249 class DiagedMatrix;
250 class MatedMatrix;
251 class GetSubMatrix;
252 class ReturnMatrix;
253 class Matrix;
254 class SquareMatrix;
255 class nricMatrix;
256 class RowVector;
257 class ColumnVector;
258 class SymmetricMatrix;
261 class DiagonalMatrix;
262 class CroutMatrix;
263 class BandMatrix;
264 class LowerBandMatrix;
265 class UpperBandMatrix;
266 class SymmetricBandMatrix;
268 class GenericMatrix;
269 
270 
271 #define MatrixTypeUnSp 0
272 //static MatrixType MatrixTypeUnSp(MatrixType::US);
273 // // AT&T needs this
274 
275 class OSSIM_DLL BaseMatrix : public RBD_COMMON::Janitor // base of all matrix classes
276 {
277 protected:
278  virtual int search(const BaseMatrix*) const = 0;
279  // count number of times matrix
280  // is referred to
281 
282 public:
283  virtual GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp) = 0;
284  // evaluate temporary
285  // for old version of G++
286  // virtual GeneralMatrix* Evaluate(MatrixType mt) = 0;
287  // GeneralMatrix* Evaluate() { return Evaluate(MatrixTypeUnSp); }
288  AddedMatrix operator+(const BaseMatrix&) const; // results of operations
289  MultipliedMatrix operator*(const BaseMatrix&) const;
290  SubtractedMatrix operator-(const BaseMatrix&) const;
291  ConcatenatedMatrix operator|(const BaseMatrix&) const;
292  StackedMatrix operator&(const BaseMatrix&) const;
294  ScaledMatrix operator*(Real) const;
295  ScaledMatrix operator/(Real) const;
297  TransposedMatrix t() const;
298 // TransposedMatrix t;
299  NegatedMatrix operator-() const; // change sign of elements
300  ReversedMatrix Reverse() const;
301  InvertedMatrix i() const;
302 // InvertedMatrix i;
303  RowedMatrix AsRow() const;
304  ColedMatrix AsColumn() const;
305  DiagedMatrix AsDiagonal() const;
306  MatedMatrix AsMatrix(int,int) const;
307  GetSubMatrix SubMatrix(int,int,int,int) const;
308  GetSubMatrix SymSubMatrix(int,int) const;
309  GetSubMatrix Row(int) const;
310  GetSubMatrix Rows(int,int) const;
311  GetSubMatrix Column(int) const;
312  GetSubMatrix Columns(int,int) const;
313  Real AsScalar() const; // conversion of 1 x 1 matrix
314  virtual LogAndSign LogDeterminant() const;
315  Real Determinant() const;
316  virtual Real SumSquare() const;
317  Real NormFrobenius() const;
318  virtual Real SumAbsoluteValue() const;
319  virtual Real Sum() const;
320  virtual Real MaximumAbsoluteValue() const;
321  virtual Real MaximumAbsoluteValue1(int& i) const;
322  virtual Real MaximumAbsoluteValue2(int& i, int& j) const;
323  virtual Real MinimumAbsoluteValue() const;
324  virtual Real MinimumAbsoluteValue1(int& i) const;
325  virtual Real MinimumAbsoluteValue2(int& i, int& j) const;
326  virtual Real Maximum() const;
327  virtual Real Maximum1(int& i) const;
328  virtual Real Maximum2(int& i, int& j) const;
329  virtual Real Minimum() const;
330  virtual Real Minimum1(int& i) const;
331  virtual Real Minimum2(int& i, int& j) const;
332  virtual Real Trace() const;
333  Real Norm1() const;
334  Real NormInfinity() const;
335  virtual MatrixBandWidth BandWidth() const; // bandwidths of band matrix
336  virtual void CleanUp() {} // to clear store
337  void IEQND() const; // called by ineq. ops
338 // virtual ReturnMatrix Reverse() const; // reverse order of elements
339 //protected:
340 // BaseMatrix() : t(this), i(this) {}
341 
342  friend class GeneralMatrix;
343  friend class Matrix;
344  friend class SquareMatrix;
345  friend class nricMatrix;
346  friend class RowVector;
347  friend class ColumnVector;
348  friend class SymmetricMatrix;
349  friend class UpperTriangularMatrix;
350  friend class LowerTriangularMatrix;
351  friend class DiagonalMatrix;
352  friend class CroutMatrix;
353  friend class BandMatrix;
354  friend class LowerBandMatrix;
355  friend class UpperBandMatrix;
356  friend class SymmetricBandMatrix;
357  friend class AddedMatrix;
358  friend class MultipliedMatrix;
359  friend class SubtractedMatrix;
360  friend class SPMatrix;
361  friend class KPMatrix;
362  friend class ConcatenatedMatrix;
363  friend class StackedMatrix;
364  friend class SolvedMatrix;
365  friend class ShiftedMatrix;
366  friend class NegShiftedMatrix;
367  friend class ScaledMatrix;
368  friend class TransposedMatrix;
369  friend class ReversedMatrix;
370  friend class NegatedMatrix;
371  friend class InvertedMatrix;
372  friend class RowedMatrix;
373  friend class ColedMatrix;
374  friend class DiagedMatrix;
375  friend class MatedMatrix;
376  friend class GetSubMatrix;
377  friend class ReturnMatrix;
378  friend class LinearEquationSolver;
379  friend class GenericMatrix;
381 };
382 
383 
384 // ***************************** working classes **************************/
385 
386 class OSSIM_DLL GeneralMatrix : public BaseMatrix // declarable matrix types
387 {
388  virtual GeneralMatrix* Image() const; // copy of matrix
389 protected:
390  int tag; // shows whether can reuse
391  int nrows, ncols; // dimensions
392  int storage; // total store required
393  Real* store; // point to store (0=not set)
394  GeneralMatrix(); // initialise with no store
395  GeneralMatrix(ArrayLengthSpecifier); // constructor getting store
396  void Add(GeneralMatrix*, Real); // sum of GM and Real
397  void Add(Real); // add Real to this
398  void NegAdd(GeneralMatrix*, Real); // Real - GM
399  void NegAdd(Real); // this = this - Real
400  void Multiply(GeneralMatrix*, Real); // product of GM and Real
401  void Multiply(Real); // multiply this by Real
402  void Negate(GeneralMatrix*); // change sign
403  void Negate(); // change sign
404  void ReverseElements(); // internal reverse of elements
405  void ReverseElements(GeneralMatrix*); // reverse order of elements
406  void operator=(Real); // set matrix to constant
407  Real* GetStore(); // get store or copy
408  GeneralMatrix* BorrowStore(GeneralMatrix*, MatrixType);
409  // temporarily access store
410  void GetMatrix(const GeneralMatrix*); // used by = and initialise
411  void Eq(const BaseMatrix&, MatrixType); // used by =
412  void Eq(const GeneralMatrix&); // version with no conversion
413  void Eq(const BaseMatrix&, MatrixType, bool);// used by <<
414  void Eq2(const BaseMatrix&, MatrixType); // cut down version of Eq
415  int search(const BaseMatrix*) const;
416  virtual GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
417  void CheckConversion(const BaseMatrix&); // check conversion OK
418  void ReSize(int, int, int); // change dimensions
419  virtual short SimpleAddOK(const GeneralMatrix* /* gm */ ) { return 0; }
420  // see bandmat.cpp for explanation
421  virtual void MiniCleanUp() { store = 0; storage = 0; nrows = 0; ncols = 0; tag = -1;}
422  // CleanUp when the data array has already been deleted
423  void PlusEqual(const GeneralMatrix& gm);
424  void MinusEqual(const GeneralMatrix& gm);
425  void PlusEqual(Real f);
426  void MinusEqual(Real f);
427 public:
429  virtual MatrixType Type() const = 0; // type of a matrix
430  int Nrows() const { return nrows; } // get dimensions
431  int Ncols() const { return ncols; }
432  int Storage() const { return storage; }
433  Real* Store() const { return store; }
434  virtual ~GeneralMatrix(); // delete store if set
435  void tDelete(); // delete if tag permits
436  bool reuse(); // true if tag allows reuse
437  void Protect() { tag=-1; } // cannot delete or reuse
438  int Tag() const { return tag; }
439  bool IsZero() const; // test matrix has all zeros
440  void Release() { tag=1; } // del store after next use
441  void Release(int t) { tag=t; } // del store after t accesses
442  void ReleaseAndDelete() { tag=0; } // delete matrix after use
443  void operator<<(const Real*); // assignment from an array
444  void operator<<(const int*); // assignment from an array
445  void operator<<(const BaseMatrix& X)
446  { Eq(X,this->Type(),true); } // = without checking type
447  void Inject(const GeneralMatrix&); // copy stored els only
448  void operator+=(const BaseMatrix&);
449  void operator-=(const BaseMatrix&);
450  void operator*=(const BaseMatrix&);
451  void operator|=(const BaseMatrix&);
452  void operator&=(const BaseMatrix&);
453  void operator+=(Real);
454  void operator-=(Real r) { operator+=(-r); }
455  void operator*=(Real);
456  void operator/=(Real r) { operator*=(1.0/r); }
457  virtual GeneralMatrix* MakeSolver(); // for solving
458  virtual void Solver(MatrixColX&, const MatrixColX&) {}
459  virtual void GetRow(MatrixRowCol&) = 0; // Get matrix row
460  virtual void RestoreRow(MatrixRowCol&) {} // Restore matrix row
461  virtual void NextRow(MatrixRowCol&); // Go to next row
462  virtual void GetCol(MatrixRowCol&) = 0; // Get matrix col
463  virtual void GetCol(MatrixColX&) = 0; // Get matrix col
464  virtual void RestoreCol(MatrixRowCol&) {} // Restore matrix col
465  virtual void RestoreCol(MatrixColX&) {} // Restore matrix col
466  virtual void NextCol(MatrixRowCol&); // Go to next col
467  virtual void NextCol(MatrixColX&); // Go to next col
468  Real SumSquare() const;
469  Real SumAbsoluteValue() const;
470  Real Sum() const;
471  Real MaximumAbsoluteValue1(int& i) const;
472  Real MinimumAbsoluteValue1(int& i) const;
473  Real Maximum1(int& i) const;
474  Real Minimum1(int& i) const;
475  Real MaximumAbsoluteValue() const;
476  Real MaximumAbsoluteValue2(int& i, int& j) const;
477  Real MinimumAbsoluteValue() const;
478  Real MinimumAbsoluteValue2(int& i, int& j) const;
479  Real Maximum() const;
480  Real Maximum2(int& i, int& j) const;
481  Real Minimum() const;
482  Real Minimum2(int& i, int& j) const;
483  LogAndSign LogDeterminant() const;
484  virtual bool IsEqual(const GeneralMatrix&) const;
485  // same type, same values
486  void CheckStore() const; // check store is non-zero
487  virtual void SetParameters(const GeneralMatrix*) {}
488  // set parameters in GetMatrix
489  operator ReturnMatrix() const; // for building a ReturnMatrix
490  ReturnMatrix ForReturn() const;
491  virtual bool SameStorageType(const GeneralMatrix& A) const;
492  virtual void ReSizeForAdd(const GeneralMatrix& A, const GeneralMatrix& B);
493  virtual void ReSizeForSP(const GeneralMatrix& A, const GeneralMatrix& B);
494  virtual void ReSize(const GeneralMatrix& A);
495  MatrixInput operator<<(Real); // for loading a list
496  MatrixInput operator<<(int f);
497 // ReturnMatrix Reverse() const; // reverse order of elements
498  void CleanUp(); // to clear store
499 
500  friend class Matrix;
501  friend class SquareMatrix;
502  friend class nricMatrix;
503  friend class SymmetricMatrix;
504  friend class UpperTriangularMatrix;
505  friend class LowerTriangularMatrix;
506  friend class DiagonalMatrix;
507  friend class CroutMatrix;
508  friend class RowVector;
509  friend class ColumnVector;
510  friend class BandMatrix;
511  friend class LowerBandMatrix;
512  friend class UpperBandMatrix;
513  friend class SymmetricBandMatrix;
514  friend class BaseMatrix;
515  friend class AddedMatrix;
516  friend class MultipliedMatrix;
517  friend class SubtractedMatrix;
518  friend class SPMatrix;
519  friend class KPMatrix;
520  friend class ConcatenatedMatrix;
521  friend class StackedMatrix;
522  friend class SolvedMatrix;
523  friend class ShiftedMatrix;
524  friend class NegShiftedMatrix;
525  friend class ScaledMatrix;
526  friend class TransposedMatrix;
527  friend class ReversedMatrix;
528  friend class NegatedMatrix;
529  friend class InvertedMatrix;
530  friend class RowedMatrix;
531  friend class ColedMatrix;
532  friend class DiagedMatrix;
533  friend class MatedMatrix;
534  friend class GetSubMatrix;
535  friend class ReturnMatrix;
536  friend class LinearEquationSolver;
537  friend class GenericMatrix;
539 };
540 
541 
542 
543 class OSSIM_DLL Matrix : public GeneralMatrix // usual rectangular matrix
544 {
545  GeneralMatrix* Image() const; // copy of matrix
546 public:
548  ~Matrix() {}
549  Matrix(int, int); // standard declaration
550  Matrix(const BaseMatrix&); // evaluate BaseMatrix
551  void operator=(const BaseMatrix&);
553  void operator=(const Matrix& m) { Eq(m); }
554  MatrixType Type() const;
555  Real& operator()(int, int); // access element
556  Real& element(int, int); // access element
557  Real operator()(int, int) const; // access element
558  Real element(int, int) const; // access element
559 #ifdef SETUP_C_SUBSCRIPTS
560  Real* operator[](int m) { return store+m*ncols; }
561  const Real* operator[](int m) const { return store+m*ncols; }
562 #endif
563  Matrix(const Matrix& gm):GeneralMatrix(gm) { GetMatrix(&gm); }
564  GeneralMatrix* MakeSolver();
565  Real Trace() const;
566  void GetRow(MatrixRowCol&);
567  void GetCol(MatrixRowCol&);
568  void GetCol(MatrixColX&);
569  void RestoreCol(MatrixRowCol&);
570  void RestoreCol(MatrixColX&);
571  void NextRow(MatrixRowCol&);
572  void NextCol(MatrixRowCol&);
573  void NextCol(MatrixColX&);
574  virtual void ReSize(int,int); // change dimensions
575  // virtual so we will catch it being used in a vector called as a matrix
576  void ReSize(const GeneralMatrix& A);
577  Real MaximumAbsoluteValue2(int& i, int& j) const;
578  Real MinimumAbsoluteValue2(int& i, int& j) const;
579  Real Maximum2(int& i, int& j) const;
580  Real Minimum2(int& i, int& j) const;
581  void operator+=(const Matrix& M) { PlusEqual(M); }
582  void operator-=(const Matrix& M) { MinusEqual(M); }
585  friend OSSIM_DLL Real DotProduct(const Matrix& A, const Matrix& B);
587 };
588 
589 class OSSIM_DLL SquareMatrix : public Matrix // square matrix
590 {
591  GeneralMatrix* Image() const; // copy of matrix
592 public:
595  SquareMatrix(ArrayLengthSpecifier); // standard declaration
596  SquareMatrix(const BaseMatrix&); // evaluate BaseMatrix
597  void operator=(const BaseMatrix&);
599  void operator=(const SquareMatrix& m) { Eq(m); }
600  void operator=(const Matrix& m);
601  MatrixType Type() const;
602  SquareMatrix(const SquareMatrix& gm):Matrix(gm) { GetMatrix(&gm); }
603  SquareMatrix(const Matrix& gm);
604  void ReSize(int); // change dimensions
605  virtual void ReSize(int,int); // change dimensions
606  // virtual so we will catch it being used in a vector called as a matrix
607  void ReSize(const GeneralMatrix& A);
608  void operator+=(const Matrix& M) { PlusEqual(M); }
609  void operator-=(const Matrix& M) { MinusEqual(M); }
613 };
614 
615 class OSSIM_DLL nricMatrix : public Matrix // for use with Numerical
616  // Recipes in C
617 {
618  GeneralMatrix* Image() const; // copy of matrix
619  Real** row_pointer; // points to rows
620  void MakeRowPointer(); // build rowpointer
621  void DeleteRowPointer();
622 public:
624  nricMatrix(int m, int n) // standard declaration
625  : Matrix(m,n) { MakeRowPointer(); }
626  nricMatrix(const BaseMatrix& bm) // evaluate BaseMatrix
627  : Matrix(bm) { MakeRowPointer(); }
628  void operator=(const BaseMatrix& bm)
629  { DeleteRowPointer(); Matrix::operator=(bm); MakeRowPointer(); }
631  void operator=(const nricMatrix& m)
632  { DeleteRowPointer(); Eq(m); MakeRowPointer(); }
633  void operator<<(const BaseMatrix& X)
634  { DeleteRowPointer(); Eq(X,this->Type(),true); MakeRowPointer(); }
635  nricMatrix(const nricMatrix& gm):Matrix(gm) { GetMatrix(&gm); MakeRowPointer(); }
636  void ReSize(int m, int n) // change dimensions
637  { DeleteRowPointer(); Matrix::ReSize(m,n); MakeRowPointer(); }
638  void ReSize(const GeneralMatrix& A);
639  ~nricMatrix() { DeleteRowPointer(); }
640  Real** nric() const { CheckStore(); return row_pointer-1; }
641  void CleanUp(); // to clear store
642  void MiniCleanUp();
643  void operator+=(const Matrix& M) { PlusEqual(M); }
644  void operator-=(const Matrix& M) { MinusEqual(M); }
648 };
649 
651 {
652  GeneralMatrix* Image() const; // copy of matrix
653 public:
657  SymmetricMatrix(const BaseMatrix&);
658  void operator=(const BaseMatrix&);
660  void operator=(const SymmetricMatrix& m) { Eq(m); }
661  Real& operator()(int, int); // access element
662  Real& element(int, int); // access element
663  Real operator()(int, int) const; // access element
664  Real element(int, int) const; // access element
665 #ifdef SETUP_C_SUBSCRIPTS
666  Real* operator[](int m) { return store+(m*(m+1))/2; }
667  const Real* operator[](int m) const { return store+(m*(m+1))/2; }
668 #endif
669  MatrixType Type() const;
670  SymmetricMatrix(const SymmetricMatrix& gm):GeneralMatrix(gm) { GetMatrix(&gm); }
671  Real SumSquare() const;
672  Real SumAbsoluteValue() const;
673  Real Sum() const;
674  Real Trace() const;
675  void GetRow(MatrixRowCol&);
676  void GetCol(MatrixRowCol&);
677  void GetCol(MatrixColX&);
679  void RestoreCol(MatrixColX&);
681  void ReSize(int); // change dimensions
682  void ReSize(const GeneralMatrix& A);
683  void operator+=(const SymmetricMatrix& M) { PlusEqual(M); }
684  void operator-=(const SymmetricMatrix& M) { MinusEqual(M); }
688 };
689 
691 {
692  GeneralMatrix* Image() const; // copy of matrix
693 public:
697  void operator=(const BaseMatrix&);
698  void operator=(const UpperTriangularMatrix& m) { Eq(m); }
700  UpperTriangularMatrix(const UpperTriangularMatrix& gm):GeneralMatrix(gm) { GetMatrix(&gm); }
702  Real& operator()(int, int); // access element
703  Real& element(int, int); // access element
704  Real operator()(int, int) const; // access element
705  Real element(int, int) const; // access element
706 #ifdef SETUP_C_SUBSCRIPTS
707  Real* operator[](int m) { return store+m*ncols-(m*(m+1))/2; }
708  const Real* operator[](int m) const { return store+m*ncols-(m*(m+1))/2; }
709 #endif
710  MatrixType Type() const;
711  GeneralMatrix* MakeSolver() { return this; } // for solving
712  void Solver(MatrixColX&, const MatrixColX&);
713  LogAndSign LogDeterminant() const;
714  Real Trace() const;
715  void GetRow(MatrixRowCol&);
716  void GetCol(MatrixRowCol&);
717  void GetCol(MatrixColX&);
718  void RestoreCol(MatrixRowCol&);
720  void NextRow(MatrixRowCol&);
721  void ReSize(int); // change dimensions
722  void ReSize(const GeneralMatrix& A);
723  MatrixBandWidth BandWidth() const;
724  void operator+=(const UpperTriangularMatrix& M) { PlusEqual(M); }
725  void operator-=(const UpperTriangularMatrix& M) { MinusEqual(M); }
729 };
730 
732 {
733  GeneralMatrix* Image() const; // copy of matrix
734 public:
738  LowerTriangularMatrix(const LowerTriangularMatrix& gm):GeneralMatrix(gm) { GetMatrix(&gm); }
740  void operator=(const BaseMatrix&);
742  void operator=(const LowerTriangularMatrix& m) { Eq(m); }
743  Real& operator()(int, int); // access element
744  Real& element(int, int); // access element
745  Real operator()(int, int) const; // access element
746  Real element(int, int) const; // access element
747 #ifdef SETUP_C_SUBSCRIPTS
748  Real* operator[](int m) { return store+(m*(m+1))/2; }
749  const Real* operator[](int m) const { return store+(m*(m+1))/2; }
750 #endif
751  MatrixType Type() const;
752  GeneralMatrix* MakeSolver() { return this; } // for solving
753  void Solver(MatrixColX&, const MatrixColX&);
754  LogAndSign LogDeterminant() const;
755  Real Trace() const;
756  void GetRow(MatrixRowCol&);
757  void GetCol(MatrixRowCol&);
758  void GetCol(MatrixColX&);
759  void RestoreCol(MatrixRowCol&);
761  void NextRow(MatrixRowCol&);
762  void ReSize(int); // change dimensions
763  void ReSize(const GeneralMatrix& A);
764  MatrixBandWidth BandWidth() const;
765  void operator+=(const LowerTriangularMatrix& M) { PlusEqual(M); }
766  void operator-=(const LowerTriangularMatrix& M) { MinusEqual(M); }
770 };
771 
773 {
774  GeneralMatrix* Image() const; // copy of matrix
775 public:
779  DiagonalMatrix(const BaseMatrix&);
780  DiagonalMatrix(const DiagonalMatrix& gm):GeneralMatrix(gm) { GetMatrix(&gm); }
781  void operator=(const BaseMatrix&);
783  void operator=(const DiagonalMatrix& m) { Eq(m); }
784  Real& operator()(int, int); // access element
785  Real& operator()(int); // access element
786  Real operator()(int, int) const; // access element
787  Real operator()(int) const;
788  Real& element(int, int); // access element
789  Real& element(int); // access element
790  Real element(int, int) const; // access element
791  Real element(int) const; // access element
792 #ifdef SETUP_C_SUBSCRIPTS
793  Real& operator[](int m) { return store[m]; }
794  const Real& operator[](int m) const { return store[m]; }
795 #endif
796  MatrixType Type() const;
797 
798  LogAndSign LogDeterminant() const;
799  Real Trace() const;
800  void GetRow(MatrixRowCol&);
801  void GetCol(MatrixRowCol&);
802  void GetCol(MatrixColX&);
803  void NextRow(MatrixRowCol&);
804  void NextCol(MatrixRowCol&);
805  void NextCol(MatrixColX&);
806  GeneralMatrix* MakeSolver() { return this; } // for solving
807  void Solver(MatrixColX&, const MatrixColX&);
809  void ReSize(int); // change dimensions
810  void ReSize(const GeneralMatrix& A);
811  Real* nric() const
812  { CheckStore(); return store-1; } // for use by NRIC
813  MatrixBandWidth BandWidth() const;
814 // ReturnMatrix Reverse() const; // reverse order of elements
815  void operator+=(const DiagonalMatrix& M) { PlusEqual(M); }
816  void operator-=(const DiagonalMatrix& M) { MinusEqual(M); }
820 };
821 
822 class OSSIM_DLL RowVector : public Matrix
823 {
824  GeneralMatrix* Image() const; // copy of matrix
825 public:
826  RowVector():Matrix() { nrows = 1; }
829  RowVector(const BaseMatrix&);
830  RowVector(const RowVector& gm):Matrix(gm) { GetMatrix(&gm); }
831  void operator=(const BaseMatrix&);
833  void operator=(const RowVector& m) { Eq(m); }
834  Real& operator()(int); // access element
835  Real& element(int); // access element
836  Real operator()(int) const; // access element
837  Real element(int) const; // access element
838 #ifdef SETUP_C_SUBSCRIPTS
839  Real& operator[](int m) { return store[m]; }
840  const Real& operator[](int m) const { return store[m]; }
841 #endif
842  MatrixType Type() const;
843  void GetCol(MatrixRowCol&);
844  void GetCol(MatrixColX&);
845  void NextCol(MatrixRowCol&);
846  void NextCol(MatrixColX&);
848  void RestoreCol(MatrixColX& c);
850  void ReSize(int); // change dimensions
851  void ReSize(int,int); // in case access is matrix
852  void ReSize(const GeneralMatrix& A);
853  Real* nric() const
854  { CheckStore(); return store-1; } // for use by NRIC
855  void CleanUp(); // to clear store
856  void MiniCleanUp() { store = 0; storage = 0; nrows = 1; ncols = 0; tag = -1; }
857  // friend ReturnMatrix GetMatrixRow(Matrix& A, int row);
858  void operator+=(const Matrix& M) { PlusEqual(M); }
859  void operator-=(const Matrix& M) { MinusEqual(M); }
863 };
864 
866 {
867  GeneralMatrix* Image() const; // copy of matrix
868 public:
869  ColumnVector():Matrix() { ncols = 1; }
872  ColumnVector(const BaseMatrix&);
873  ColumnVector(const ColumnVector& gm):Matrix(gm) { GetMatrix(&gm); }
874  void operator=(const BaseMatrix&);
876  void operator=(const ColumnVector& m) { Eq(m); }
877  Real& operator()(int); // access element
878  Real& element(int); // access element
879  Real operator()(int) const; // access element
880  Real element(int) const; // access element
881 #ifdef SETUP_C_SUBSCRIPTS
882  Real& operator[](int m) { return store[m]; }
883  const Real& operator[](int m) const { return store[m]; }
884 #endif
885  MatrixType Type() const;
887  void ReSize(int); // change dimensions
888  void ReSize(int,int); // in case access is matrix
889  void ReSize(const GeneralMatrix& A);
890  Real* nric() const
891  { CheckStore(); return store-1; } // for use by NRIC
892  void CleanUp(); // to clear store
893  void MiniCleanUp() { store = 0; storage = 0; nrows = 0; ncols = 1; tag = -1; }
894 // ReturnMatrix Reverse() const; // reverse order of elements
895  void operator+=(const Matrix& M) { PlusEqual(M); }
896  void operator-=(const Matrix& M) { MinusEqual(M); }
900 };
901 
902 class OSSIM_DLL CroutMatrix : public GeneralMatrix // for LU decomposition
903 {
904  int* indx;
905  bool d;
906  bool sing;
907  void ludcmp();
908  void operator=(const CroutMatrix& /* m */) {} // not allowed
909 public:
910  CroutMatrix(const BaseMatrix&);
911  MatrixType Type() const;
912  void lubksb(Real*, int=0);
913  ~CroutMatrix();
914  GeneralMatrix* MakeSolver() { return this; } // for solving
915  LogAndSign LogDeterminant() const;
916  void Solver(MatrixColX&, const MatrixColX&);
917  void GetRow(MatrixRowCol&);
918  void GetCol(MatrixRowCol&);
920  void CleanUp(); // to clear store
921  void MiniCleanUp();
922  bool IsEqual(const GeneralMatrix&) const;
923  bool IsSingular() const { return sing; }
925 };
926 
927 // ***************************** band matrices ***************************/
928 
929 class OSSIM_DLL BandMatrix : public GeneralMatrix // band matrix
930 {
931  GeneralMatrix* Image() const; // copy of matrix
932 protected:
933  void CornerClear() const; // set unused elements to zero
934  short SimpleAddOK(const GeneralMatrix* gm);
935 public:
936  int lower, upper; // band widths
937  BandMatrix():GeneralMatrix() { lower=0; upper=0; CornerClear(); }
939  BandMatrix(int n,int lb,int ub) { ReSize(n,lb,ub); CornerClear(); }
940  // standard declaration
941  BandMatrix(const BaseMatrix&); // evaluate BaseMatrix
942  void operator=(const BaseMatrix&);
944  void operator=(const BandMatrix& m) { Eq(m); }
945  MatrixType Type() const;
946  Real& operator()(int, int); // access element
947  Real& element(int, int); // access element
948  Real operator()(int, int) const; // access element
949  Real element(int, int) const; // access element
950 #ifdef SETUP_C_SUBSCRIPTS
951  Real* operator[](int m) { return store+(upper+lower)*m+lower; }
952  const Real* operator[](int m) const { return store+(upper+lower)*m+lower; }
953 #endif
954  BandMatrix(const BandMatrix& gm):GeneralMatrix(gm) { GetMatrix(&gm); }
955  LogAndSign LogDeterminant() const;
956  GeneralMatrix* MakeSolver();
957  Real Trace() const;
958  Real SumSquare() const { CornerClear(); return GeneralMatrix::SumSquare(); }
960  { CornerClear(); return GeneralMatrix::SumAbsoluteValue(); }
961  Real Sum() const
962  { CornerClear(); return GeneralMatrix::Sum(); }
964  { CornerClear(); return GeneralMatrix::MaximumAbsoluteValue(); }
966  { int i, j; return GeneralMatrix::MinimumAbsoluteValue2(i, j); }
967  Real Maximum() const { int i, j; return GeneralMatrix::Maximum2(i, j); }
968  Real Minimum() const { int i, j; return GeneralMatrix::Minimum2(i, j); }
969  void GetRow(MatrixRowCol&);
970  void GetCol(MatrixRowCol&);
971  void GetCol(MatrixColX&);
972  void RestoreCol(MatrixRowCol&);
974  void NextRow(MatrixRowCol&);
975  virtual void ReSize(int, int, int); // change dimensions
976  void ReSize(const GeneralMatrix& A);
977  bool SameStorageType(const GeneralMatrix& A) const;
978  void ReSizeForAdd(const GeneralMatrix& A, const GeneralMatrix& B);
979  void ReSizeForSP(const GeneralMatrix& A, const GeneralMatrix& B);
980  MatrixBandWidth BandWidth() const;
981  void SetParameters(const GeneralMatrix*);
982  MatrixInput operator<<(Real); // will give error
983  MatrixInput operator<<(int f);
984  void operator<<(const Real* r); // will give error
985  void operator<<(const int* r); // will give error
986  // the next is included because Zortech and Borland
987  // cannot find the copy in GeneralMatrix
990 };
991 
992 class OSSIM_DLL UpperBandMatrix : public BandMatrix // upper band matrix
993 {
994  GeneralMatrix* Image() const; // copy of matrix
995 public:
998  UpperBandMatrix(int n, int ubw) // standard declaration
999  : BandMatrix(n, 0, ubw) {}
1000  UpperBandMatrix(const BaseMatrix&); // evaluate BaseMatrix
1001  void operator=(const BaseMatrix&);
1003  void operator=(const UpperBandMatrix& m) { Eq(m); }
1004  MatrixType Type() const;
1005  UpperBandMatrix(const UpperBandMatrix& gm):BandMatrix(gm) { GetMatrix(&gm); }
1006  GeneralMatrix* MakeSolver() { return this; }
1007  void Solver(MatrixColX&, const MatrixColX&);
1008  LogAndSign LogDeterminant() const;
1009  void ReSize(int, int, int); // change dimensions
1010  void ReSize(int n,int ubw) // change dimensions
1011  { BandMatrix::ReSize(n,0,ubw); }
1013  Real& operator()(int, int);
1014  Real operator()(int, int) const;
1015  Real& element(int, int);
1016  Real element(int, int) const;
1017 #ifdef SETUP_C_SUBSCRIPTS
1018  Real* operator[](int m) { return store+upper*m; }
1019  const Real* operator[](int m) const { return store+upper*m; }
1020 #endif
1022 };
1023 
1024 class OSSIM_DLL LowerBandMatrix : public BandMatrix // upper band matrix
1025 {
1026  GeneralMatrix* Image() const; // copy of matrix
1027 public:
1030  LowerBandMatrix(int n, int lbw) // standard declaration
1031  : BandMatrix(n, lbw, 0) {}
1032  LowerBandMatrix(const BaseMatrix&); // evaluate BaseMatrix
1033  void operator=(const BaseMatrix&);
1035  void operator=(const LowerBandMatrix& m) { Eq(m); }
1036  MatrixType Type() const;
1037  LowerBandMatrix(const LowerBandMatrix& gm):BandMatrix(gm) { GetMatrix(&gm); }
1038  GeneralMatrix* MakeSolver() { return this; }
1039  void Solver(MatrixColX&, const MatrixColX&);
1040  LogAndSign LogDeterminant() const;
1041  void ReSize(int, int, int); // change dimensions
1042  void ReSize(int n,int lbw) // change dimensions
1043  { BandMatrix::ReSize(n,lbw,0); }
1045  Real& operator()(int, int);
1046  Real operator()(int, int) const;
1047  Real& element(int, int);
1048  Real element(int, int) const;
1049 #ifdef SETUP_C_SUBSCRIPTS
1050  Real* operator[](int m) { return store+lower*(m+1); }
1051  const Real* operator[](int m) const { return store+lower*(m+1); }
1052 #endif
1054 };
1055 
1057 {
1058  GeneralMatrix* Image() const; // copy of matrix
1059  void CornerClear() const; // set unused elements to zero
1060  short SimpleAddOK(const GeneralMatrix* gm);
1061 public:
1062  int lower; // lower band width
1063  SymmetricBandMatrix():GeneralMatrix() { lower=0; CornerClear(); }
1065  SymmetricBandMatrix(int n, int lb) { ReSize(n,lb); CornerClear(); }
1067  void operator=(const BaseMatrix&);
1069  void operator=(const SymmetricBandMatrix& m) { Eq(m); }
1070  Real& operator()(int, int); // access element
1071  Real& element(int, int); // access element
1072  Real operator()(int, int) const; // access element
1073  Real element(int, int) const; // access element
1074 #ifdef SETUP_C_SUBSCRIPTS
1075  Real* operator[](int m) { return store+lower*(m+1); }
1076  const Real* operator[](int m) const { return store+lower*(m+1); }
1077 #endif
1078  MatrixType Type() const;
1079  SymmetricBandMatrix(const SymmetricBandMatrix& gm):GeneralMatrix(gm) { GetMatrix(&gm); }
1080  GeneralMatrix* MakeSolver();
1081  Real SumSquare() const;
1082  Real SumAbsoluteValue() const;
1083  Real Sum() const;
1085  { CornerClear(); return GeneralMatrix::MaximumAbsoluteValue(); }
1087  { int i, j; return GeneralMatrix::MinimumAbsoluteValue2(i, j); }
1088  Real Maximum() const { int i, j; return GeneralMatrix::Maximum2(i, j); }
1089  Real Minimum() const { int i, j; return GeneralMatrix::Minimum2(i, j); }
1090  Real Trace() const;
1091  LogAndSign LogDeterminant() const;
1092  void GetRow(MatrixRowCol&);
1093  void GetCol(MatrixRowCol&);
1094  void GetCol(MatrixColX&);
1096  void RestoreCol(MatrixColX&);
1098  void ReSize(int,int); // change dimensions
1099  void ReSize(const GeneralMatrix& A);
1100  bool SameStorageType(const GeneralMatrix& A) const;
1101  void ReSizeForAdd(const GeneralMatrix& A, const GeneralMatrix& B);
1102  void ReSizeForSP(const GeneralMatrix& A, const GeneralMatrix& B);
1103  MatrixBandWidth BandWidth() const;
1104  void SetParameters(const GeneralMatrix*);
1105  void operator<<(const Real* r); // will give error
1106  void operator<<(const int* r); // will give error
1109 };
1110 
1112 // for LU decomposition of band matrix
1113 {
1114  int* indx;
1115  bool d;
1116  bool sing; // true if singular
1119  void ludcmp();
1120  int m1,m2; // lower and upper
1121  void operator=(const BandLUMatrix& /* m */) {} // no allowed
1122 public:
1123  BandLUMatrix(const BaseMatrix&);
1124  MatrixType Type() const;
1125  void lubksb(Real*, int=0);
1126  ~BandLUMatrix();
1127  GeneralMatrix* MakeSolver() { return this; } // for solving
1128  LogAndSign LogDeterminant() const;
1129  void Solver(MatrixColX&, const MatrixColX&);
1130  void GetRow(MatrixRowCol&);
1131  void GetCol(MatrixRowCol&);
1133  void CleanUp(); // to clear store
1134  void MiniCleanUp();
1135  bool IsEqual(const GeneralMatrix&) const;
1136  bool IsSingular() const { return sing; }
1138 };
1139 
1140 // ************************** special matrices ****************************
1141 
1143 {
1144  GeneralMatrix* Image() const; // copy of matrix
1145 public:
1149  { nrows = ncols = n.Value(); *store = 1; }
1150  IdentityMatrix(const IdentityMatrix& gm):GeneralMatrix(gm) { GetMatrix(&gm); }
1151  IdentityMatrix(const BaseMatrix&);
1152  void operator=(const BaseMatrix&);
1153  void operator=(const IdentityMatrix& m) { Eq(m); }
1155  MatrixType Type() const;
1156 
1157  LogAndSign LogDeterminant() const;
1158  Real Trace() const;
1159  Real SumSquare() const;
1160  Real SumAbsoluteValue() const;
1161  Real Sum() const { return Trace(); }
1162  void GetRow(MatrixRowCol&);
1163  void GetCol(MatrixRowCol&);
1164  void GetCol(MatrixColX&);
1165  void NextRow(MatrixRowCol&);
1166  void NextCol(MatrixRowCol&);
1167  void NextCol(MatrixColX&);
1168  GeneralMatrix* MakeSolver() { return this; } // for solving
1169  void Solver(MatrixColX&, const MatrixColX&);
1171  void ReSize(int n);
1172  void ReSize(const GeneralMatrix& A);
1173  MatrixBandWidth BandWidth() const;
1174 // ReturnMatrix Reverse() const; // reverse order of elements
1176 };
1177 
1178 
1179 
1180 
1181 // ************************** GenericMatrix class ************************/
1182 
1184 {
1186  int search(const BaseMatrix* bm) const;
1187  friend class BaseMatrix;
1188 public:
1189  GenericMatrix() : gm(0) {}
1191  { gm = ((BaseMatrix&)bm).Evaluate(); gm = gm->Image(); }
1193  { gm = bm.gm->Image(); }
1194  void operator=(const GenericMatrix&);
1195  void operator=(const BaseMatrix&);
1196  void operator+=(const BaseMatrix&);
1197  void operator-=(const BaseMatrix&);
1198  void operator*=(const BaseMatrix&);
1199  void operator|=(const BaseMatrix&);
1200  void operator&=(const BaseMatrix&);
1201  void operator+=(Real);
1202  void operator-=(Real r) { operator+=(-r); }
1203  void operator*=(Real);
1204  void operator/=(Real r) { operator*=(1.0/r); }
1205  ~GenericMatrix() { delete gm; }
1206  void CleanUp() { delete gm; gm = 0; }
1207  void Release() { gm->Release(); }
1209  MatrixBandWidth BandWidth() const;
1211 };
1212 
1213 // *************************** temporary classes *************************/
1214 
1216 {
1217 protected:
1218  // if these union statements cause problems, simply remove them
1219  // and declare the items individually
1220  union { const BaseMatrix* bm1; GeneralMatrix* gm1; };
1221  // pointers to summands
1222  union { const BaseMatrix* bm2; GeneralMatrix* gm2; };
1223  MultipliedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1224  : bm1(bm1x),bm2(bm2x) {}
1225  int search(const BaseMatrix*) const;
1226  friend class BaseMatrix;
1227  friend class GeneralMatrix;
1228  friend class GenericMatrix;
1229 public:
1232  MatrixBandWidth BandWidth() const;
1234 };
1235 
1237 {
1238 protected:
1239  AddedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1240  : MultipliedMatrix(bm1x,bm2x) {}
1241 
1242  friend class BaseMatrix;
1243  friend class GeneralMatrix;
1244  friend class GenericMatrix;
1245 public:
1248  MatrixBandWidth BandWidth() const;
1250 };
1251 
1253 {
1254 protected:
1255  SPMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1256  : AddedMatrix(bm1x,bm2x) {}
1257 
1258  friend class BaseMatrix;
1259  friend class GeneralMatrix;
1260  friend class GenericMatrix;
1261 public:
1264  MatrixBandWidth BandWidth() const;
1265 
1266  friend SPMatrix SP(const BaseMatrix&, const BaseMatrix&);
1267 
1269 };
1270 
1272 {
1273 protected:
1274  KPMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1275  : MultipliedMatrix(bm1x,bm2x) {}
1276 
1277  friend class BaseMatrix;
1278  friend class GeneralMatrix;
1279  friend class GenericMatrix;
1280 public:
1282  MatrixBandWidth BandWidth() const;
1284  friend KPMatrix KP(const BaseMatrix&, const BaseMatrix&);
1286 };
1287 
1289 {
1290 protected:
1291  ConcatenatedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1292  : MultipliedMatrix(bm1x,bm2x) {}
1293 
1294  friend class BaseMatrix;
1295  friend class GeneralMatrix;
1296  friend class GenericMatrix;
1297 public:
1299  MatrixBandWidth BandWidth() const;
1302 };
1303 
1305 {
1306 protected:
1307  StackedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1308  : ConcatenatedMatrix(bm1x,bm2x) {}
1309 
1310  friend class BaseMatrix;
1311  friend class GeneralMatrix;
1312  friend class GenericMatrix;
1313 public:
1317 };
1318 
1320 {
1321  SolvedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1322  : MultipliedMatrix(bm1x,bm2x) {}
1323  friend class BaseMatrix;
1324  friend class InvertedMatrix; // for operator*
1325 public:
1328  MatrixBandWidth BandWidth() const;
1330 };
1331 
1333 {
1334  SubtractedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
1335  : AddedMatrix(bm1x,bm2x) {}
1336  friend class BaseMatrix;
1337  friend class GeneralMatrix;
1338  friend class GenericMatrix;
1339 public:
1343 };
1344 
1346 {
1347 protected:
1348  union { const BaseMatrix* bm; GeneralMatrix* gm; };
1350  ShiftedMatrix(const BaseMatrix* bmx, Real fx) : bm(bmx),f(fx) {}
1351  int search(const BaseMatrix*) const;
1352  friend class BaseMatrix;
1353  friend class GeneralMatrix;
1354  friend class GenericMatrix;
1355 public:
1358  friend ShiftedMatrix operator+(Real f, const BaseMatrix& BM);
1360 };
1361 
1363 {
1364 protected:
1365  NegShiftedMatrix(Real fx, const BaseMatrix* bmx) : ShiftedMatrix(bmx,fx) {}
1366  friend class BaseMatrix;
1367  friend class GeneralMatrix;
1368  friend class GenericMatrix;
1369 public:
1372  friend NegShiftedMatrix operator-(Real, const BaseMatrix&);
1374 };
1375 
1377 {
1378  ScaledMatrix(const BaseMatrix* bmx, Real fx) : ShiftedMatrix(bmx,fx) {}
1379  friend class BaseMatrix;
1380  friend class GeneralMatrix;
1381  friend class GenericMatrix;
1382 public:
1385  MatrixBandWidth BandWidth() const;
1386  friend ScaledMatrix operator*(Real f, const BaseMatrix& BM);
1388 };
1389 
1391 {
1392 protected:
1393  union { const BaseMatrix* bm; GeneralMatrix* gm; };
1394  NegatedMatrix(const BaseMatrix* bmx) : bm(bmx) {}
1395  int search(const BaseMatrix*) const;
1396 private:
1397  friend class BaseMatrix;
1398 public:
1401  MatrixBandWidth BandWidth() const;
1403 };
1404 
1406 {
1408  friend class BaseMatrix;
1409 public:
1412  MatrixBandWidth BandWidth() const;
1414 };
1415 
1417 {
1419  friend class BaseMatrix;
1420 public:
1424 };
1425 
1427 {
1429 public:
1431  SolvedMatrix operator*(const BaseMatrix&) const; // inverse(A) * B
1433  friend class BaseMatrix;
1435  MatrixBandWidth BandWidth() const;
1437 };
1438 
1440 {
1441  RowedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
1442  friend class BaseMatrix;
1443 public:
1446  MatrixBandWidth BandWidth() const;
1448 };
1449 
1451 {
1452  ColedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
1453  friend class BaseMatrix;
1454 public:
1457  MatrixBandWidth BandWidth() const;
1459 };
1460 
1462 {
1463  DiagedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
1464  friend class BaseMatrix;
1465 public:
1468  MatrixBandWidth BandWidth() const;
1470 };
1471 
1473 {
1474  int nr, nc;
1475  MatedMatrix(const BaseMatrix* bmx, int nrx, int ncx)
1476  : NegatedMatrix(bmx), nr(nrx), nc(ncx) {}
1477  friend class BaseMatrix;
1478 public:
1481  MatrixBandWidth BandWidth() const;
1483 };
1484 
1485 class OSSIM_DLL ReturnMatrix : public BaseMatrix // for matrix return
1486 {
1488  int search(const BaseMatrix*) const;
1489 public:
1491  GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
1492  friend class BaseMatrix;
1493  ReturnMatrix(const ReturnMatrix& tm) :BaseMatrix(tm), gm(tm.gm) {}
1494  ReturnMatrix(const GeneralMatrix* gmx) : gm((GeneralMatrix*&)gmx) {}
1495 // ReturnMatrix(GeneralMatrix&);
1496  MatrixBandWidth BandWidth() const;
1498 };
1499 
1500 
1501 // ************************** submatrices ******************************/
1502 
1504 {
1509  bool IsSym;
1510 
1511  GetSubMatrix
1512  (const BaseMatrix* bmx, int rs, int rn, int cs, int cn, bool is)
1513  : NegatedMatrix(bmx),
1514  row_skip(rs), row_number(rn), col_skip(cs), col_number(cn), IsSym(is) {}
1515  void SetUpLHS();
1516  friend class BaseMatrix;
1517 
1518 public:
1519 
1521  : NegatedMatrix(g.bm), row_skip(g.row_skip), row_number(g.row_number),
1522  col_skip(g.col_skip), col_number(g.col_number), IsSym(g.IsSym) {}
1523 
1526  void operator=(const BaseMatrix&);
1527  void operator+=(const BaseMatrix&);
1528  void operator-=(const BaseMatrix&);
1529  void operator=(const GetSubMatrix& m) { operator=((const BaseMatrix&)m); }
1530  void operator<<(const BaseMatrix&);
1531  void operator<<(const Real*); // copy from array
1532  void operator<<(const int*); // copy from array
1533  MatrixInput operator<<(Real); // for loading a list
1534  MatrixInput operator<<(int f);
1535  void operator=(Real); // copy from constant
1536  void operator+=(Real); // add constant
1537  void operator-=(Real r) { operator+=(-r); } // subtract constant
1538  void operator*=(Real); // multiply by constant
1539  void operator/=(Real r) { operator*=(1.0/r); } // divide by constant
1540  void Inject(const GeneralMatrix&); // copy stored els only
1541  MatrixBandWidth BandWidth() const;
1543 };
1544 
1545 // ******************** linear equation solving ****************************/
1546 
1548 {
1550  int search(const BaseMatrix*) const { return 0; }
1551  friend class BaseMatrix;
1552 public:
1553  LinearEquationSolver(const BaseMatrix& bm);
1554  ~LinearEquationSolver() { delete gm; }
1555  void CleanUp() { delete gm; }
1557  // probably should have an error message if MatrixType != UnSp
1559 };
1560 
1561 // ************************** matrix input *******************************/
1562 
1563 class OSSIM_DLL MatrixInput // for reading a list of values into a matrix
1564  // the difficult part is detecting a mismatch
1565  // in the number of elements
1566 {
1567  int n; // number values still to be read
1568  Real* r; // pointer to next location to be read to
1569 public:
1570  MatrixInput(const MatrixInput& mi) : n(mi.n), r(mi.r) {}
1571  MatrixInput(int nx, Real* rx) : n(nx), r(rx) {}
1572  ~MatrixInput();
1574  MatrixInput operator<<(int f);
1575  friend class GeneralMatrix;
1576 };
1577 
1578 
1579 
1580 // **************** a very simple integer array class ********************/
1581 
1582 // A minimal array class to imitate a C style array but giving dynamic storage
1583 // mostly intended for internal use by newmat
1584 
1585 class OSSIM_DLL SimpleIntArray : public RBD_COMMON::Janitor
1586 {
1587 protected:
1588  int* a; // pointer to the array
1589  int n; // length of the array
1590 public:
1591  SimpleIntArray(int xn); // build an array length xn
1592  ~SimpleIntArray(); // return the space to memory
1593  int& operator[](int i); // access element of the array - start at 0
1594  int operator[](int i) const;
1595  // access element of constant array
1596  void operator=(int ai); // set the array equal to a constant
1597  void operator=(const SimpleIntArray& b);
1598  // copy the elements of an array
1599  SimpleIntArray(const SimpleIntArray& b);
1600  // make a new array equal to an existing one
1601  int Size() const { return n; }
1602  // return the size of the array
1603  int* Data() { return a; } // pointer to the data
1604  const int* Data() const { return a; }
1605  // pointer to the data
1606  void ReSize(int i, bool keep = false);
1607  // change length, keep data if keep = true
1608  void CleanUp() { ReSize(0); }
1610 };
1611 
1612 // *************************** exceptions ********************************/
1613 
1614 class OSSIM_DLL NPDException : public Runtime_error // Not positive definite
1615 {
1616 public:
1617  static unsigned long Select; // for identifying exception
1618  NPDException(const GeneralMatrix&);
1619 };
1620 
1622 {
1623 public:
1624  static unsigned long Select; // for identifying exception
1626  ConvergenceException(const char* c);
1627 };
1628 
1630 {
1631 public:
1632  static unsigned long Select; // for identifying exception
1634 };
1635 
1637 {
1638 public:
1639  static unsigned long Select; // for identifying exception
1640  OverflowException(const char* c);
1641 };
1642 
1644 {
1645 protected:
1646  ProgramException();
1647 public:
1648  static unsigned long Select; // for identifying exception
1649  ProgramException(const char* c);
1650  ProgramException(const char* c, const GeneralMatrix&);
1651  ProgramException(const char* c, const GeneralMatrix&, const GeneralMatrix&);
1652  ProgramException(const char* c, MatrixType, MatrixType);
1653 };
1654 
1656 {
1657 public:
1658  static unsigned long Select; // for identifying exception
1659  IndexException(int i, const GeneralMatrix& A);
1660  IndexException(int i, int j, const GeneralMatrix& A);
1661  // next two are for access via element function
1662  IndexException(int i, const GeneralMatrix& A, bool);
1663  IndexException(int i, int j, const GeneralMatrix& A, bool);
1664 };
1665 
1666 class OSSIM_DLL VectorException : public Logic_error // cannot convert to vector
1667 {
1668 public:
1669  static unsigned long Select; // for identifying exception
1670  VectorException();
1672 };
1673 
1675 {
1676 public:
1677  static unsigned long Select; // for identifying exception
1680 };
1681 
1683 {
1684 public:
1685  static unsigned long Select; // for identifying exception
1687 };
1688 
1690 {
1691 public:
1692  static unsigned long Select; // for identifying exception
1695 };
1696 
1698 {
1699 public:
1700  static unsigned long Select; // for identifying exception
1701  NotDefinedException(const char* op, const char* matrix);
1702 };
1703 
1705 {
1706 public:
1707  static unsigned long Select; // for identifying exception
1708  CannotBuildException(const char* matrix);
1709 };
1710 
1711 
1713 {
1714 public:
1715  static unsigned long Select; // for identifying exception
1716  InternalException(const char* c);
1717 };
1718 
1719 // ************************ functions ************************************ //
1720 
1721 bool operator==(const GeneralMatrix& A, const GeneralMatrix& B);
1722 bool operator==(const BaseMatrix& A, const BaseMatrix& B);
1723 inline bool operator!=(const GeneralMatrix& A, const GeneralMatrix& B)
1724  { return ! (A==B); }
1725 inline bool operator!=(const BaseMatrix& A, const BaseMatrix& B)
1726  { return ! (A==B); }
1727 
1728  // inequality operators are dummies included for compatibility
1729  // with STL. They throw an exception if actually called.
1730 inline bool operator<=(const BaseMatrix& A, const BaseMatrix&)
1731  { A.IEQND(); return true; }
1732 inline bool operator>=(const BaseMatrix& A, const BaseMatrix&)
1733  { A.IEQND(); return true; }
1734 inline bool operator<(const BaseMatrix& A, const BaseMatrix&)
1735  { A.IEQND(); return true; }
1736 inline bool operator>(const BaseMatrix& A, const BaseMatrix&)
1737  { A.IEQND(); return true; }
1738 
1739 bool IsZero(const BaseMatrix& A);
1740 
1741 OSSIM_DLL Matrix CrossProduct(const Matrix& A, const Matrix& B);
1744 
1745 // Definition: newmat8.cpp:
1746 OSSIM_DLL Real DotProduct(const Matrix& A, const Matrix& B);
1747 
1748 // ********************* inline functions ******************************** //
1749 
1750 
1752  { return B.LogDeterminant(); }
1753 inline Real Determinant(const BaseMatrix& B)
1754  { return B.Determinant(); }
1755 inline Real SumSquare(const BaseMatrix& B) { return B.SumSquare(); }
1756 inline Real NormFrobenius(const BaseMatrix& B) { return B.NormFrobenius(); }
1757 inline Real Trace(const BaseMatrix& B) { return B.Trace(); }
1759  { return B.SumAbsoluteValue(); }
1760 inline Real Sum(const BaseMatrix& B)
1761  { return B.Sum(); }
1763  { return B.MaximumAbsoluteValue(); }
1765  { return B.MinimumAbsoluteValue(); }
1766 inline Real Maximum(const BaseMatrix& B) { return B.Maximum(); }
1767 inline Real Minimum(const BaseMatrix& B) { return B.Minimum(); }
1768 inline Real Norm1(const BaseMatrix& B) { return B.Norm1(); }
1769 inline Real Norm1(RowVector& RV) { return RV.MaximumAbsoluteValue(); }
1770 inline Real NormInfinity(const BaseMatrix& B) { return B.NormInfinity(); }
1772  { return CV.MaximumAbsoluteValue(); }
1773 inline bool IsZero(const GeneralMatrix& A) { return A.IsZero(); }
1774 
1775 
1776 inline MatrixInput MatrixInput::operator<<(int f) { return *this << (Real)f; }
1777 inline MatrixInput GeneralMatrix::operator<<(int f) { return *this << (Real)f; }
1778 inline MatrixInput BandMatrix::operator<<(int f) { return *this << (Real)f; }
1779 inline MatrixInput GetSubMatrix::operator<<(int f) { return *this << (Real)f; }
1780 
1781 
1782 
1783 #ifdef use_namespace
1784 }
1785 #endif
1786 
1787 
1788 #endif
1789 
1790 // body file: newmat1.cpp
1791 // body file: newmat2.cpp
1792 // body file: newmat3.cpp
1793 // body file: newmat4.cpp
1794 // body file: newmat5.cpp
1795 // body file: newmat6.cpp
1796 // body file: newmat7.cpp
1797 // body file: newmat8.cpp
1798 // body file: newmatex.cpp
1799 // body file: bandmat.cpp
1800 // body file: submat.cpp
1801 
1802 
1803 
1804 
1805 
1806 
1807 
static unsigned long Select
Definition: newmat.h:1617
void Add(GeneralMatrix *, Real)
Definition: newmat5.cpp:311
void operator<<(const BaseMatrix &)
Definition: submat.cpp:98
StackedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1307
void RestoreCol(MatrixRowCol &)
Definition: newmat.h:1095
Real MaximumAbsoluteValue() const
Definition: newmat.h:963
void operator-=(const Matrix &M)
Definition: newmat.h:582
void operator=(Real f)
Definition: newmat.h:630
void CleanUp()
Definition: newmat.h:1206
void operator=(const BaseMatrix &bm)
Definition: newmat.h:628
double Real
Definition: include.h:57
RowVector(const RowVector &gm)
Definition: newmat.h:830
void operator-=(const Matrix &M)
Definition: newmat.h:896
void operator=(const SymmetricMatrix &m)
Definition: newmat.h:660
GeneralMatrix * gm
Definition: newmat.h:1549
~DiagonalMatrix()
Definition: newmat.h:777
virtual Real MaximumAbsoluteValue() const
Definition: newmat8.cpp:454
~SymmetricMatrix()
Definition: newmat.h:655
Real Maximum() const
Definition: newmat.h:1088
void Release()
Definition: newmat.h:440
#define MatrixTypeUnSp
Definition: newmat.h:271
ossimRationalNumber operator-(ossim_int32 i, ossimRationalNumber &r)
void operator+=(const BaseMatrix &)
Definition: newmat6.cpp:469
void operator=(Real f)
Definition: newmat.h:659
void operator+=(const Matrix &M)
Definition: newmat.h:643
void operator=(const CroutMatrix &)
Definition: newmat.h:908
void operator-=(Real r)
Definition: newmat.h:1202
void operator=(const RowVector &m)
Definition: newmat.h:833
bool operator>=(MatrixType mt) const
Definition: newmat.h:153
GeneralMatrix * MakeSolver()
Definition: newmat.h:1006
Real sign(Real x, Real y)
Definition: newmatrm.h:108
Real Sum(const BaseMatrix &B)
Definition: newmat.h:1760
int Tag() const
Definition: newmat.h:438
MatrixBandWidth(const int i)
Definition: newmat.h:195
MatrixType(int i)
Definition: newmat.h:136
void operator+=(Real f)
Definition: newmat.h:583
virtual void RestoreRow(MatrixRowCol &)
Definition: newmat.h:460
virtual Real Sum() const
Definition: newmat8.cpp:448
void operator=(const MatrixType &mt)
Definition: newmat.h:140
void operator<<(const BaseMatrix &X)
Definition: newmat.h:988
ScaledMatrix(const BaseMatrix *bmx, Real fx)
Definition: newmat.h:1378
void MiniCleanUp()
Definition: newmat.h:893
void operator=(Real f)
Definition: newmat.h:782
MatrixBandWidth t() const
Definition: newmat.h:199
SolvedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1321
Matrix()
Definition: newmat.h:547
Real Maximum(const BaseMatrix &B)
Definition: newmat.h:1766
~UpperBandMatrix()
Definition: newmat.h:997
ShiftedMatrix(const BaseMatrix *bmx, Real fx)
Definition: newmat.h:1350
MatrixType ssub() const
Definition: newmat.h:169
void Release(int t)
Definition: newmat.h:441
static unsigned long Select
Definition: newmat.h:1658
~ColumnVector()
Definition: newmat.h:870
void operator=(Real f)
Definition: newmat.h:1068
IdentityMatrix(ArrayLengthSpecifier n)
Definition: newmat.h:1148
void operator-=(Real f)
Definition: newmat.h:818
int sign
Definition: newmat.h:44
ossimRationalNumber operator/(ossim_int32 i, ossimRationalNumber &r)
MatrixBandWidth(const int l, const int u)
Definition: newmat.h:194
LowerBandMatrix(const LowerBandMatrix &gm)
Definition: newmat.h:1037
void operator-=(const Matrix &M)
Definition: newmat.h:609
int * Data()
Definition: newmat.h:1603
SPMatrix SP(const BaseMatrix &bm1, const BaseMatrix &bm2)
Definition: newmat6.cpp:274
bool operator!() const
Definition: newmat.h:161
Real * r
Definition: newmat.h:1568
ColumnVector()
Definition: newmat.h:869
nricMatrix()
Definition: newmat.h:623
virtual Real Minimum() const
Definition: newmat8.cpp:508
void operator+=(const Matrix &M)
Definition: newmat.h:608
void operator=(const nricMatrix &m)
Definition: newmat.h:631
GeneralMatrix * gm
Definition: newmat.h:1185
void MiniCleanUp()
Definition: newmat.h:856
void GetCol(MatrixColX &c)
Definition: newmat.h:1132
virtual MatrixBandWidth BandWidth() const
Definition: newmat4.cpp:431
virtual void MiniCleanUp()
Definition: newmat.h:421
void operator=(const DiagonalMatrix &m)
Definition: newmat.h:783
bool IsSingular() const
Definition: newmat.h:923
~AddedMatrix()
Definition: newmat.h:1246
OSSIM_DLL Matrix CrossProduct(const Matrix &A, const Matrix &B)
Definition: newmat7.cpp:964
Real Determinant() const
Definition: newmat8.cpp:711
ReversedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1418
ColumnVector(const ColumnVector &gm)
Definition: newmat.h:873
Real Maximum() const
Definition: newmat.h:967
static unsigned long Select
Definition: newmat.h:1707
AddedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1239
int Ncols() const
Definition: newmat.h:431
NegShiftedMatrix(Real fx, const BaseMatrix *bmx)
Definition: newmat.h:1365
LowerTriangularMatrix(const LowerTriangularMatrix &gm)
Definition: newmat.h:738
friend class LinearEquationSolver
Definition: newmat.h:378
void operator-=(Real f)
Definition: newmat.h:611
void operator=(Real f)
Definition: newmat.h:552
void operator-=(const SymmetricMatrix &M)
Definition: newmat.h:684
MatrixInput operator<<(Real)
Definition: newmat5.cpp:391
#define FREE_CHECK(Class)
Definition: myexcept.h:316
GeneralMatrix * Evaluate(MatrixType mt=MatrixTypeUnSp)
Definition: newmat5.cpp:79
void operator=(const ColumnVector &m)
Definition: newmat.h:876
Matrix(const Matrix &gm)
Definition: newmat.h:563
int attribute
Definition: newmat.h:131
MatrixType()
Definition: newmat.h:135
ScaledMatrix operator*(Real t) const
Definition: newmat.h:1432
void operator=(Real f)
Definition: newmat.h:1034
Real MaximumAbsoluteValue(const BaseMatrix &B)
Definition: newmat.h:1762
bool CannotConvert() const
Definition: newmat.h:181
MatrixInput operator<<(Real)
Definition: newmat5.cpp:441
void operator=(const UpperTriangularMatrix &m)
Definition: newmat.h:698
ossimRationalNumber operator*(ossim_int32 i, ossimRationalNumber &r)
virtual short SimpleAddOK(const GeneralMatrix *)
Definition: newmat.h:419
DiagonalMatrix(const DiagonalMatrix &gm)
Definition: newmat.h:780
Real Norm1(const BaseMatrix &B)
Definition: newmat.h:1768
void operator=(Real)
Definition: newmat6.cpp:342
~BandMatrix()
Definition: newmat.h:938
LogAndSign()
Definition: newmat.h:46
#define A(r, c)
UpperBandMatrix(const UpperBandMatrix &gm)
Definition: newmat.h:1005
GenericMatrix(const BaseMatrix &bm)
Definition: newmat.h:1190
void CleanUp()
Definition: newmat.h:1608
nricMatrix(const BaseMatrix &bm)
Definition: newmat.h:626
virtual void ReSize(int, int, int)
Definition: bandmat.cpp:46
Real Maximum2(int &i, int &j) const
Definition: newmat8.cpp:322
void operator+=(Real f)
Definition: newmat.h:610
bool operator!=(MatrixType t) const
Definition: newmat.h:159
Real MaximumAbsoluteValue() const
Definition: newmat8.cpp:214
BandMatrix()
Definition: newmat.h:937
bool sing
Definition: newmat.h:906
bool operator!=(const GeneralMatrix &A, const GeneralMatrix &B)
Definition: newmat.h:1723
bool Compare(const MatrixType &source, MatrixType &destination)
Definition: newmat4.cpp:729
virtual Real MinimumAbsoluteValue() const
Definition: newmat8.cpp:472
void operator+=(const Matrix &M)
Definition: newmat.h:858
int operator+() const
Definition: newmat.h:143
int Size() const
Definition: newmat.h:1601
GeneralMatrix * MakeSolver()
Definition: newmat.h:711
void operator=(Real f)
Definition: newmat.h:1154
void operator+=(Real f)
Definition: newmat.h:685
Real ** nric() const
Definition: newmat.h:640
GeneralMatrix * gm
Definition: newmat.h:1393
MatrixBandWidth BandWidth() const
Definition: newmat4.cpp:444
Real MinimumAbsoluteValue() const
Definition: newmat.h:1086
int col_number
Definition: newmat.h:1508
void RestoreCol(MatrixColX &c)
Definition: newmat.h:719
void operator<<(const BaseMatrix &X)
Definition: newmat.h:1107
SPMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1255
GenericMatrix(const GenericMatrix &bm)
Definition: newmat.h:1192
int row_skip
Definition: newmat.h:1505
void operator/=(Real r)
Definition: newmat.h:1204
void operator=(const UpperBandMatrix &m)
Definition: newmat.h:1003
SquareMatrix()
Definition: newmat.h:593
~SolvedMatrix()
Definition: newmat.h:1326
~ReturnMatrix()
Definition: newmat.h:1490
~GetSubMatrix()
Definition: newmat.h:1524
void operator=(const LowerBandMatrix &m)
Definition: newmat.h:1035
Real MinimumAbsoluteValue(const BaseMatrix &B)
Definition: newmat.h:1764
GeneralMatrix * MakeSolver()
Definition: newmat.h:806
void operator+=(Real f)
Definition: newmat.h:767
MatrixType sub() const
Definition: newmat.h:167
IdentityMatrix(const IdentityMatrix &gm)
Definition: newmat.h:1150
~ColedMatrix()
Definition: newmat.h:1455
ostream & operator<<(ostream &out, const ossimAxes &axes)
Definition: ossimAxes.h:88
void operator/=(Real r)
Definition: newmat.h:1539
ReturnMatrix(const GeneralMatrix *gmx)
Definition: newmat.h:1494
int row_number
Definition: newmat.h:1506
MatedMatrix(const BaseMatrix *bmx, int nrx, int ncx)
Definition: newmat.h:1475
bool operator<(const BaseMatrix &A, const BaseMatrix &)
Definition: newmat.h:1734
void MatrixErrorNoSpace(const void *)
Definition: newmatex.cpp:292
void operator+=(Real f)
Definition: newmat.h:817
ColedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1452
virtual void ReSize(int, int)
Definition: newmat4.cpp:233
void ReleaseAndDelete()
Definition: newmat.h:442
void operator+=(Real f)
Definition: newmat.h:726
UpperBandMatrix(int n, int ubw)
Definition: newmat.h:998
KPMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1274
int Sign() const
Definition: newmat.h:52
void operator-=(Real f)
Definition: newmat.h:861
int Lower() const
Definition: newmat.h:204
Real MinimumAbsoluteValue2(int &i, int &j) const
Definition: newmat8.cpp:307
GeneralMatrix * Evaluate(MatrixType mt=MatrixTypeUnSp)
Definition: newmat7.cpp:495
void operator-=(Real r)
Definition: newmat.h:454
void operator-=(const Matrix &M)
Definition: newmat.h:644
void operator-=(const BaseMatrix &)
Definition: newmat6.cpp:482
int search(const BaseMatrix *) const
Definition: newmat.h:1550
OSSIM_DLL ReturnMatrix CrossProductRows(const Matrix &A, const Matrix &B)
Definition: newmat7.cpp:988
void operator+=(Real f)
Definition: newmat.h:860
ArrayLengthSpecifier(int l)
Definition: newmat.h:220
os2<< "> n<< " > nendobj n
Real NormInfinity(const BaseMatrix &B)
Definition: newmat.h:1770
void operator/=(Real r)
Definition: newmat.h:456
void operator-=(Real f)
Definition: newmat.h:584
void operator+=(const Matrix &M)
Definition: newmat.h:895
GeneralMatrix * MakeSolver()
Definition: newmat.h:914
void operator=(Real f)
Definition: newmat.h:701
int storage2
Definition: newmat.h:1118
Real Sum() const
Definition: newmat.h:1161
void operator=(const SymmetricBandMatrix &m)
Definition: newmat.h:1069
nricMatrix(int m, int n)
Definition: newmat.h:624
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:1044
OSSIM_DLL ReturnMatrix CrossProductColumns(const Matrix &A, const Matrix &B)
Definition: newmat7.cpp:1009
void operator-=(Real f)
Definition: newmat.h:768
NegatedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1394
void operator+=(const SymmetricMatrix &M)
Definition: newmat.h:683
bool operator==(const MatrixBandWidth &bw) const
Definition: newmat.h:200
bool operator>(const BaseMatrix &A, const BaseMatrix &)
Definition: newmat.h:1736
void ReSize(int n, int lbw)
Definition: newmat.h:1042
int Value() const
Definition: newmat.h:219
void operator-=(Real f)
Definition: newmat.h:686
ReturnMatrix(const ReturnMatrix &tm)
Definition: newmat.h:1493
GeneralMatrix * gm
Definition: newmat.h:1487
ColumnVector(ArrayLengthSpecifier n)
Definition: newmat.h:871
bool operator==(const GeneralMatrix &A, const GeneralMatrix &B)
Definition: newmat7.cpp:850
SquareMatrix(const SquareMatrix &gm)
Definition: newmat.h:602
void RestoreCol(MatrixColX &c)
Definition: newmat.h:760
void operator-=(Real f)
Definition: newmat.h:646
bool operator>=(const BaseMatrix &A, const BaseMatrix &)
Definition: newmat.h:1732
void operator+=(const Matrix &M)
Definition: newmat.h:581
Real * nric() const
Definition: newmat.h:811
void operator-=(Real r)
Definition: newmat.h:1537
virtual void RestoreCol(MatrixColX &)
Definition: newmat.h:465
void RestoreCol(MatrixRowCol &)
Definition: newmat.h:678
Real SumSquare() const
Definition: newmat8.cpp:152
SymmetricMatrix(const SymmetricMatrix &gm)
Definition: newmat.h:670
Real SumAbsoluteValue(const BaseMatrix &B)
Definition: newmat.h:1758
int * indx
Definition: newmat.h:1114
~DiagedMatrix()
Definition: newmat.h:1466
bool Rectangular(MatrixType a, MatrixType b, MatrixType c)
Definition: newmat1.cpp:103
GeneralMatrix * MakeSolver()
Definition: newmat.h:1127
void operator=(const IdentityMatrix &m)
Definition: newmat.h:1153
bool DataLossOK
Definition: newmat.h:132
~MatedMatrix()
Definition: newmat.h:1479
Real Determinant(const BaseMatrix &B)
Definition: newmat.h:1753
Real NormFrobenius() const
Definition: newmat8.cpp:439
MatrixType operator+(MatrixType mt) const
Definition: newmat.h:144
void GetCol(MatrixColX &c)
Definition: newmat.h:919
void operator+=(const LowerTriangularMatrix &M)
Definition: newmat.h:765
Definition: newmat.h:543
virtual LogAndSign LogDeterminant() const
Definition: newmat8.cpp:682
GeneralMatrix * MakeSolver()
Definition: newmat.h:1168
LogAndSign LogDeterminant(const BaseMatrix &B)
Definition: newmat.h:1751
Real * store
Definition: newmat.h:393
SymmetricBandMatrix(int n, int lb)
Definition: newmat.h:1065
LowerBandMatrix(int n, int lbw)
Definition: newmat.h:1030
~SPMatrix()
Definition: newmat.h:1262
virtual Real Maximum() const
Definition: newmat8.cpp:490
Real * nric() const
Definition: newmat.h:890
bool IsSymmetric() const
Definition: newmat.h:180
MatrixType AddEqualEl() const
Definition: newmat.h:164
~RowedMatrix()
Definition: newmat.h:1444
static unsigned long Select
Definition: newmat.h:1648
static unsigned long Select
Definition: newmat.h:1677
virtual void CleanUp()
Definition: newmat.h:336
const int * Data() const
Definition: newmat.h:1604
Real MinimumAbsoluteValue() const
Definition: newmat.h:965
void operator=(const SquareMatrix &m)
Definition: newmat.h:599
MatrixInput(const MatrixInput &mi)
Definition: newmat.h:1570
Real ** row_pointer
Definition: newmat.h:619
void operator<<(const Real *)
Definition: newmat6.cpp:422
void operator+=(Real f)
Definition: newmat.h:897
MatrixBandWidth BandWidth() const
Definition: newmat4.cpp:503
Real MaximumAbsoluteValue() const
Definition: newmat.h:1084
virtual Real SumSquare() const
Definition: newmat8.cpp:433
void Release()
Definition: newmat.h:1207
void operator=(Real f)
Definition: newmat.h:598
bool sing
Definition: newmat.h:1116
virtual GeneralMatrix * Image() const
Definition: newmat4.cpp:838
BandMatrix(const BandMatrix &gm)
Definition: newmat.h:954
Real NormInfinity() const
Definition: newmat7.cpp:735
static unsigned long Select
Definition: newmat.h:1669
void operator<<(const BaseMatrix &X)
Definition: newmat.h:445
~RowVector()
Definition: newmat.h:827
BandMatrix(int n, int lb, int ub)
Definition: newmat.h:939
Real * store2
Definition: newmat.h:1117
virtual GeneralMatrix * Evaluate(MatrixType mt=MatrixTypeUnSp)=0
SymmetricBandMatrix(const SymmetricBandMatrix &gm)
Definition: newmat.h:1079
void operator=(const BandMatrix &m)
Definition: newmat.h:944
void RestoreCol(MatrixColX &c)
Definition: newmat.h:973
GeneralMatrix * Evaluate(MatrixType)
Definition: newmat.h:1556
nricMatrix(const nricMatrix &gm)
Definition: newmat.h:635
void RestoreCol(MatrixRowCol &)
Definition: newmat.h:847
bool d
Definition: newmat.h:905
static unsigned long Select
Definition: newmat.h:1624
bool operator<(MatrixType mt) const
Definition: newmat.h:155
void operator+=(const UpperTriangularMatrix &M)
Definition: newmat.h:724
OSSIM_DLL Real DotProduct(const Matrix &A, const Matrix &B)
Definition: newmat8.cpp:526
UpperTriangularMatrix(const UpperTriangularMatrix &gm)
Definition: newmat.h:700
~StackedMatrix()
Definition: newmat.h:1314
void operator=(const BaseMatrix &)
Definition: newmat6.cpp:345
virtual void RestoreCol(MatrixRowCol &)
Definition: newmat.h:464
Real log_value
Definition: newmat.h:43
GetSubMatrix(const GetSubMatrix &g)
Definition: newmat.h:1520
bool IsDiagonal() const
Definition: newmat.h:179
#define OSSIM_DLL
int Storage() const
Definition: newmat.h:432
static unsigned long Select
Definition: newmat.h:1700
MatrixInput(int nx, Real *rx)
Definition: newmat.h:1571
void operator-=(const UpperTriangularMatrix &M)
Definition: newmat.h:725
~KPMatrix()
Definition: newmat.h:1281
void operator=(const Matrix &m)
Definition: newmat.h:553
void operator-=(const Matrix &M)
Definition: newmat.h:859
Real SumSquare() const
Definition: newmat.h:958
MatrixType(const MatrixType &mt)
Definition: newmat.h:138
DiagedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1463
void operator-=(const LowerTriangularMatrix &M)
Definition: newmat.h:766
RowedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1441
int Nrows() const
Definition: newmat.h:430
void ReSize(int m, int n)
Definition: newmat.h:636
bool IsSingular() const
Definition: newmat.h:1136
ConcatenatedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1291
MatrixType(int i, bool dlok)
Definition: newmat.h:137
virtual Real SumAbsoluteValue() const
Definition: newmat8.cpp:442
int Upper() const
Definition: newmat.h:203
~SquareMatrix()
Definition: newmat.h:594
Real Sum() const
Definition: newmat8.cpp:168
void SetDataLossOK()
Definition: newmat.h:142
Real SumAbsoluteValue() const
Definition: newmat.h:959
GeneralMatrix * gm2
Definition: newmat.h:1222
int upper
Definition: newmat.h:936
static unsigned long Select
Definition: newmat.h:1632
static unsigned long Select
Definition: newmat.h:1715
void operator=(Real f)
Definition: newmat.h:741
void operator+=(Real f)
Definition: newmat.h:645
bool operator!=(const MatrixBandWidth &bw) const
Definition: newmat.h:202
void operator=(const GetSubMatrix &m)
Definition: newmat.h:1529
void ChangeSign()
Definition: newmat.h:50
KPMatrix KP(const BaseMatrix &bm1, const BaseMatrix &bm2)
Definition: newmat6.cpp:277
DiagonalMatrix()
Definition: newmat.h:776
void operator=(Real f)
Definition: newmat.h:875
Real * Store() const
Definition: newmat.h:433
static unsigned long Select
Definition: newmat.h:1685
static int nTypes()
Definition: newmat.h:128
virtual void Solver(MatrixColX &, const MatrixColX &)
Definition: newmat.h:458
void operator-=(Real f)
Definition: newmat.h:727
Real Norm1() const
Definition: newmat7.cpp:723
Real LogValue() const
Definition: newmat.h:51
void Protect()
Definition: newmat.h:437
int storage
Definition: newmat.h:392
int * indx
Definition: newmat.h:904
static unsigned long Select
Definition: newmat.h:1639
RowVector()
Definition: newmat.h:826
void operator-=(const DiagonalMatrix &M)
Definition: newmat.h:816
Real NormFrobenius(const BaseMatrix &B)
Definition: newmat.h:1756
GeneralMatrix * gm1
Definition: newmat.h:1220
void operator=(Real f)
Definition: newmat.h:943
MultipliedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1223
void operator+=(const DiagonalMatrix &M)
Definition: newmat.h:815
Real Minimum(const BaseMatrix &B)
Definition: newmat.h:1767
GeneralMatrix * MakeSolver()
Definition: newmat.h:1038
~NegatedMatrix()
Definition: newmat.h:1399
~nricMatrix()
Definition: newmat.h:639
bool operator<=(const BaseMatrix &A, const BaseMatrix &)
Definition: newmat.h:1730
Real Minimum() const
Definition: newmat.h:968
Real Minimum2(int &i, int &j) const
Definition: newmat8.cpp:337
virtual Real Trace() const
Definition: newmat8.cpp:609
static unsigned long Select
Definition: newmat.h:1692
void operator=(const LowerTriangularMatrix &m)
Definition: newmat.h:742
void operator=(Real f)
Definition: newmat.h:1002
#define NEW_DELETE(Class)
Definition: myexcept.h:338
void ReSize(int n, int ubw)
Definition: newmat.h:1010
Real SumAbsoluteValue() const
Definition: newmat8.cpp:160
~ShiftedMatrix()
Definition: newmat.h:1356
void ReSize(const GeneralMatrix &A)
Definition: newmat.h:1012
~GenericMatrix()
Definition: newmat.h:1205
int col_skip
Definition: newmat.h:1507
ossimRationalNumber operator+(ossim_int32 i, ossimRationalNumber &r)
bool operator==(MatrixType t) const
Definition: newmat.h:157
~ScaledMatrix()
Definition: newmat.h:1383
SubtractedMatrix(const BaseMatrix *bm1x, const BaseMatrix *bm2x)
Definition: newmat.h:1334
TransposedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1407
Real * nric() const
Definition: newmat.h:853
GeneralMatrix * Evaluate(MatrixType=MatrixTypeUnSp)
Definition: newmat5.cpp:91
virtual void SetParameters(const GeneralMatrix *)
Definition: newmat.h:487
MultipliedMatrix operator*(const BaseMatrix &) const
Definition: newmat6.cpp:280
GeneralMatrix * MakeSolver()
Definition: newmat.h:752
GeneralMatrix * gm
Definition: newmat.h:1348
RowVector(ArrayLengthSpecifier n)
Definition: newmat.h:828
bool IsZero(const BaseMatrix &A)
Definition: newmat7.cpp:889
bool IsSym
Definition: newmat.h:1509
void operator=(Real f)
Definition: newmat.h:832
void operator=(const BandLUMatrix &)
Definition: newmat.h:1121
bool IsBand() const
Definition: newmat.h:178
Real SumSquare(const BaseMatrix &B)
Definition: newmat.h:1755
Real Sum() const
Definition: newmat.h:961
MatrixType operator|(const MatrixType &mt) const
Definition: newmat.h:149
Real Trace(const BaseMatrix &B)
Definition: newmat.h:1757
InvertedMatrix(const BaseMatrix *bmx)
Definition: newmat.h:1428
Real Minimum() const
Definition: newmat.h:1089
void operator<<(const BaseMatrix &X)
Definition: newmat.h:633
void operator-=(Real f)
Definition: newmat.h:898
~Matrix()
Definition: newmat.h:548