newmatrc.h
Go to the documentation of this file.
1 
6 
7 // Copyright (C) 1991,2,3,4,7: R B Davies
8 
9 #ifndef NEWMATRC_LIB
10 #define NEWMATRC_LIB 0
11 
12 #ifdef use_namespace
13 namespace NEWMAT {
14 #endif
15 
16 #include "controlw.h"
17 
18 
19 /************** classes MatrixRowCol, MatrixRow, MatrixCol *****************/
20 
21 // Used for accessing the rows and columns of matrices
22 // All matrix classes must provide routines for calculating matrix rows and
23 // columns. Assume rows can be found very efficiently.
24 
26 
27 
31 {
32 public:
37 };
38 
39 
43 {
44 public: // these are public to avoid
45  // numerous friend statements
46  int length; // row or column length
47  int skip; // initial number of zeros
48  int storage; // number of stored elements
49  int rowcol; // row or column number
50  GeneralMatrix* gm; // pointer to parent matrix
51  Real* data; // pointer to local storage
52  LoadAndStoreFlag cw; // Load? Store? Is a Copy?
53  void IncrMat() { rowcol++; data += storage; } // used by NextRow
54  void IncrDiag() { rowcol++; skip++; data++; }
55  void IncrId() { rowcol++; skip++; }
56  void IncrUT() { rowcol++; data += storage; storage--; skip++; }
57  void IncrLT() { rowcol++; data += storage; storage++; }
58 
59 public:
60  void Zero(); // set elements to zero
61  void Add(const MatrixRowCol&); // add a row/col
62  void AddScaled(const MatrixRowCol&, Real); // add a multiple of a row/col
63  void Add(const MatrixRowCol&, const MatrixRowCol&);
64  // add two rows/cols
65  void Add(const MatrixRowCol&, Real); // add a row/col
66  void NegAdd(const MatrixRowCol&, Real); // Real - a row/col
67  void Sub(const MatrixRowCol&); // subtract a row/col
68  void Sub(const MatrixRowCol&, const MatrixRowCol&);
69  // sub a row/col from another
70  void RevSub(const MatrixRowCol&); // subtract from a row/col
71  void ConCat(const MatrixRowCol&, const MatrixRowCol&);
72  // concatenate two row/cols
73  void Multiply(const MatrixRowCol&); // multiply a row/col
74  void Multiply(const MatrixRowCol&, const MatrixRowCol&);
75  // multiply two row/cols
76  void KP(const MatrixRowCol&, const MatrixRowCol&);
77  // Kronecker Product two row/cols
78  void Copy(const MatrixRowCol&); // copy a row/col
79  void CopyCheck(const MatrixRowCol&); // ... check for data loss
80  void Check(const MatrixRowCol&); // just check for data loss
81  void Check(); // check full row/col present
82  void Copy(const double*&); // copy from an array
83  void Copy(const float*&); // copy from an array
84  void Copy(const int*&); // copy from an array
85  void Copy(Real); // copy from constant
86  void Add(Real); // add a constant
87  void Multiply(Real); // multiply by constant
88  Real SumAbsoluteValue(); // sum of absolute values
89  Real MaximumAbsoluteValue1(Real r, int& i); // maximum of absolute values
90  Real MinimumAbsoluteValue1(Real r, int& i); // minimum of absolute values
91  Real Maximum1(Real r, int& i); // maximum
92  Real Minimum1(Real r, int& i); // minimum
93  Real Sum(); // sum of values
94  void Inject(const MatrixRowCol&); // copy stored els of a row/col
95  void Negate(const MatrixRowCol&); // change sign of a row/col
96  void Multiply(const MatrixRowCol&, Real); // scale a row/col
97  friend Real DotProd(const MatrixRowCol&, const MatrixRowCol&);
98  // sum of pairwise product
99  Real* Data() { return data; }
100  int Skip() { return skip; } // number of elements skipped
101  int Storage() { return storage; } // number of elements stored
102  int Length() { return length; } // length of row or column
103  void Skip(int i) { skip=i; }
104  void Storage(int i) { storage=i; }
105  void Length(int i) { length=i; }
106  void SubRowCol(MatrixRowCol&, int, int) const;
107  // get part of a row or column
108  MatrixRowCol() {} // to stop warning messages
109  ~MatrixRowCol();
111 };
112 
115 class MatrixRow : public MatrixRowCol
116 {
117 public:
118  // bodies for these are inline at the end of this .h file
120  // extract a row
121  ~MatrixRow();
122  void Next(); // get next row
124 };
125 
128 class MatrixCol : public MatrixRowCol
129 {
130 public:
131  // bodies for these are inline at the end of this .h file
133  // extract a col
135  // store/retrieve a col
136  ~MatrixCol();
137  void Next(); // get next column
139 };
140 
143 class MatrixColX : public MatrixRowCol
144 {
145 public:
146  // bodies for these are inline at the end of this .h file
148  // store/retrieve a col
149  ~MatrixColX();
150  void Next(); // get next row
151  Real* store; // pointer to local storage
152  // less skip
154 };
155 
156 /**************************** inline bodies ****************************/
157 
159 { gm=gmx; cw=cwx; rowcol=row; gm->GetRow(*this); }
160 
161 inline void MatrixRow::Next() { gm->NextRow(*this); }
162 
164 { gm=gmx; cw=cwx; rowcol=col; gm->GetCol(*this); }
165 
167  LoadAndStoreFlag cwx, int col)
168 { gm=gmx; data=r; cw=cwx+StoreHere; rowcol=col; gm->GetCol(*this); }
169 
171  LoadAndStoreFlag cwx, int col)
172 { gm=gmx; store=data=r; cw=cwx+StoreHere; rowcol=col; gm->GetCol(*this); }
173 
174 
175 inline void MatrixCol::Next() { gm->NextCol(*this); }
176 
177 inline void MatrixColX::Next() { gm->NextCol(*this); }
178 
179 #ifdef use_namespace
180 }
181 #endif
182 
183 #endif
184 
185 
Real DotProd(const MatrixRowCol &mrc1, const MatrixRowCol &mrc2)
Definition: newmat2.cpp:80
LoadAndStoreFlag(int i)
Definition: newmatrc.h:34
void IncrMat()
Definition: newmatrc.h:53
int Storage()
Definition: newmatrc.h:101
int Length()
Definition: newmatrc.h:102
Real Sum(const BaseMatrix &B)
Definition: newmat.h:2107
GeneralMatrix * gm
Definition: newmatrc.h:50
void IncrId()
Definition: newmatrc.h:55
void Skip(int i)
Definition: newmatrc.h:103
double Real
Definition: include.h:307
#define FREE_CHECK(Class)
Definition: myexcept.h:328
static void Add(GeneralMatrix *gm, GeneralMatrix *gm1, GeneralMatrix *gm2)
Definition: newmat7.cpp:131
int Skip()
Definition: newmatrc.h:100
KPMatrix KP(const BaseMatrix &, const BaseMatrix &)
Definition: newmat6.cpp:281
MatrixColX(GeneralMatrix *, Real *, LoadAndStoreFlag, int=0)
Definition: newmatrc.h:170
void IncrDiag()
Definition: newmatrc.h:54
void IncrUT()
Definition: newmatrc.h:56
void Next()
Definition: newmatrc.h:177
Real * data
Definition: newmatrc.h:51
int storage
Definition: newmatrc.h:48
MatrixRow(GeneralMatrix *, LoadAndStoreFlag, int=0)
Definition: newmatrc.h:158
Real * Data()
Definition: newmatrc.h:99
Real * store
Definition: newmatrc.h:151
void Storage(int i)
Definition: newmatrc.h:104
LoadAndStoreFlag(const ControlWord &cwx)
Definition: newmatrc.h:36
LoadAndStoreFlag cw
Definition: newmatrc.h:52
Real SumAbsoluteValue(const BaseMatrix &B)
Definition: newmat.h:2103
void Next()
Definition: newmatrc.h:175
LSF
Definition: newmatrc.h:25
int rowcol
Definition: newmatrc.h:49
MatrixCol(GeneralMatrix *, LoadAndStoreFlag, int=0)
Definition: newmatrc.h:163
void Length(int i)
Definition: newmatrc.h:105
void IncrLT()
Definition: newmatrc.h:57
The classes for matrices that can contain data are derived from this.
Definition: newmat.h:447
LoadAndStoreFlag(LSF lsf)
Definition: newmatrc.h:35
void Next()
Definition: newmatrc.h:161
int length
Definition: newmatrc.h:46


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