general.h
Go to the documentation of this file.
00001 #ifndef NEW_MAT_GENERAL_H
00002 #define NEW_MAT_GENERAL_H
00003 
00004 #ifdef use_namespace
00005 namespace NEWMAT { using namespace RBD_COMMON; }
00006 namespace RBD_LIBRARIES { using namespace NEWMAT; }
00007 namespace NEWMAT {
00008 #endif
00009 
00010 //#define DO_REPORT                     // to activate REPORT
00011 
00012 #ifdef NO_LONG_NAMES
00013 #define UpperTriangularMatrix UTMatrix
00014 #define LowerTriangularMatrix LTMatrix
00015 #define SymmetricMatrix SMatrix
00016 #define DiagonalMatrix DMatrix
00017 #define BandMatrix BMatrix
00018 #define UpperBandMatrix UBMatrix
00019 #define LowerBandMatrix LBMatrix
00020 #define SymmetricBandMatrix SBMatrix
00021 #define BandLUMatrix BLUMatrix
00022 #endif
00023 
00024 // ************************** general utilities ****************************/
00025 
00026 class GeneralMatrix;                            // defined later
00027 class BaseMatrix;                               // defined later
00028 class MatrixInput;                              // defined later
00029 
00030 void MatrixErrorNoSpace(const void*);           
00031 
00034 class LogAndSign
00035 {
00036    Real log_val;
00037    int sign_val;
00038 public:
00039    LogAndSign() { log_val=0.0; sign_val=1; }
00040    LogAndSign(Real);
00041    void operator*=(Real);                       
00042    void pow_eq(int k);                          
00043    void PowEq(int k) { pow_eq(k); }
00044    void ChangeSign() { sign_val = -sign_val; }
00045    void change_sign() { sign_val = -sign_val; } 
00046    Real LogValue() const { return log_val; }
00047    Real log_value() const { return log_val; }   
00048    int Sign() const { return sign_val; }
00049    int sign() const { return sign_val; }        
00050    Real value() const;                          
00051    Real Value() const { return value(); }
00052    FREE_CHECK(LogAndSign)
00053 };
00054 
00055 // the following class is for counting the number of times a piece of code
00056 // is executed. It is used for locating any code not executed by test
00057 // routines. Use turbo GREP locate all places this code is called and
00058 // check which ones are not accessed.
00059 // Somewhat implementation dependent as it relies on "cout" still being
00060 // present when ExeCounter objects are destructed.
00061 
00062 #ifdef DO_REPORT
00063 
00064 class ExeCounter
00065 {
00066    int line;                                    // code line number
00067    int fileid;                                  // file identifier
00068    long nexe;                                   // number of executions
00069    static int nreports;                         // number of reports
00070 public:
00071    ExeCounter(int,int);
00072    void operator++() { nexe++; }
00073    ~ExeCounter();                               // prints out reports
00074 };
00075 
00076 #endif
00077 
00078 
00079 // ************************** class MatrixType *****************************
00080 
00084 
00085 class MatrixType
00086 {
00087 public:
00088    enum Attribute {  Valid     = 1,
00089                      Diagonal  = 2,             // order of these is important
00090                      Symmetric = 4,
00091                      Band      = 8,
00092                      Lower     = 16,
00093                      Upper     = 32,
00094                      Square    = 64,
00095                      Skew      = 128,
00096                      LUDeco    = 256,
00097                      Ones      = 512 };
00098 
00099    enum            { US = 0,
00100                      UT = Valid + Upper + Square,
00101                      LT = Valid + Lower + Square,
00102                      Rt = Valid,
00103                      Sq = Valid + Square,
00104                      Sm = Valid + Symmetric + Square,
00105                      Sk = Valid + Skew + Square,
00106                      Dg = Valid + Diagonal + Band + Lower + Upper + Symmetric
00107                         + Square,
00108                      Id = Valid + Diagonal + Band + Lower + Upper + Symmetric
00109                         + Square + Ones,
00110                      RV = Valid,     //   do not separate out
00111                      CV = Valid,     //   vectors
00112                      BM = Valid + Band + Square,
00113                      UB = Valid + Band + Upper + Square,
00114                      LB = Valid + Band + Lower + Square,
00115                      SB = Valid + Band + Symmetric + Square,
00116                      KB = Valid + Band + Skew + Square,
00117                      Ct = Valid + LUDeco + Square,
00118                      BC = Valid + Band + LUDeco + Square,
00119                      Mask = ~Square
00120                    };
00121 
00122 
00123    static int nTypes() { return 13; }          // number of different types
00124                                                // exclude Ct, US, BC
00125 public:
00126    int attribute;
00127    bool DataLossOK;                            // true if data loss is OK when
00128                                                // this represents a destination
00129 public:
00130    MatrixType () : DataLossOK(false) {}
00131    MatrixType (int i) : attribute(i), DataLossOK(false) {}
00132    MatrixType (int i, bool dlok) : attribute(i), DataLossOK(dlok) {}
00133    MatrixType (const MatrixType& mt)
00134       : attribute(mt.attribute), DataLossOK(mt.DataLossOK) {}
00135    void operator=(const MatrixType& mt)
00136       { attribute = mt.attribute; DataLossOK = mt.DataLossOK; }
00137    void SetDataLossOK() { DataLossOK = true; }
00138    int operator+() const { return attribute; }
00139    MatrixType operator+(MatrixType mt) const
00140       { return MatrixType(attribute & mt.attribute); }
00141    MatrixType operator*(const MatrixType&) const;
00142    MatrixType SP(const MatrixType&) const;
00143    MatrixType KP(const MatrixType&) const;
00144    MatrixType operator|(const MatrixType& mt) const
00145       { return MatrixType(attribute & mt.attribute & Valid); }
00146    MatrixType operator&(const MatrixType& mt) const
00147       { return MatrixType(attribute & mt.attribute & Valid); }
00148    bool operator>=(MatrixType mt) const
00149       { return ( attribute & ~mt.attribute & Mask ) == 0; }
00150    bool operator<(MatrixType mt) const         // for MS Visual C++ 4
00151       { return ( attribute & ~mt.attribute & Mask ) != 0; }
00152    bool operator==(MatrixType t) const
00153       { return (attribute == t.attribute); }
00154    bool operator!=(MatrixType t) const
00155       { return (attribute != t.attribute); }
00156    bool operator!() const { return (attribute & Valid) == 0; }
00157    MatrixType i() const;                       
00158    MatrixType t() const;                       
00159    MatrixType AddEqualEl() const               
00160       { return MatrixType(attribute & (Valid + Symmetric + Square)); }
00161    MatrixType MultRHS() const;                 
00162    MatrixType sub() const                      
00163       { return MatrixType(attribute & Valid); }
00164    MatrixType ssub() const                     
00165       { return MatrixType(attribute); }        // not for selection matrix
00166    GeneralMatrix* New() const;                 
00167    GeneralMatrix* New(int,int,BaseMatrix*) const;
00169    const char* value() const;                  
00170    const char* Value() const { return value(); }
00171    friend bool Rectangular(MatrixType a, MatrixType b, MatrixType c);
00172    friend bool Compare(const MatrixType&, MatrixType&);
00174    bool is_band() const { return (attribute & Band) != 0; }
00175    bool is_diagonal() const { return (attribute & Diagonal) != 0; }
00176    bool is_symmetric() const { return (attribute & Symmetric) != 0; }
00177    bool CannotConvert() const { return (attribute & LUDeco) != 0; }
00178                                                // used by operator==
00179    FREE_CHECK(MatrixType)
00180 };
00181 
00182 
00183 // *********************** class MatrixBandWidth ***********************/
00184 
00189 class MatrixBandWidth
00190 {
00191 public:
00192    int lower_val;
00193    int upper_val;
00194    MatrixBandWidth() : lower_val(0), upper_val(0) {}
00195    MatrixBandWidth(const int l, const int u) : lower_val(l), upper_val(u) {}
00196    MatrixBandWidth(const int i) : lower_val(i), upper_val(i) {}
00197    MatrixBandWidth operator+(const MatrixBandWidth&) const;
00198    MatrixBandWidth operator*(const MatrixBandWidth&) const;
00199    MatrixBandWidth minimum(const MatrixBandWidth&) const;
00200    MatrixBandWidth t() const { return MatrixBandWidth(upper_val,lower_val); }
00201    bool operator==(const MatrixBandWidth& bw) const
00202       { return (lower_val == bw.lower_val) && (upper_val == bw.upper_val); }
00203    bool operator!=(const MatrixBandWidth& bw) const { return !operator==(bw); }
00204    int Upper() const { return upper_val; }
00205    int upper() const { return upper_val; }
00206    int Lower() const { return lower_val; }
00207    int lower() const { return lower_val; }
00208    FREE_CHECK(MatrixBandWidth)
00209 };
00210 
00211 
00212 // ********************* Array length specifier ************************/
00213 
00217 
00218 class ArrayLengthSpecifier
00219 {
00220    int v;
00221 public:
00222    int Value() const { return v; }
00223    int value() const { return v; }
00224    ArrayLengthSpecifier(int l) : v(l) {}
00225 };
00226 
00227 // ************************* Matrix routines ***************************/
00228 
00229 
00230 class MatrixRowCol;                             // defined later
00231 class MatrixRow;
00232 class MatrixCol;
00233 class MatrixColX;
00234 
00235 class GeneralMatrix;                            // defined later
00236 class AddedMatrix;
00237 class MultipliedMatrix;
00238 class SubtractedMatrix;
00239 class SPMatrix;
00240 class KPMatrix;
00241 class ConcatenatedMatrix;
00242 class StackedMatrix;
00243 class SolvedMatrix;
00244 class ShiftedMatrix;
00245 class NegShiftedMatrix;
00246 class ScaledMatrix;
00247 class TransposedMatrix;
00248 class ReversedMatrix;
00249 class NegatedMatrix;
00250 class InvertedMatrix;
00251 class RowedMatrix;
00252 class ColedMatrix;
00253 class DiagedMatrix;
00254 class MatedMatrix;
00255 class GetSubMatrix;
00256 class ReturnMatrix;
00257 class Matrix;
00258 class SquareMatrix;
00259 class nricMatrix;
00260 class RowVector;
00261 class ColumnVector;
00262 class SymmetricMatrix;
00263 class UpperTriangularMatrix;
00264 class LowerTriangularMatrix;
00265 class DiagonalMatrix;
00266 class CroutMatrix;
00267 class BandMatrix;
00268 class LowerBandMatrix;
00269 class UpperBandMatrix;
00270 class SymmetricBandMatrix;
00271 class LinearEquationSolver;
00272 class GenericMatrix;
00273 
00274 #endif
00275 


lo
Author(s): U. Klank
autogenerated on Mon Oct 6 2014 10:44:13