OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
newmatrc.h
Go to the documentation of this file.
1 //$$ newmatrc.h definition file for row/column classes
2 
3 // Copyright (C) 1991,2,3,4,7: R B Davies
4 
5 #ifndef NEWMATRC_LIB
6 #define NEWMATRC_LIB 0
7 
8 #ifdef use_namespace
9 namespace NEWMAT {
10 #endif
11 
12 #include <ossim/matrix/controlw.h>
13 
14 
15 /************** classes MatrixRowCol, MatrixRow, MatrixCol *****************/
16 
17 // Used for accessing the rows and columns of matrices
18 // All matrix classes must provide routines for calculating matrix rows and
19 // columns. Assume rows can be found very efficiently.
20 
22 
23 
25 {
26 public:
31 };
32 
34 // the row or column of a matrix
35 {
36 public: // these are public to avoid
37  // numerous friend statements
38  int length; // row or column length
39  int skip; // initial number of zeros
40  int storage; // number of stored elements
41  int rowcol; // row or column number
42  GeneralMatrix* gm; // pointer to parent matrix
43  Real* data; // pointer to local storage
44  LoadAndStoreFlag cw; // Load? Store? Is a Copy?
45  void IncrMat() { rowcol++; data += storage; } // used by NextRow
46  void IncrDiag() { rowcol++; skip++; data++; }
47  void IncrId() { rowcol++; skip++; }
48  void IncrUT() { rowcol++; data += storage; storage--; skip++; }
49  void IncrLT() { rowcol++; data += storage; storage++; }
50 
51 public:
52  void Zero(); // set elements to zero
53  void Add(const MatrixRowCol&); // add a row/col
54  void AddScaled(const MatrixRowCol&, Real); // add a multiple of a row/col
55  void Add(const MatrixRowCol&, const MatrixRowCol&);
56  // add two rows/cols
57  void Add(const MatrixRowCol&, Real); // add a row/col
58  void NegAdd(const MatrixRowCol&, Real); // Real - a row/col
59  void Sub(const MatrixRowCol&); // subtract a row/col
60  void Sub(const MatrixRowCol&, const MatrixRowCol&);
61  // sub a row/col from another
62  void RevSub(const MatrixRowCol&); // subtract from a row/col
63  void ConCat(const MatrixRowCol&, const MatrixRowCol&);
64  // concatenate two row/cols
65  void Multiply(const MatrixRowCol&); // multiply a row/col
66  void Multiply(const MatrixRowCol&, const MatrixRowCol&);
67  // multiply two row/cols
68  void KP(const MatrixRowCol&, const MatrixRowCol&);
69  // Kronecker Product two row/cols
70  void Copy(const MatrixRowCol&); // copy a row/col
71  void CopyCheck(const MatrixRowCol&); // ... check for data loss
72  void Check(const MatrixRowCol&); // just check for data loss
73  void Check(); // check full row/col present
74  void Copy(const Real*&); // copy from an array
75  void Copy(const int*&); // copy from an array
76  void Copy(Real); // copy from constant
77  void Add(Real); // add a constant
78  void Multiply(Real); // multiply by constant
79  Real SumAbsoluteValue(); // sum of absolute values
80  Real MaximumAbsoluteValue1(Real r, int& i); // maximum of absolute values
81  Real MinimumAbsoluteValue1(Real r, int& i); // minimum of absolute values
82  Real Maximum1(Real r, int& i); // maximum
83  Real Minimum1(Real r, int& i); // minimum
84  Real Sum(); // sum of values
85  void Inject(const MatrixRowCol&); // copy stored els of a row/col
86  void Negate(const MatrixRowCol&); // change sign of a row/col
87  void Multiply(const MatrixRowCol&, Real); // scale a row/col
88  friend Real DotProd(const MatrixRowCol&, const MatrixRowCol&);
89  // sum of pairwise product
90  Real* Data() { return data; }
91  int Skip() { return skip; } // number of elements skipped
92  int Storage() { return storage; } // number of elements stored
93  int Length() { return length; } // length of row or column
94  void Skip(int i) { skip=i; }
95  void Storage(int i) { storage=i; }
96  void Length(int i) { length=i; }
97  void SubRowCol(MatrixRowCol&, int, int) const;
98  // get part of a row or column
99  MatrixRowCol() {} // to stop warning messages
100  ~MatrixRowCol();
102 };
103 
105 {
106 public:
107  // bodies for these are inline at the end of this .h file
109  // extract a row
110  ~MatrixRow();
111  void Next(); // get next row
113 };
114 
116 {
117 public:
118  // bodies for these are inline at the end of this .h file
120  // extract a col
122  // store/retrieve a col
123  ~MatrixCol();
124  void Next(); // get next row
126 };
127 
128 // MatrixColX is an alternative to MatrixCol where the complete
129 // column is stored externally
130 
132 {
133 public:
134  // bodies for these are inline at the end of this .h file
136  // store/retrieve a col
137  ~MatrixColX();
138  void Next(); // get next row
139  Real* store; // pointer to local storage
140  // less skip
142 };
143 
144 /**************************** inline bodies ****************************/
145 
147 { gm=gmx; cw=cwx; rowcol=row; gm->GetRow(*this); }
148 
149 inline void MatrixRow::Next() { gm->NextRow(*this); }
150 
152 { gm=gmx; cw=cwx; rowcol=col; gm->GetCol(*this); }
153 
155  LoadAndStoreFlag cwx, int col)
156 { gm=gmx; data=r; cw=cwx+StoreHere; rowcol=col; gm->GetCol(*this); }
157 
159  LoadAndStoreFlag cwx, int col)
160 { gm=gmx; store=data=r; cw=cwx+StoreHere; rowcol=col; gm->GetCol(*this); }
161 
162 
163 inline void MatrixCol::Next() { gm->NextCol(*this); }
164 
165 inline void MatrixColX::Next() { gm->NextCol(*this); }
166 
167 #ifdef use_namespace
168 }
169 #endif
170 
171 #endif
Real DotProd(const MatrixRowCol &mrc1, const MatrixRowCol &mrc2)
Definition: newmat2.cpp:74
double Real
Definition: include.h:57
LoadAndStoreFlag(int i)
Definition: newmatrc.h:28
void IncrMat()
Definition: newmatrc.h:45
int Storage()
Definition: newmatrc.h:92
int Length()
Definition: newmatrc.h:93
Real Sum(const BaseMatrix &B)
Definition: newmat.h:1760
GeneralMatrix * gm
Definition: newmatrc.h:42
void IncrId()
Definition: newmatrc.h:47
void Skip(int i)
Definition: newmatrc.h:94
#define FREE_CHECK(Class)
Definition: myexcept.h:316
int Skip()
Definition: newmatrc.h:91
MatrixColX(GeneralMatrix *, Real *, LoadAndStoreFlag, int=0)
Definition: newmatrc.h:158
void IncrDiag()
Definition: newmatrc.h:46
void IncrUT()
Definition: newmatrc.h:48
void Next()
Definition: newmatrc.h:165
Real * data
Definition: newmatrc.h:43
int storage
Definition: newmatrc.h:40
MatrixRow(GeneralMatrix *, LoadAndStoreFlag, int=0)
Definition: newmatrc.h:146
Real * Data()
Definition: newmatrc.h:90
Real * store
Definition: newmatrc.h:139
MatrixRowCol()
Definition: newmatrc.h:99
void Storage(int i)
Definition: newmatrc.h:95
LoadAndStoreFlag(const ControlWord &cwx)
Definition: newmatrc.h:30
Real SumAbsoluteValue(const BaseMatrix &B)
Definition: newmat.h:1758
LoadAndStoreFlag cw
Definition: newmatrc.h:44
void Next()
Definition: newmatrc.h:163
#define OSSIM_DLL
LSF
Definition: newmatrc.h:21
int rowcol
Definition: newmatrc.h:41
KPMatrix KP(const BaseMatrix &bm1, const BaseMatrix &bm2)
Definition: newmat6.cpp:277
MatrixCol(GeneralMatrix *, LoadAndStoreFlag, int=0)
Definition: newmatrc.h:151
void Length(int i)
Definition: newmatrc.h:96
void IncrLT()
Definition: newmatrc.h:49
LoadAndStoreFlag(LSF lsf)
Definition: newmatrc.h:29
void Next()
Definition: newmatrc.h:149
int length
Definition: newmatrc.h:38