00001
00002
00003
00004
00005
00006 #ifndef NEWMATRC_LIB
00007 #define NEWMATRC_LIB 0
00008
00009 #ifdef use_namespace
00010 namespace NEWMAT {
00011 #endif
00012
00013 #include "controlw.h"
00014
00015
00016
00017
00018
00019
00020
00021 enum LSF { LoadOnEntry=1,StoreOnExit=2,DirectPart=4,StoreHere=8,HaveStore=16 };
00022
00024 class LoadAndStoreFlag : public ControlWord {
00025 public:
00026 LoadAndStoreFlag() {}
00027 LoadAndStoreFlag(int i) : ControlWord(i) {}
00028 LoadAndStoreFlag(LSF lsf) : ControlWord(lsf) {}
00029 LoadAndStoreFlag(const ControlWord& cwx) : ControlWord(cwx) {}
00030 };
00031
00033 class MatrixRowCol {
00034
00035 public:
00036
00037 int length;
00038 int skip;
00039 int storage;
00040 int rowcol;
00041 GeneralMatrix* gm;
00042 Real* data;
00043 LoadAndStoreFlag cw;
00044 void IncrMat() { rowcol++; data += storage; }
00045
00046 void IncrDiag() { rowcol++; skip++; data++; }
00047 void IncrUT()
00048 { rowcol++; data += storage; storage--; skip++; }
00049 void IncrLT() { rowcol++; data += storage; storage++; }
00050
00051 public:
00052 void Add(const MatrixRowCol&);
00053 void AddScaled(const MatrixRowCol&, Real);
00054 void Add(const MatrixRowCol&, const MatrixRowCol&);
00055
00056 void Add(const MatrixRowCol&, Real);
00057 void NegAdd(const MatrixRowCol&, Real);
00058 void Sub(const MatrixRowCol&);
00059 void Sub(const MatrixRowCol&, const MatrixRowCol&);
00060
00061 void RevSub(const MatrixRowCol&);
00062 void ConCat(const MatrixRowCol&, const MatrixRowCol&);
00063
00064 void Multiply(const MatrixRowCol&);
00065 void Multiply(const MatrixRowCol&, const MatrixRowCol&);
00066
00067 void Copy(const MatrixRowCol&);
00068 void CopyCheck(const MatrixRowCol&);
00069 void Check(const MatrixRowCol&);
00070 void Check();
00071 void Copy(const Real*&);
00072 void Copy(Real);
00073 void Add(Real);
00074 void Multiply(Real);
00075 Real SumAbsoluteValue();
00076 Real Sum();
00077 void Inject(const MatrixRowCol&);
00078 void Negate(const MatrixRowCol&);
00079 void Multiply(const MatrixRowCol&, Real);
00080 friend Real DotProd(const MatrixRowCol&, const MatrixRowCol&);
00081
00082 Real* Data() { return data; }
00083 int Skip() {
00084 return skip;
00085 }
00086 int Storage() {
00087 return storage;
00088 }
00089 int Length() {
00090 return length;
00091 }
00092 void Skip(int i) { skip=i; }
00093 void Storage(int i) { storage=i; }
00094 void Length(int i) { length=i; }
00095 void SubRowCol(MatrixRowCol&, int, int) const;
00096
00097 MatrixRowCol() {
00098 }
00099 ~MatrixRowCol();
00100 FREE_CHECK(MatrixRowCol)
00101 };
00102
00104 class MatrixRow : public MatrixRowCol {
00105 public:
00106
00107 MatrixRow(GeneralMatrix*, LoadAndStoreFlag, int=0);
00108
00109 ~MatrixRow();
00110 void Next();
00111 FREE_CHECK(MatrixRow)
00112 };
00113
00115 class MatrixCol : public MatrixRowCol {
00116 public:
00117
00118 MatrixCol(GeneralMatrix*, LoadAndStoreFlag, int=0);
00119
00120 MatrixCol(GeneralMatrix*, Real*, LoadAndStoreFlag, int=0);
00121
00122 ~MatrixCol();
00123 void Next();
00124 FREE_CHECK(MatrixCol)
00125 };
00126
00127
00128
00129
00132 class MatrixColX : public MatrixRowCol {
00133 public:
00134
00135 MatrixColX(GeneralMatrix*, Real*, LoadAndStoreFlag, int=0);
00136
00137 ~MatrixColX();
00138 void Next();
00139 Real* store;
00140
00141 FREE_CHECK(MatrixColX)
00142 };
00143
00144
00145
00146 inline MatrixRow::MatrixRow(GeneralMatrix* gmx, LoadAndStoreFlag cwx, int row)
00147 { gm=gmx; cw=cwx; rowcol=row; gm->GetRow(*this); }
00148
00149 inline void MatrixRow::Next() { gm->NextRow(*this); }
00150
00151 inline MatrixCol::MatrixCol(GeneralMatrix* gmx, LoadAndStoreFlag cwx, int col)
00152 { gm=gmx; cw=cwx; rowcol=col; gm->GetCol(*this); }
00153
00154 inline MatrixCol::MatrixCol(GeneralMatrix* gmx, Real* r,
00155 LoadAndStoreFlag cwx, int col)
00156 { gm=gmx; data=r; cw=cwx+StoreHere; rowcol=col; gm->GetCol(*this); }
00157
00158 inline MatrixColX::MatrixColX(GeneralMatrix* gmx, Real* r,
00159 LoadAndStoreFlag cwx, int col)
00160 { gm=gmx; store=data=r; cw=cwx+StoreHere; rowcol=col; gm->GetCol(*this); }
00161
00162 inline void MatrixCol::Next() { gm->NextCol(*this); }
00163
00164 inline void MatrixColX::Next() { gm->NextCol(*this); }
00165
00166 #ifdef use_namespace
00167 }
00168 #endif
00169 #endif