Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

Newmat.h Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Newmat.h

Go to the documentation of this file.
00001 //Owner: Fred
00002 //$$ newmat.h           definition file for new version of matrix package
00003 
00004 // Copyright (C) 1991,2,3,4,7: R B Davies
00005 
00006 #ifndef NEWMAT_LIB
00007 #define NEWMAT_LIB 0
00008 
00009 #include "include.h"
00010 
00011 // #include "boolean.h"
00012 #include "myexcept.h"
00013 
00014 #ifdef use_namespace
00015 namespace NEWMAT { using namespace RBD_COMMON; }
00016 namespace RBD_LIBRARIES { using namespace NEWMAT; }
00017 namespace NEWMAT {
00018 #endif
00019 
00020     // #define DO_REPORT                     // to activate REPORT
00021 
00022 #ifdef NO_LONG_NAMES
00023 #define UpperTriangularMatrix UTMatrix
00024 #define LowerTriangularMatrix LTMatrix
00025 #define SymmetricMatrix SMatrix
00026 #define DiagonalMatrix DMatrix
00027 #define BandMatrix BMatrix
00028 #define UpperBandMatrix UBMatrix
00029 #define LowerBandMatrix LBMatrix
00030 #define SymmetricBandMatrix SBMatrix
00031 #define BandLUMatrix BLUMatrix
00032 #endif
00033 
00034 #ifndef TEMPS_DESTROYED_QUICKLY_R
00035 #define ReturnMatrix ReturnMatrixX
00036 #else
00037 #define ReturnMatrix ReturnMatrixX&
00038 #endif
00039 
00040     /**************************** general utilities ****************************/
00041 
00042     class GeneralMatrix;
00043     void MatrixErrorNoSpace(void*);                 // no space handler
00044 
00047     class LogAndSign {
00048         // Return from LogDeterminant function
00049         //    - value of the log plus the sign (+, - or 0)
00050         Real log_value;
00051         int sign;
00052     public:
00053         LogAndSign() { log_value=0.0; sign=1; }
00054         LogAndSign(Real);
00055         void operator*=(Real);
00056         void ChangeSign() { sign = -sign; }
00057         Real LogValue() const { return log_value; }
00058         int Sign() const { return sign; }
00059         Real Value() const;
00060         FREE_CHECK(LogAndSign)
00061             };
00062 
00063     // the following class is for counting the number of times a piece of code
00064     // is executed. It is used for locating any code not executed by test
00065     // routines. Use turbo GREP locate all places this code is called and
00066     // check which ones are not accessed.
00067     // Somewhat implementation dependent as it relies on "cout" still being
00068     // present when ExeCounter objects are destructed.
00069 
00070 #ifdef DO_REPORT
00071 
00073     class ExeCounter {
00074         int line;                                     // code line number
00075         int fileid;                                   // file identifier
00076         long nexe;                                    // number of executions
00077         static int nreports;                          // number of reports
00078     public:
00079         ExeCounter(int,int);
00080         void operator++() { nexe++; }
00081         ~ExeCounter();                              // prints out reports
00082     };
00083 #endif
00084 
00085     /************** Class to show whether to check for loss of data ************/
00086 
00089     class MatrixConversionCheck {
00090         static bool DoCheck;
00091     public:
00092         MatrixConversionCheck() {                   // turn check on
00093             DoCheck=true;
00094         }
00095         ~MatrixConversionCheck() {                  // turn check off
00096             DoCheck=false;
00097         }
00098         void CleanUp() { DoCheck=false; }
00099         static bool IsOn() { return DoCheck; }
00100         static void DataLoss();
00101         friend class SkipConversionCheck;
00102     };
00103 
00106     class SkipConversionCheck {
00107         // to turn check off in current block
00108         bool LastValue;
00109     public:
00110         SkipConversionCheck() : LastValue(MatrixConversionCheck::DoCheck)
00111             { MatrixConversionCheck::DoCheck = false; }
00112         ~SkipConversionCheck() { MatrixConversionCheck::DoCheck = LastValue; }
00113         void CleanUp() { MatrixConversionCheck::DoCheck = LastValue; }
00114     };
00115 
00116     /**************************** class MatrixType *****************************/
00117 
00118     // Is used for finding the type of a matrix resulting from the binary operations
00119     // +, -, * and identifying what conversions are permissible.
00120     // This class must be updated when new matrix types are added.
00121 
00122     class GeneralMatrix;                            // defined later
00123     class BaseMatrix;                               // defined later
00124     class MatrixInput;                              // defined later
00125 
00129     class MatrixType {
00130     public:
00131         enum Attribute {
00132             Valid     = 1,
00133             Diagonal  = 2,                            // order of these is important
00134             Symmetric = 4,
00135             Band      = 8,
00136             Lower     = 16,
00137             Upper     = 32,
00138             LUDeco    = 64
00139         };
00140 
00141         enum {
00142             US = 0,
00143             UT = Valid + Upper,
00144             LT = Valid + Lower,
00145             Rt = Valid,
00146             Sm = Valid + Symmetric,
00147             Dg = Valid + Diagonal + Band + Lower + Upper + Symmetric,
00148             RV = Valid,                               //   don't separate out
00149             CV = Valid,                               //   vectors
00150             BM = Valid + Band,
00151             UB = Valid + Band + Upper,
00152             LB = Valid + Band + Lower,
00153             SB = Valid + Band + Symmetric,
00154             Ct = Valid + LUDeco,
00155             BC = Valid + Band + LUDeco
00156         };
00157 
00158         static nTypes() {                           // number of different types
00159             return 9;
00160         }
00161         // exclude Ct, US, BC
00162     public:
00163         int attribute;
00164     public:
00165         MatrixType () {}
00166         MatrixType (int i) : attribute(i) {}
00167         int operator+() const { return attribute; }
00168         MatrixType operator+(MatrixType mt) const
00169             { return MatrixType(attribute & mt.attribute); }
00170         MatrixType operator*(const MatrixType&) const;
00171         MatrixType SP(const MatrixType&) const;
00172         MatrixType operator|(const MatrixType& mt) const
00173             { return MatrixType(attribute & mt.attribute & Valid); }
00174         MatrixType operator&(const MatrixType& mt) const
00175             { return MatrixType(attribute & mt.attribute & Valid); }
00176         bool operator>=(MatrixType mt) const
00177             { return ( attribute & mt.attribute ) == attribute; }
00178         bool operator<(MatrixType mt) const         // for MS Visual C++ 4
00179             { return ( attribute & mt.attribute ) != attribute; }
00180         bool operator==(MatrixType t) const
00181             { return (attribute == t.attribute); }
00182         bool operator!=(MatrixType t) const
00183             { return (attribute != t.attribute); }
00184         bool operator!() const { return (attribute & Valid) == 0; }
00185         MatrixType i() const;                       // type of inverse
00186         MatrixType t() const;                       // type of transpose
00187         MatrixType AddEqualEl() const               // Add constant to matrix
00188             { return MatrixType(attribute & (Valid + Symmetric)); }
00189         MatrixType MultRHS() const;                 // type for rhs of multiply
00190         MatrixType sub() const                      // type of submatrix
00191             { return MatrixType(attribute & Valid); }
00192         MatrixType ssub() const {                   // type of sym submatrix
00193             // not for selection matrix
00194             return MatrixType(attribute);
00195         }
00196         GeneralMatrix* New() const;                 // new matrix of given type
00197         GeneralMatrix* New(int,int,BaseMatrix*) const;
00198         // new matrix of given type
00199         char* Value() const;                        // to print type
00200         friend bool Rectangular(MatrixType a, MatrixType b, MatrixType c);
00201         friend bool Compare(const MatrixType&, MatrixType&);
00202         // compare and check conv.
00203         bool IsBand() const { return (attribute & Band) != 0; }
00204         bool IsDiagonal() const { return (attribute & Diagonal) != 0; }
00205         bool CannotConvert() const { return (attribute & LUDeco) != 0; }
00206         // used by operator==
00207         FREE_CHECK(MatrixType)
00208             };
00209 
00210     /************************* class MatrixBandWidth ***********************/
00211 
00214     class MatrixBandWidth {
00215     public:
00216         int lower;
00217         int upper;
00218         MatrixBandWidth(const int l, const int u) : lower(l), upper (u) {}
00219         MatrixBandWidth(const int i) : lower(i), upper(i) {}
00220         MatrixBandWidth operator+(const MatrixBandWidth&) const;
00221         MatrixBandWidth operator*(const MatrixBandWidth&) const;
00222         MatrixBandWidth minimum(const MatrixBandWidth&) const;
00223         MatrixBandWidth t() const { return MatrixBandWidth(upper,lower); }
00224         bool operator==(const MatrixBandWidth& bw) const
00225             { return (lower == bw.lower) && (upper == bw.upper); }
00226         int Upper() const { return upper; }
00227         int Lower() const { return lower; }
00228         FREE_CHECK(MatrixBandWidth)
00229             };
00230 
00231     /*********************** Array length specifier ************************/
00232 
00233     // This class is introduced to avoid constructors such as
00234     //   ColumnVector(int)
00235     // being used for conversions
00236 
00239     class ArrayLengthSpecifier {
00240         int value;
00241     public:
00242         int Value() const { return value; }
00243         ArrayLengthSpecifier(int l) : value(l) {}
00244     };
00245 
00246     /*************************** Matrix routines ***************************/
00247 
00248     class MatrixRowCol;                             // defined later
00249     class MatrixRow;
00250     class MatrixCol;
00251     class MatrixColX;
00252 
00253     class GeneralMatrix;                            // defined later
00254     class AddedMatrix;
00255     class MultipliedMatrix;
00256     class SubtractedMatrix;
00257     class SPMatrix;
00258     class ConcatenatedMatrix;
00259     class StackedMatrix;
00260     class SolvedMatrix;
00261     class ShiftedMatrix;
00262     class NegShiftedMatrix;
00263     class ScaledMatrix;
00264     class TransposedMatrix;
00265     class ReversedMatrix;
00266     class NegatedMatrix;
00267     class InvertedMatrix;
00268     class RowedMatrix;
00269     class ColedMatrix;
00270     class DiagedMatrix;
00271     class MatedMatrix;
00272     class GetSubMatrix;
00273     class ReturnMatrixX;
00274     class Matrix;
00275     class nricMatrix;
00276     class RowVector;
00277     class ColumnVector;
00278     class SymmetricMatrix;
00279     class UpperTriangularMatrix;
00280     class LowerTriangularMatrix;
00281     class DiagonalMatrix;
00282     class CroutMatrix;
00283     class BandMatrix;
00284     class LowerBandMatrix;
00285     class UpperBandMatrix;
00286     class SymmetricBandMatrix;
00287     class LinearEquationSolver;
00288     class GenericMatrix;
00289 
00290     static MatrixType MatrixTypeUnSp(MatrixType::US);
00291     // AT&T needs this
00292 
00294     class BaseMatrix : public Janitor {             // base of all matrix classes
00295     protected:
00296         virtual int search(const BaseMatrix*) const = 0;
00297         // count number of times matrix
00298         // is referred to
00299 
00300     public:
00301         virtual GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp) = 0;
00302         // evaluate temporary
00303         // for old version of G++
00304         //   virtual GeneralMatrix* Evaluate(MatrixType mt) = 0;
00305         //   GeneralMatrix* Evaluate() { return Evaluate(MatrixTypeUnSp); }
00306 #ifndef TEMPS_DESTROYED_QUICKLY
00307         // results of operations
00308         AddedMatrix operator+(const BaseMatrix&) const;
00309         MultipliedMatrix operator*(const BaseMatrix&) const;
00310         SubtractedMatrix operator-(const BaseMatrix&) const;
00311         ConcatenatedMatrix operator|(const BaseMatrix&) const;
00312         StackedMatrix operator&(const BaseMatrix&) const;
00313         ShiftedMatrix operator+(Real) const;
00314         ScaledMatrix operator*(Real) const;
00315         ScaledMatrix operator/(Real) const;
00316         ShiftedMatrix operator-(Real) const;
00317         TransposedMatrix t() const;
00318         //   TransposedMatrix t;
00319         NegatedMatrix operator-() const;            // change sign of elements
00320         ReversedMatrix Reverse() const;
00321         InvertedMatrix i() const;
00322         //   InvertedMatrix i;
00323         RowedMatrix AsRow() const;
00324         ColedMatrix AsColumn() const;
00325         DiagedMatrix AsDiagonal() const;
00326         MatedMatrix AsMatrix(int,int) const;
00327         GetSubMatrix SubMatrix(int,int,int,int) const;
00328         GetSubMatrix SymSubMatrix(int,int) const;
00329         GetSubMatrix Row(int) const;
00330         GetSubMatrix Rows(int,int) const;
00331         GetSubMatrix Column(int) const;
00332         GetSubMatrix Columns(int,int) const;
00333 #else
00334         // results of operations
00335         AddedMatrix& operator+(const BaseMatrix&) const;
00336         MultipliedMatrix& operator*(const BaseMatrix&) const;
00337         SubtractedMatrix& operator-(const BaseMatrix&) const;
00338         ConcatenatedMatrix& operator|(const BaseMatrix&) const;
00339         StackedMatrix& operator&(const BaseMatrix&) const;
00340         ShiftedMatrix& operator+(Real) const;
00341         ScaledMatrix& operator*(Real) const;
00342         ScaledMatrix& operator/(Real) const;
00343         ShiftedMatrix& operator-(Real) const;
00344         TransposedMatrix& t() const;
00345         //   TransposedMatrix& t;
00346         NegatedMatrix& operator-() const;           // change sign of elements
00347         ReversedMatrix& Reverse() const;
00348         InvertedMatrix& i() const;
00349         //   InvertedMatrix& i;
00350         RowedMatrix& AsRow() const;
00351         ColedMatrix& AsColumn() const;
00352         DiagedMatrix& AsDiagonal() const;
00353         MatedMatrix& AsMatrix(int,int) const;
00354         GetSubMatrix& SubMatrix(int,int,int,int) const;
00355         GetSubMatrix& SymSubMatrix(int,int) const;
00356         GetSubMatrix& Row(int) const;
00357         GetSubMatrix& Rows(int,int) const;
00358         GetSubMatrix& Column(int) const;
00359         GetSubMatrix& Columns(int,int) const;
00360 #endif
00361         Real AsScalar() const;                      // conversion of 1 x 1 matrix
00362         virtual LogAndSign LogDeterminant() const;
00363         virtual Real SumSquare() const;
00364         virtual Real SumAbsoluteValue() const;
00365         virtual Real Sum() const;
00366         virtual Real MaximumAbsoluteValue() const;
00367         virtual Real MaximumValue() const;          // Fred 0512
00368         virtual Real MinimumValue() const;          // fred 0512
00369         virtual Real Trace() const;
00370         Real Norm1() const;
00371         Real NormInfinity() const;
00372         virtual MatrixBandWidth BandWidth() const;  // bandwidths of band matrix
00373         virtual void CleanUp() {                    // to clear store
00374         }
00375         void IEQND() const;                         // called by ineq. ops
00376         //   virtual ReturnMatrix Reverse() const;       // reverse order of elements
00377 
00378         //protected:
00379         //   BaseMatrix() : t(this), i(this) {}
00380 
00381         friend class GeneralMatrix;
00382         friend class Matrix;
00383         friend class nricMatrix;
00384         friend class RowVector;
00385         friend class ColumnVector;
00386         friend class SymmetricMatrix;
00387         friend class UpperTriangularMatrix;
00388         friend class LowerTriangularMatrix;
00389         friend class DiagonalMatrix;
00390         friend class CroutMatrix;
00391         friend class BandMatrix;
00392         friend class LowerBandMatrix;
00393         friend class UpperBandMatrix;
00394         friend class SymmetricBandMatrix;
00395         friend class AddedMatrix;
00396         friend class MultipliedMatrix;
00397         friend class SubtractedMatrix;
00398         friend class SPMatrix;
00399         friend class ConcatenatedMatrix;
00400         friend class StackedMatrix;
00401         friend class SolvedMatrix;
00402         friend class ShiftedMatrix;
00403         friend class NegShiftedMatrix;
00404         friend class ScaledMatrix;
00405         friend class TransposedMatrix;
00406         friend class ReversedMatrix;
00407         friend class NegatedMatrix;
00408         friend class InvertedMatrix;
00409         friend class RowedMatrix;
00410         friend class ColedMatrix;
00411         friend class DiagedMatrix;
00412         friend class MatedMatrix;
00413         friend class GetSubMatrix;
00414         friend class ReturnMatrixX;
00415         friend class LinearEquationSolver;
00416         friend class GenericMatrix;
00417         NEW_DELETE(BaseMatrix)
00418             };
00419 
00420     /******************************* working classes **************************/
00421 
00423     class GeneralMatrix : public BaseMatrix {       // declarable matrix types
00424         virtual GeneralMatrix* Image() const;         // copy of matrix
00425     protected:
00426         int tag;                                    // shows whether can reuse
00427         int nrows, ncols;                           // dimensions
00428         int storage;                                // total store required
00429         Real* store;                                // point to store (0=not set)
00430         GeneralMatrix();                            // initialise with no store
00431         GeneralMatrix(ArrayLengthSpecifier);        // constructor getting store
00432         void Add(GeneralMatrix*, Real);             // sum of GM and Real
00433         void Add(Real);                             // add Real to this
00434         void NegAdd(GeneralMatrix*, Real);          // Real - GM
00435         void NegAdd(Real);                          // this = this - Real
00436         void Multiply(GeneralMatrix*, Real);        // product of GM and Real
00437         void Multiply(Real);                        // multiply this by Real
00438         void Negate(GeneralMatrix*);                // change sign
00439         void Negate();                              // change sign
00440         void ReverseElements();                     // internal reverse of elements
00441         void ReverseElements(GeneralMatrix*);       // reverse order of elements
00442         void operator=(Real);                       // set matrix to constant
00443         Real* GetStore();                           // get store or copy
00444         GeneralMatrix* BorrowStore(GeneralMatrix*, MatrixType);
00445         // temporarily access store
00446         void GetMatrix(const GeneralMatrix*);       // used by = and initialise
00447         void Eq(const BaseMatrix&, MatrixType);     // used by =
00448         void Eq2(const BaseMatrix&, MatrixType);    // cut down version of Eq
00449         int search(const BaseMatrix*) const;
00450         virtual GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
00451         void CheckConversion(const BaseMatrix&);    // check conversion OK
00452         void ReSize(int, int, int);                 // change dimensions
00453     public:
00454         GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
00455         virtual MatrixType Type() const = 0;        // type of a matrix
00456         int Nrows() const {                         // get dimensions
00457             return nrows;
00458         }
00459         int Ncols() const { return ncols; }
00460         int Storage() const { return storage; }
00461         Real* Store() const { return store; }
00462         virtual ~GeneralMatrix();                   // delete store if set
00463         void tDelete();                             // delete if tag permits
00464         bool reuse();                               // true if tag allows reuse
00465         void Protect() {                            // can't delete or reuse
00466             tag=-1;
00467         }
00468         int Tag() const { return tag; }
00469         bool IsZero() const;                        // test matrix has all zeros
00470         void Release() {                            // del store after next use
00471             tag=1;
00472         }
00473         void Release(int t) {                       // del store after t accesses
00474             tag=t;
00475         }
00476         void ReleaseAndDelete() {                   // delete matrix after use
00477             tag=0;
00478         }
00479         void operator<<(const Real*);               // assignment from an array
00480         void operator<<(const BaseMatrix& X) { Eq(X,this->Type()); }
00481         // = without checking type
00482         void Inject(const GeneralMatrix&);          // copy stored els only
00483         void operator+=(const BaseMatrix&);
00484         void operator-=(const BaseMatrix&);
00485         void operator*=(const BaseMatrix&);
00486         void operator|=(const BaseMatrix&);
00487         void operator&=(const BaseMatrix&);
00488         void operator+=(Real);
00489         void operator-=(Real r) { operator+=(-r); }
00490         void operator*=(Real);
00491         void operator/=(Real r) { operator*=(1.0/r); }
00492 
00493         virtual GeneralMatrix* MakeSolver();        // for solving
00494         virtual void Solver(MatrixColX&, const MatrixColX&) {}
00495         virtual void GetRow(MatrixRowCol&) = 0;     // Get matrix row
00496         virtual void RestoreRow(MatrixRowCol&) {    // Restore matrix row
00497         }
00498         virtual void NextRow(MatrixRowCol&);        // Go to next row
00499         virtual void GetCol(MatrixRowCol&) = 0;     // Get matrix col
00500         virtual void GetCol(MatrixColX&) = 0;       // Get matrix col
00501         virtual void RestoreCol(MatrixRowCol&) {    // Restore matrix col
00502         }
00503         virtual void RestoreCol(MatrixColX&) {      // Restore matrix col
00504         }
00505         virtual void NextCol(MatrixRowCol&);        // Go to next col
00506         virtual void NextCol(MatrixColX&);          // Go to next col
00507         Real SumSquare() const;
00508         Real SumAbsoluteValue() const;
00509         Real Sum() const;
00510         Real MaximumAbsoluteValue() const;
00511         Real MaximumValue() const;                  // Fred 0512
00512         Real MinimumValue() const;                  // Fred 0512
00513         LogAndSign LogDeterminant() const;
00514         virtual bool IsEqual(const GeneralMatrix&) const;
00515         // same type, same values
00516         void CheckStore() const;                    // check store is non-zero
00517         virtual void SetParameters(const GeneralMatrix*) {}
00518         // set parameters in GetMatrix
00519         operator ReturnMatrix() const;              // for building a ReturnMatrix
00520         ReturnMatrix ForReturn() const;
00521         MatrixInput operator<<(Real);               // for loading a list
00522         //   ReturnMatrix Reverse() const;                // reverse order of elements
00523         void CleanUp();                             // to clear store
00524 
00525         friend class Matrix;
00526         friend class nricMatrix;
00527         friend class SymmetricMatrix;
00528         friend class UpperTriangularMatrix;
00529         friend class LowerTriangularMatrix;
00530         friend class DiagonalMatrix;
00531         friend class CroutMatrix;
00532         friend class RowVector;
00533         friend class ColumnVector;
00534         friend class BandMatrix;
00535         friend class LowerBandMatrix;
00536         friend class UpperBandMatrix;
00537         friend class SymmetricBandMatrix;
00538         friend class BaseMatrix;
00539         friend class AddedMatrix;
00540         friend class MultipliedMatrix;
00541         friend class SubtractedMatrix;
00542         friend class SPMatrix;
00543         friend class ConcatenatedMatrix;
00544         friend class StackedMatrix;
00545         friend class SolvedMatrix;
00546         friend class ShiftedMatrix;
00547         friend class NegShiftedMatrix;
00548         friend class ScaledMatrix;
00549         friend class TransposedMatrix;
00550         friend class ReversedMatrix;
00551         friend class NegatedMatrix;
00552         friend class InvertedMatrix;
00553         friend class RowedMatrix;
00554         friend class ColedMatrix;
00555         friend class DiagedMatrix;
00556         friend class MatedMatrix;
00557         friend class GetSubMatrix;
00558         friend class ReturnMatrixX;
00559         friend class LinearEquationSolver;
00560         friend class GenericMatrix;
00561         NEW_DELETE(GeneralMatrix)
00562             };
00563 
00566     class Matrix : public GeneralMatrix {           // usual rectangular matrix
00567         GeneralMatrix* Image() const;                 // copy of matrix
00568     public:
00569         Matrix() {}
00570         Matrix(int, int);                           // standard declaration
00571         Matrix(const BaseMatrix&);                  // evaluate BaseMatrix
00572         void operator=(const BaseMatrix&);
00573         void operator=(Real f) { GeneralMatrix::operator=(f); }
00574         void operator=(const Matrix& m) { operator=((const BaseMatrix&)m); }
00575         MatrixType Type() const;
00576         Real& operator()(int, int);                 // access element
00577         Real& element(int, int);                    // access element
00578 #ifdef SETUP_C_SUBSCRIPTS
00579         Real* operator[](int m) { return store+m*ncols; }
00580         const Real* operator[](int m) const { return store+m*ncols; }
00581 #endif
00582         Matrix(const Matrix& gm) { GetMatrix(&gm); }
00583         Real operator()(int, int) const;            // access element
00584         GeneralMatrix* MakeSolver();
00585         Real Trace() const;
00586         void GetRow(MatrixRowCol&);
00587         void GetCol(MatrixRowCol&);
00588         void GetCol(MatrixColX&);
00589         void RestoreCol(MatrixRowCol&);
00590         void RestoreCol(MatrixColX&);
00591         void NextRow(MatrixRowCol&);
00592         void NextCol(MatrixRowCol&);
00593         void NextCol(MatrixColX&);
00594         virtual void ReSize(int,int);               // change dimensions
00595         // virtual so we will catch it being used in a vector called as a matrix
00596         NEW_DELETE(Matrix)
00597             };
00598 
00600     class nricMatrix : public Matrix {              // for use with Numerical
00601         // Recipes in C
00602         GeneralMatrix* Image() const;                 // copy of matrix
00603         Real** row_pointer;                           // points to rows
00604         void MakeRowPointer();                        // build rowpointer
00605         void DeleteRowPointer();
00606     public:
00607         nricMatrix() {}
00608         nricMatrix(int m, int n)                    // standard declaration
00609             :  Matrix(m,n) { MakeRowPointer(); }
00610         nricMatrix(const BaseMatrix& bm)            // evaluate BaseMatrix
00611             :  Matrix(bm) { MakeRowPointer(); }
00612         void operator=(const BaseMatrix& bm)
00613             { DeleteRowPointer(); Matrix::operator=(bm); MakeRowPointer(); }
00614         void operator=(Real f) { GeneralMatrix::operator=(f); }
00615         void operator=(const nricMatrix& m) { operator=((const BaseMatrix&)m); }
00616         void operator<<(const BaseMatrix& X)
00617             { DeleteRowPointer(); Eq(X,this->Type()); MakeRowPointer(); }
00618         nricMatrix(const nricMatrix& gm) { GetMatrix(&gm); MakeRowPointer(); }
00619         void ReSize(int m, int n)                   // change dimensions
00620             { DeleteRowPointer(); Matrix::ReSize(m,n); MakeRowPointer(); }
00621         ~nricMatrix() { DeleteRowPointer(); }
00622         Real** nric() const { CheckStore(); return row_pointer-1; }
00623         void CleanUp();                             // to clear store
00624         NEW_DELETE(nricMatrix)
00625             };
00626 
00628     class SymmetricMatrix : public GeneralMatrix {
00629         GeneralMatrix* Image() const;                 // copy of matrix
00630     public:
00631         SymmetricMatrix() {}
00632         SymmetricMatrix(ArrayLengthSpecifier);
00633         SymmetricMatrix(const BaseMatrix&);
00634         void operator=(const BaseMatrix&);
00635         void operator=(Real f) { GeneralMatrix::operator=(f); }
00636         void operator=(const SymmetricMatrix& m) { operator=((const BaseMatrix&)m); }
00637         Real& operator()(int, int);                 // access element
00638         Real& element(int, int);                    // access element
00639 #ifdef SETUP_C_SUBSCRIPTS
00640         Real* operator[](int m) { return store+(m*(m+1))/2; }
00641         const Real* operator[](int m) const { return store+(m*(m+1))/2; }
00642 #endif
00643         MatrixType Type() const;
00644         SymmetricMatrix(const SymmetricMatrix& gm) { GetMatrix(&gm); }
00645         Real operator()(int, int) const;            // access element
00646         Real SumSquare() const;
00647         Real SumAbsoluteValue() const;
00648         Real Sum() const;
00649         Real Trace() const;
00650         void GetRow(MatrixRowCol&);
00651         void GetCol(MatrixRowCol&);
00652         void GetCol(MatrixColX&);
00653         void RestoreCol(MatrixRowCol&) {}
00654         void RestoreCol(MatrixColX&);
00655         GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
00656         void ReSize(int);                           // change dimensions
00657         NEW_DELETE(SymmetricMatrix)
006