00001
00002
00003
00004
00005 #ifndef NEWMAT_LIB
00006 #define NEWMAT_LIB 0
00007
00008 #include "include.h"
00009
00010 #include "myexcept.h"
00011
00012
00013 #ifdef use_namespace
00014 namespace NEWMAT { using namespace RBD_COMMON; }
00015 namespace RBD_LIBRARIES { using namespace NEWMAT; }
00016 namespace NEWMAT {
00017 #endif
00018
00019
00020
00021 #ifdef NO_LONG_NAMES
00022 #define UpperTriangularMatrix UTMatrix
00023 #define LowerTriangularMatrix LTMatrix
00024 #define SymmetricMatrix SMatrix
00025 #define DiagonalMatrix DMatrix
00026 #define BandMatrix BMatrix
00027 #define UpperBandMatrix UBMatrix
00028 #define LowerBandMatrix LBMatrix
00029 #define SymmetricBandMatrix SBMatrix
00030 #define BandLUMatrix BLUMatrix
00031 #endif
00032
00033
00034
00035 class GeneralMatrix;
00036
00037 void MatrixErrorNoSpace(const void*);
00038
00039 class LogAndSign
00040
00041
00042 {
00043 Real log_value;
00044 int sign;
00045 public:
00046 LogAndSign() { log_value=0.0; sign=1; }
00047 LogAndSign(Real);
00048 void operator*=(Real);
00049 void PowEq(int k);
00050 void ChangeSign() { sign = -sign; }
00051 Real LogValue() const { return log_value; }
00052 int Sign() const { return sign; }
00053 Real Value() const;
00054 FREE_CHECK(LogAndSign)
00055 };
00056
00057
00058
00059
00060
00061
00062
00063
00064 #ifdef DO_REPORT
00065
00066 class ExeCounter
00067 {
00068 int line;
00069 int fileid;
00070 long nexe;
00071 static int nreports;
00072 public:
00073 ExeCounter(int,int);
00074 void operator++() { nexe++; }
00075 ~ExeCounter();
00076 };
00077
00078 #endif
00079
00080
00081
00082
00083
00084
00085
00086
00087 class GeneralMatrix;
00088 class BaseMatrix;
00089 class MatrixInput;
00090
00091 class MatrixType
00092 {
00093 public:
00094 enum Attribute { Valid = 1,
00095 Diagonal = 2,
00096 Symmetric = 4,
00097 Band = 8,
00098 Lower = 16,
00099 Upper = 32,
00100 Square = 64,
00101 Skew = 128,
00102 LUDeco = 256,
00103 Ones = 512 };
00104
00105 enum { US = 0,
00106 UT = Valid + Upper + Square,
00107 LT = Valid + Lower + Square,
00108 Rt = Valid,
00109 Sq = Valid + Square,
00110 Sm = Valid + Symmetric + Square,
00111 Sk = Valid + Skew + Square,
00112 Dg = Valid + Diagonal + Band + Lower + Upper + Symmetric
00113 + Square,
00114 Id = Valid + Diagonal + Band + Lower + Upper + Symmetric
00115 + Square + Ones,
00116 RV = Valid,
00117 CV = Valid,
00118 BM = Valid + Band + Square,
00119 UB = Valid + Band + Upper + Square,
00120 LB = Valid + Band + Lower + Square,
00121 SB = Valid + Band + Symmetric + Square,
00122 Ct = Valid + LUDeco + Square,
00123 BC = Valid + Band + LUDeco + Square,
00124 Mask = ~Square
00125 };
00126
00127
00128 static int nTypes() { return 12; }
00129
00130 public:
00131 int attribute;
00132 bool DataLossOK;
00133
00134 public:
00135 MatrixType () : DataLossOK(false) {}
00136 MatrixType (int i) : attribute(i), DataLossOK(false) {}
00137 MatrixType (int i, bool dlok) : attribute(i), DataLossOK(dlok) {}
00138 MatrixType (const MatrixType& mt)
00139 : attribute(mt.attribute), DataLossOK(mt.DataLossOK) {}
00140 void operator=(const MatrixType& mt)
00141 { attribute = mt.attribute; DataLossOK = mt.DataLossOK; }
00142 void SetDataLossOK() { DataLossOK = true; }
00143 int operator+() const { return attribute; }
00144 MatrixType operator+(MatrixType mt) const
00145 { return MatrixType(attribute & mt.attribute); }
00146 MatrixType operator*(const MatrixType&) const;
00147 MatrixType SP(const MatrixType&) const;
00148 MatrixType KP(const MatrixType&) const;
00149 MatrixType operator|(const MatrixType& mt) const
00150 { return MatrixType(attribute & mt.attribute & Valid); }
00151 MatrixType operator&(const MatrixType& mt) const
00152 { return MatrixType(attribute & mt.attribute & Valid); }
00153 bool operator>=(MatrixType mt) const
00154 { return ( attribute & ~mt.attribute & Mask ) == 0; }
00155 bool operator<(MatrixType mt) const
00156 { return ( attribute & ~mt.attribute & Mask ) != 0; }
00157 bool operator==(MatrixType t) const
00158 { return (attribute == t.attribute); }
00159 bool operator!=(MatrixType t) const
00160 { return (attribute != t.attribute); }
00161 bool operator!() const { return (attribute & Valid) == 0; }
00162 MatrixType i() const;
00163 MatrixType t() const;
00164 MatrixType AddEqualEl() const
00165 { return MatrixType(attribute & (Valid + Symmetric + Square)); }
00166 MatrixType MultRHS() const;
00167 MatrixType sub() const
00168 { return MatrixType(attribute & Valid); }
00169 MatrixType ssub() const
00170 { return MatrixType(attribute); }
00171 GeneralMatrix* New() const;
00172 GeneralMatrix* New(int,int,BaseMatrix*) const;
00173
00174 const char* Value() const;
00175 friend bool Rectangular(MatrixType a, MatrixType b, MatrixType c);
00176 friend bool Compare(const MatrixType&, MatrixType&);
00177
00178 bool IsBand() const { return (attribute & Band) != 0; }
00179 bool IsDiagonal() const { return (attribute & Diagonal) != 0; }
00180 bool IsSymmetric() const { return (attribute & Symmetric) != 0; }
00181 bool CannotConvert() const { return (attribute & LUDeco) != 0; }
00182
00183 FREE_CHECK(MatrixType)
00184 };
00185
00186
00187
00188
00189 class MatrixBandWidth
00190 {
00191 public:
00192 int lower;
00193 int upper;
00194 MatrixBandWidth(const int l, const int u) : lower(l), upper (u) {}
00195 MatrixBandWidth(const int i) : lower(i), upper(i) {}
00196 MatrixBandWidth operator+(const MatrixBandWidth&) const;
00197 MatrixBandWidth operator*(const MatrixBandWidth&) const;
00198 MatrixBandWidth minimum(const MatrixBandWidth&) const;
00199 MatrixBandWidth t() const { return MatrixBandWidth(upper,lower); }
00200 bool operator==(const MatrixBandWidth& bw) const
00201 { return (lower == bw.lower) && (upper == bw.upper); }
00202 bool operator!=(const MatrixBandWidth& bw) const { return !operator==(bw); }
00203 int Upper() const { return upper; }
00204 int Lower() const { return lower; }
00205 FREE_CHECK(MatrixBandWidth)
00206 };
00207
00208
00209
00210
00211
00212
00213
00214
00215 class ArrayLengthSpecifier
00216 {
00217 int value;
00218 public:
00219 int Value() const { return value; }
00220 ArrayLengthSpecifier(int l) : value(l) {}
00221 };
00222
00223
00224
00225
00226 class MatrixRowCol;
00227 class MatrixRow;
00228 class MatrixCol;
00229 class MatrixColX;
00230
00231 class GeneralMatrix;
00232 class AddedMatrix;
00233 class MultipliedMatrix;
00234 class SubtractedMatrix;
00235 class SPMatrix;
00236 class KPMatrix;
00237 class ConcatenatedMatrix;
00238 class StackedMatrix;
00239 class SolvedMatrix;
00240 class ShiftedMatrix;
00241 class NegShiftedMatrix;
00242 class ScaledMatrix;
00243 class TransposedMatrix;
00244 class ReversedMatrix;
00245 class NegatedMatrix;
00246 class InvertedMatrix;
00247 class RowedMatrix;
00248 class ColedMatrix;
00249 class DiagedMatrix;
00250 class MatedMatrix;
00251 class GetSubMatrix;
00252 class ReturnMatrix;
00253 class Matrix;
00254 class SquareMatrix;
00255 class nricMatrix;
00256 class RowVector;
00257 class ColumnVector;
00258 class SymmetricMatrix;
00259 class UpperTriangularMatrix;
00260 class LowerTriangularMatrix;
00261 class DiagonalMatrix;
00262 class CroutMatrix;
00263 class BandMatrix;
00264 class LowerBandMatrix;
00265 class UpperBandMatrix;
00266 class SymmetricBandMatrix;
00267 class LinearEquationSolver;
00268 class GenericMatrix;
00269
00270
00271 #define MatrixTypeUnSp 0
00272
00273
00274
00275 class BaseMatrix : public Janitor
00276 {
00277 protected:
00278 virtual int search(const BaseMatrix*) const = 0;
00279
00280
00281
00282 public:
00283 virtual GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp) = 0;
00284
00285
00286
00287
00288 AddedMatrix operator+(const BaseMatrix&) const;
00289 MultipliedMatrix operator*(const BaseMatrix&) const;
00290 SubtractedMatrix operator-(const BaseMatrix&) const;
00291 ConcatenatedMatrix operator|(const BaseMatrix&) const;
00292 StackedMatrix operator&(const BaseMatrix&) const;
00293 ShiftedMatrix operator+(Real) const;
00294 ScaledMatrix operator*(Real) const;
00295 ScaledMatrix operator/(Real) const;
00296 ShiftedMatrix operator-(Real) const;
00297 TransposedMatrix t() const;
00298
00299 NegatedMatrix operator-() const;
00300 ReversedMatrix Reverse() const;
00301 InvertedMatrix i() const;
00302
00303 RowedMatrix AsRow() const;
00304 ColedMatrix AsColumn() const;
00305 DiagedMatrix AsDiagonal() const;
00306 MatedMatrix AsMatrix(int,int) const;
00307 GetSubMatrix SubMatrix(int,int,int,int) const;
00308 GetSubMatrix SymSubMatrix(int,int) const;
00309 GetSubMatrix Row(int) const;
00310 GetSubMatrix Rows(int,int) const;
00311 GetSubMatrix Column(int) const;
00312 GetSubMatrix Columns(int,int) const;
00313 Real AsScalar() const;
00314 virtual LogAndSign LogDeterminant() const;
00315 Real Determinant() const;
00316 virtual Real SumSquare() const;
00317 Real NormFrobenius() const;
00318 virtual Real SumAbsoluteValue() const;
00319 virtual Real Sum() const;
00320 virtual Real MaximumAbsoluteValue() const;
00321 virtual Real MaximumAbsoluteValue1(int& i) const;
00322 virtual Real MaximumAbsoluteValue2(int& i, int& j) const;
00323 virtual Real MinimumAbsoluteValue() const;
00324 virtual Real MinimumAbsoluteValue1(int& i) const;
00325 virtual Real MinimumAbsoluteValue2(int& i, int& j) const;
00326 virtual Real Maximum() const;
00327 virtual Real Maximum1(int& i) const;
00328 virtual Real Maximum2(int& i, int& j) const;
00329 virtual Real Minimum() const;
00330 virtual Real Minimum1(int& i) const;
00331 virtual Real Minimum2(int& i, int& j) const;
00332 virtual Real Trace() const;
00333 Real Norm1() const;
00334 Real NormInfinity() const;
00335 virtual MatrixBandWidth BandWidth() const;
00336 virtual void CleanUp() {}
00337 void IEQND() const;
00338 virtual ReturnMatrix sum_square_columns() const;
00339 virtual ReturnMatrix sum_square_rows() const;
00340
00341
00342
00343
00344 friend class GeneralMatrix;
00345 friend class Matrix;
00346 friend class SquareMatrix;
00347 friend class nricMatrix;
00348 friend class RowVector;
00349 friend class ColumnVector;
00350 friend class SymmetricMatrix;
00351 friend class UpperTriangularMatrix;
00352 friend class LowerTriangularMatrix;
00353 friend class DiagonalMatrix;
00354 friend class CroutMatrix;
00355 friend class BandMatrix;
00356 friend class LowerBandMatrix;
00357 friend class UpperBandMatrix;
00358 friend class SymmetricBandMatrix;
00359 friend class AddedMatrix;
00360 friend class MultipliedMatrix;
00361 friend class SubtractedMatrix;
00362 friend class SPMatrix;
00363 friend class KPMatrix;
00364 friend class ConcatenatedMatrix;
00365 friend class StackedMatrix;
00366 friend class SolvedMatrix;
00367 friend class ShiftedMatrix;
00368 friend class NegShiftedMatrix;
00369 friend class ScaledMatrix;
00370 friend class TransposedMatrix;
00371 friend class ReversedMatrix;
00372 friend class NegatedMatrix;
00373 friend class InvertedMatrix;
00374 friend class RowedMatrix;
00375 friend class ColedMatrix;
00376 friend class DiagedMatrix;
00377 friend class MatedMatrix;
00378 friend class GetSubMatrix;
00379 friend class ReturnMatrix;
00380 friend class LinearEquationSolver;
00381 friend class GenericMatrix;
00382 NEW_DELETE(BaseMatrix)
00383 };
00384
00385
00386
00387
00388 class GeneralMatrix : public BaseMatrix
00389 {
00390 virtual GeneralMatrix* Image() const;
00391 protected:
00392 int tag;
00393 int nrows_value, ncols_value;
00394 int storage;
00395 Real* store;
00396 GeneralMatrix();
00397 GeneralMatrix(ArrayLengthSpecifier);
00398 void Add(GeneralMatrix*, Real);
00399 void Add(Real);
00400 void NegAdd(GeneralMatrix*, Real);
00401 void NegAdd(Real);
00402 void Multiply(GeneralMatrix*, Real);
00403 void Multiply(Real);
00404 void Negate(GeneralMatrix*);
00405 void Negate();
00406 void ReverseElements();
00407 void ReverseElements(GeneralMatrix*);
00408 void operator=(Real);
00409 Real* GetStore();
00410 GeneralMatrix* BorrowStore(GeneralMatrix*, MatrixType);
00411
00412 void GetMatrix(const GeneralMatrix*);
00413 void Eq(const BaseMatrix&, MatrixType);
00414 void Eq(const GeneralMatrix&);
00415 void Eq(const BaseMatrix&, MatrixType, bool);
00416 void Eq2(const BaseMatrix&, MatrixType);
00417 int search(const BaseMatrix*) const;
00418 virtual GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
00419 void CheckConversion(const BaseMatrix&);
00420 void ReSize(int, int, int);
00421 virtual short SimpleAddOK(const GeneralMatrix* gm) { return 0; }
00422
00423 virtual void MiniCleanUp()
00424 { store = 0; storage = 0; nrows_value = 0; ncols_value = 0; tag = -1;}
00425
00426 void PlusEqual(const GeneralMatrix& gm);
00427 void MinusEqual(const GeneralMatrix& gm);
00428 void PlusEqual(Real f);
00429 void MinusEqual(Real f);
00430 void swap(GeneralMatrix& gm);
00431 public:
00432 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
00433 virtual MatrixType Type() const = 0;
00434 int Nrows() const { return nrows_value; }
00435 int Ncols() const { return ncols_value; }
00436 int Storage() const { return storage; }
00437 Real* Store() const { return store; }
00438
00439 int nrows() const { return nrows_value; }
00440 int ncols() const { return ncols_value; }
00441 int size() const { return storage; }
00442 Real* data() { return store; }
00443 const Real* data() const { return store; }
00444 const Real* const_data() const { return store; }
00445 virtual ~GeneralMatrix();
00446 void tDelete();
00447 bool reuse();
00448 void Protect() { tag=-1; }
00449 int Tag() const { return tag; }
00450 bool IsZero() const;
00451 void Release() { tag=1; }
00452 void Release(int t) { tag=t; }
00453 void ReleaseAndDelete() { tag=0; }
00454 void operator<<(const double*);
00455 void operator<<(const float*);
00456 void operator<<(const int*);
00457 void operator<<(const BaseMatrix& X)
00458 { Eq(X,this->Type(),true); }
00459 void Inject(const GeneralMatrix&);
00460 void operator+=(const BaseMatrix&);
00461 void operator-=(const BaseMatrix&);
00462 void operator*=(const BaseMatrix&);
00463 void operator|=(const BaseMatrix&);
00464 void operator&=(const BaseMatrix&);
00465 void operator+=(Real);
00466 void operator-=(Real r) { operator+=(-r); }
00467 void operator*=(Real);
00468 void operator/=(Real r) { operator*=(1.0/r); }
00469 virtual GeneralMatrix* MakeSolver();
00470 virtual void Solver(MatrixColX&, const MatrixColX&) {}
00471 virtual void GetRow(MatrixRowCol&) = 0;
00472 virtual void RestoreRow(MatrixRowCol&) {}
00473 virtual void NextRow(MatrixRowCol&);
00474 virtual void GetCol(MatrixRowCol&) = 0;
00475 virtual void GetCol(MatrixColX&) = 0;
00476 virtual void RestoreCol(MatrixRowCol&) {}
00477 virtual void RestoreCol(MatrixColX&) {}
00478 virtual void NextCol(MatrixRowCol&);
00479 virtual void NextCol(MatrixColX&);
00480 Real SumSquare() const;
00481 Real SumAbsoluteValue() const;
00482 Real Sum() const;
00483 Real MaximumAbsoluteValue1(int& i) const;
00484 Real MinimumAbsoluteValue1(int& i) const;
00485 Real Maximum1(int& i) const;
00486 Real Minimum1(int& i) const;
00487 Real MaximumAbsoluteValue() const;
00488 Real MaximumAbsoluteValue2(int& i, int& j) const;
00489 Real MinimumAbsoluteValue() const;
00490 Real MinimumAbsoluteValue2(int& i, int& j) const;
00491 Real Maximum() const;
00492 Real Maximum2(int& i, int& j) const;
00493 Real Minimum() const;
00494 Real Minimum2(int& i, int& j) const;
00495 LogAndSign LogDeterminant() const;
00496 virtual bool IsEqual(const GeneralMatrix&) const;
00497
00498 void CheckStore() const;
00499 virtual void SetParameters(const GeneralMatrix*) {}
00500
00501 operator ReturnMatrix() const;
00502 ReturnMatrix ForReturn() const;
00503
00504
00505
00506 virtual void ReSize(const GeneralMatrix& A);
00507 MatrixInput operator<<(double);
00508 MatrixInput operator<<(float);
00509 MatrixInput operator<<(int f);
00510
00511 void CleanUp();
00512
00513 friend class Matrix;
00514 friend class SquareMatrix;
00515 friend class nricMatrix;
00516 friend class SymmetricMatrix;
00517 friend class UpperTriangularMatrix;
00518 friend class LowerTriangularMatrix;
00519 friend class DiagonalMatrix;
00520 friend class CroutMatrix;
00521 friend class RowVector;
00522 friend class ColumnVector;
00523 friend class BandMatrix;
00524 friend class LowerBandMatrix;
00525 friend class UpperBandMatrix;
00526 friend class SymmetricBandMatrix;
00527 friend class BaseMatrix;
00528 friend class AddedMatrix;
00529 friend class MultipliedMatrix;
00530 friend class SubtractedMatrix;
00531 friend class SPMatrix;
00532 friend class KPMatrix;
00533 friend class ConcatenatedMatrix;
00534 friend class StackedMatrix;
00535 friend class SolvedMatrix;
00536 friend class ShiftedMatrix;
00537 friend class NegShiftedMatrix;
00538 friend class ScaledMatrix;
00539 friend class TransposedMatrix;
00540 friend class ReversedMatrix;
00541 friend class NegatedMatrix;
00542 friend class InvertedMatrix;
00543 friend class RowedMatrix;
00544 friend class ColedMatrix;
00545 friend class DiagedMatrix;
00546 friend class MatedMatrix;
00547 friend class GetSubMatrix;
00548 friend class ReturnMatrix;
00549 friend class LinearEquationSolver;
00550 friend class GenericMatrix;
00551 NEW_DELETE(GeneralMatrix)
00552 };
00553
00554
00555
00556 class Matrix : public GeneralMatrix
00557 {
00558 GeneralMatrix* Image() const;
00559 public:
00560 Matrix() {}
00561 ~Matrix() {}
00562 Matrix(int, int);
00563 Matrix(const BaseMatrix&);
00564 void operator=(const BaseMatrix&);
00565 void operator=(Real f) { GeneralMatrix::operator=(f); }
00566 void operator=(const Matrix& m) { Eq(m); }
00567 MatrixType Type() const;
00568 Real& operator()(int, int);
00569 Real& element(int, int);
00570 Real operator()(int, int) const;
00571 Real element(int, int) const;
00572 #ifdef SETUP_C_SUBSCRIPTS
00573 Real* operator[](int m) { return store+m*ncols_value; }
00574 const Real* operator[](int m) const { return store+m*ncols_value; }
00575
00576 Matrix(Real, int, int);
00577 Matrix(const Real*, int, int);
00578 #endif
00579 Matrix(const Matrix& gm) { GetMatrix(&gm); }
00580 GeneralMatrix* MakeSolver();
00581 Real Trace() const;
00582 void GetRow(MatrixRowCol&);
00583 void GetCol(MatrixRowCol&);
00584 void GetCol(MatrixColX&);
00585 void RestoreCol(MatrixRowCol&);
00586 void RestoreCol(MatrixColX&);
00587 void NextRow(MatrixRowCol&);
00588 void NextCol(MatrixRowCol&);
00589 void NextCol(MatrixColX&);
00590 virtual void ReSize(int,int);
00591
00592 void ReSize(const GeneralMatrix& A);
00593 Real MaximumAbsoluteValue2(int& i, int& j) const;
00594 Real MinimumAbsoluteValue2(int& i, int& j) const;
00595 Real Maximum2(int& i, int& j) const;
00596 Real Minimum2(int& i, int& j) const;
00597 void operator+=(const Matrix& M) { PlusEqual(M); }
00598 void operator-=(const Matrix& M) { MinusEqual(M); }
00599 void operator+=(Real f) { GeneralMatrix::Add(f); }
00600 void operator-=(Real f) { GeneralMatrix::Add(-f); }
00601 void swap(Matrix& gm) { GeneralMatrix::swap((GeneralMatrix&)gm); }
00602 friend Real DotProduct(const Matrix& A, const Matrix& B);
00603 NEW_DELETE(Matrix)
00604 };
00605
00606 class SquareMatrix : public Matrix
00607 {
00608 GeneralMatrix* Image() const;
00609 public:
00610 SquareMatrix() {}
00611 ~SquareMatrix() {}
00612 SquareMatrix(ArrayLengthSpecifier);
00613 SquareMatrix(const BaseMatrix&);
00614 void operator=(const BaseMatrix&);
00615 void operator=(Real f) { GeneralMatrix::operator=(f); }
00616 void operator=(const SquareMatrix& m) { Eq(m); }
00617 void operator=(const Matrix& m);
00618 MatrixType Type() const;
00619 SquareMatrix(const SquareMatrix& gm) { GetMatrix(&gm); }
00620 SquareMatrix(const Matrix& gm);
00621 void ReSize(int);
00622 virtual void ReSize(int,int);
00623
00624 void ReSize(const GeneralMatrix& A);
00625 void operator+=(const Matrix& M) { PlusEqual(M); }
00626 void operator-=(const Matrix& M) { MinusEqual(M); }
00627 void operator+=(Real f) { GeneralMatrix::Add(f); }
00628 void operator-=(Real f) { GeneralMatrix::Add(-f); }
00629 void swap(SquareMatrix& gm) { GeneralMatrix::swap((GeneralMatrix&)gm); }
00630 NEW_DELETE(SquareMatrix)
00631 };
00632
00633 class nricMatrix : public Matrix
00634
00635 {
00636 GeneralMatrix* Image() const;
00637 Real** row_pointer;
00638 void MakeRowPointer();
00639 void DeleteRowPointer();
00640 public:
00641 nricMatrix() {}
00642 nricMatrix(int m, int n)
00643 : Matrix(m,n) { MakeRowPointer(); }
00644 nricMatrix(const BaseMatrix& bm)
00645 : Matrix(bm) { MakeRowPointer(); }
00646 void operator=(const BaseMatrix& bm)
00647 { DeleteRowPointer(); Matrix::operator=(bm); MakeRowPointer(); }
00648 void operator=(Real f) { GeneralMatrix::operator=(f); }
00649 void operator=(const nricMatrix& m)
00650 { DeleteRowPointer(); Eq(m); MakeRowPointer(); }
00651 void operator<<(const BaseMatrix& X)
00652 { DeleteRowPointer(); Eq(X,this->Type(),true); MakeRowPointer(); }
00653 nricMatrix(const nricMatrix& gm) { GetMatrix(&gm); MakeRowPointer(); }
00654 void ReSize(int m, int n)
00655 { DeleteRowPointer(); Matrix::ReSize(m,n); MakeRowPointer(); }
00656 void ReSize(const GeneralMatrix& A);
00657 ~nricMatrix() { DeleteRowPointer(); }
00658 Real** nric() const { CheckStore(); return row_pointer-1; }
00659 void CleanUp();
00660 void MiniCleanUp();
00661 void operator+=(const Matrix& M) { PlusEqual(M); }
00662 void operator-=(const Matrix& M) { MinusEqual(M); }
00663 void operator+=(Real f) { GeneralMatrix::Add(f); }
00664 void operator-=(Real f) { GeneralMatrix::Add(-f); }
00665 void swap(nricMatrix& gm);
00666 NEW_DELETE(nricMatrix)
00667 };
00668
00669 class SymmetricMatrix : public GeneralMatrix
00670 {
00671 GeneralMatrix* Image() const;
00672 public:
00673 SymmetricMatrix() {}
00674 ~SymmetricMatrix() {}
00675 SymmetricMatrix(ArrayLengthSpecifier);
00676 SymmetricMatrix(const BaseMatrix&);
00677 void operator=(const BaseMatrix&);
00678 void operator=(Real f) { GeneralMatrix::operator=(f); }
00679 void operator=(const SymmetricMatrix& m) { Eq(m); }
00680 Real& operator()(int, int);
00681 Real& element(int, int);
00682 Real operator()(int, int) const;
00683 Real element(int, int) const;
00684 #ifdef SETUP_C_SUBSCRIPTS
00685 Real* operator[](int m) { return store+(m*(m+1))/2; }
00686 const Real* operator[](int m) const { return store+(m*(m+1))/2; }
00687 #endif
00688 MatrixType Type() const;
00689 SymmetricMatrix(const SymmetricMatrix& gm) { GetMatrix(&gm); }
00690 Real SumSquare() const;
00691 Real SumAbsoluteValue() const;
00692 Real Sum() const;
00693 Real Trace() const;
00694 void GetRow(MatrixRowCol&);
00695 void GetCol(MatrixRowCol&);
00696 void GetCol(MatrixColX&);
00697 void RestoreCol(MatrixRowCol&) {}
00698 void RestoreCol(MatrixColX&);
00699 GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
00700 void ReSize(int);
00701 void ReSize(const GeneralMatrix& A);
00702 void operator+=(const SymmetricMatrix& M) { PlusEqual(M); }
00703 void operator-=(const SymmetricMatrix& M) { MinusEqual(M); }
00704 void operator+=(Real f) { GeneralMatrix::Add(f); }
00705 void operator-=(Real f) { GeneralMatrix::Add(-f); }
00706 void swap(SymmetricMatrix& gm) { GeneralMatrix::swap((GeneralMatrix&)gm); }
00707 NEW_DELETE(SymmetricMatrix)
00708 };
00709
00710 class UpperTriangularMatrix : public GeneralMatrix
00711 {
00712 GeneralMatrix* Image() const;
00713 public:
00714 UpperTriangularMatrix() {}
00715 ~UpperTriangularMatrix() {}
00716 UpperTriangularMatrix(ArrayLengthSpecifier);
00717 void operator=(const BaseMatrix&);
00718 void operator=(const UpperTriangularMatrix& m) { Eq(m); }
00719 UpperTriangularMatrix(const BaseMatrix&);
00720 UpperTriangularMatrix(const UpperTriangularMatrix& gm) { GetMatrix(&gm); }
00721 void operator=(Real f) { GeneralMatrix::operator=(f); }
00722 Real& operator()(int, int);
00723 Real& element(int, int);
00724 Real operator()(int, int) const;
00725 Real element(int, int) const;
00726 #ifdef SETUP_C_SUBSCRIPTS
00727 Real* operator[](int m) { return store+m*ncols_value-(m*(m+1))/2; }
00728 const Real* operator[](int m) const
00729 { return store+m*ncols_value-(m*(m+1))/2; }
00730 #endif
00731 MatrixType Type() const;
00732 GeneralMatrix* MakeSolver() { return this; }
00733 void Solver(MatrixColX&, const MatrixColX&);
00734 LogAndSign LogDeterminant() const;
00735 Real Trace() const;
00736 void GetRow(MatrixRowCol&);
00737 void GetCol(MatrixRowCol&);
00738 void GetCol(MatrixColX&);
00739 void RestoreCol(MatrixRowCol&);
00740 void RestoreCol(MatrixColX& c) { RestoreCol((MatrixRowCol&)c); }
00741 void NextRow(MatrixRowCol&);
00742 void ReSize(int);
00743 void ReSize(const GeneralMatrix& A);
00744 MatrixBandWidth BandWidth() const;
00745 void operator+=(const UpperTriangularMatrix& M) { PlusEqual(M); }
00746 void operator-=(const UpperTriangularMatrix& M) { MinusEqual(M); }
00747 void operator+=(Real f) { GeneralMatrix::operator+=(f); }
00748 void operator-=(Real f) { GeneralMatrix::operator-=(f); }
00749 void swap(UpperTriangularMatrix& gm)
00750 { GeneralMatrix::swap((GeneralMatrix&)gm); }
00751 NEW_DELETE(UpperTriangularMatrix)
00752 };
00753
00754 class LowerTriangularMatrix : public GeneralMatrix
00755 {
00756 GeneralMatrix* Image() const;
00757 public:
00758 LowerTriangularMatrix() {}
00759 ~LowerTriangularMatrix() {}
00760 LowerTriangularMatrix(ArrayLengthSpecifier);
00761 LowerTriangularMatrix(const LowerTriangularMatrix& gm) { GetMatrix(&gm); }
00762 LowerTriangularMatrix(const BaseMatrix& M);
00763 void operator=(const BaseMatrix&);
00764 void operator=(Real f) { GeneralMatrix::operator=(f); }
00765 void operator=(const LowerTriangularMatrix& m) { Eq(m); }
00766 Real& operator()(int, int);
00767 Real& element(int, int);
00768 Real operator()(int, int) const;
00769 Real element(int, int) const;
00770 #ifdef SETUP_C_SUBSCRIPTS
00771 Real* operator[](int m) { return store+(m*(m+1))/2; }
00772 const Real* operator[](int m) const { return store+(m*(m+1))/2; }
00773 #endif
00774 MatrixType Type() const;
00775 GeneralMatrix* MakeSolver() { return this; }
00776 void Solver(MatrixColX&, const MatrixColX&);
00777 LogAndSign LogDeterminant() const;
00778 Real Trace() const;
00779 void GetRow(MatrixRowCol&);
00780 void GetCol(MatrixRowCol&);
00781 void GetCol(MatrixColX&);
00782 void RestoreCol(MatrixRowCol&);
00783 void RestoreCol(MatrixColX& c) { RestoreCol((MatrixRowCol&)c); }
00784 void NextRow(MatrixRowCol&);
00785 void ReSize(int);
00786 void ReSize(const GeneralMatrix& A);
00787 MatrixBandWidth BandWidth() const;
00788 void operator+=(const LowerTriangularMatrix& M) { PlusEqual(M); }
00789 void operator-=(const LowerTriangularMatrix& M) { MinusEqual(M); }
00790 void operator+=(Real f) { GeneralMatrix::operator+=(f); }
00791 void operator-=(Real f) { GeneralMatrix::operator-=(f); }
00792 void swap(LowerTriangularMatrix& gm)
00793 { GeneralMatrix::swap((GeneralMatrix&)gm); }
00794 NEW_DELETE(LowerTriangularMatrix)
00795 };
00796
00797 class DiagonalMatrix : public GeneralMatrix
00798 {
00799 GeneralMatrix* Image() const;
00800 public:
00801 DiagonalMatrix() {}
00802 ~DiagonalMatrix() {}
00803 DiagonalMatrix(ArrayLengthSpecifier);
00804 DiagonalMatrix(const BaseMatrix&);
00805 DiagonalMatrix(const DiagonalMatrix& gm) { GetMatrix(&gm); }
00806 void operator=(const BaseMatrix&);
00807 void operator=(Real f) { GeneralMatrix::operator=(f); }
00808 void operator=(const DiagonalMatrix& m) { Eq(m); }
00809 Real& operator()(int, int);
00810 Real& operator()(int);
00811 Real operator()(int, int) const;
00812 Real operator()(int) const;
00813 Real& element(int, int);
00814 Real& element(int);
00815 Real element(int, int) const;
00816 Real element(int) const;
00817 #ifdef SETUP_C_SUBSCRIPTS
00818 Real& operator[](int m) { return store[m]; }
00819 const Real& operator[](int m) const { return store[m]; }
00820 #endif
00821 MatrixType Type() const;
00822
00823 LogAndSign LogDeterminant() const;
00824 Real Trace() const;
00825 void GetRow(MatrixRowCol&);
00826 void GetCol(MatrixRowCol&);
00827 void GetCol(MatrixColX&);
00828 void NextRow(MatrixRowCol&);
00829 void NextCol(MatrixRowCol&);
00830 void NextCol(MatrixColX&);
00831 GeneralMatrix* MakeSolver() { return this; }
00832 void Solver(MatrixColX&, const MatrixColX&);
00833 GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
00834 void ReSize(int);
00835 void ReSize(const GeneralMatrix& A);
00836 Real* nric() const
00837 { CheckStore(); return store-1; }
00838 MatrixBandWidth BandWidth() const;
00839
00840 void operator+=(const DiagonalMatrix& M) { PlusEqual(M); }
00841 void operator-=(const DiagonalMatrix& M) { MinusEqual(M); }
00842 void operator+=(Real f) { GeneralMatrix::operator+=(f); }
00843 void operator-=(Real f) { GeneralMatrix::operator-=(f); }
00844 void swap(DiagonalMatrix& gm)
00845 { GeneralMatrix::swap((GeneralMatrix&)gm); }
00846 NEW_DELETE(DiagonalMatrix)
00847 };
00848
00849 class RowVector : public Matrix
00850 {
00851 GeneralMatrix* Image() const;
00852 public:
00853 RowVector() { nrows_value = 1; }
00854 ~RowVector() {}
00855 RowVector(ArrayLengthSpecifier n) : Matrix(1,n.Value()) {}
00856 RowVector(const BaseMatrix&);
00857 RowVector(const RowVector& gm) { GetMatrix(&gm); }
00858 void operator=(const BaseMatrix&);
00859 void operator=(Real f) { GeneralMatrix::operator=(f); }
00860 void operator=(const RowVector& m) { Eq(m); }
00861 Real& operator()(int);
00862 Real& element(int);
00863 Real operator()(int) const;
00864 Real element(int) const;
00865 #ifdef SETUP_C_SUBSCRIPTS
00866 Real& operator[](int m) { return store[m]; }
00867 const Real& operator[](int m) const { return store[m]; }
00868
00869 RowVector(Real a, int n) : Matrix(a, 1, n) {}
00870 RowVector(const Real* a, int n) : Matrix(a, 1, n) {}
00871 #endif
00872 MatrixType Type() const;
00873 void GetCol(MatrixRowCol&);
00874 void GetCol(MatrixColX&);
00875 void NextCol(MatrixRowCol&);
00876 void NextCol(MatrixColX&);
00877 void RestoreCol(MatrixRowCol&) {}
00878 void RestoreCol(MatrixColX& c);
00879 GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
00880 void ReSize(int);
00881 void ReSize(int,int);
00882 void ReSize(const GeneralMatrix& A);
00883 Real* nric() const
00884 { CheckStore(); return store-1; }
00885 void CleanUp();
00886 void MiniCleanUp()
00887 { store = 0; storage = 0; nrows_value = 1; ncols_value = 0; tag = -1; }
00888
00889 void operator+=(const Matrix& M) { PlusEqual(M); }
00890 void operator-=(const Matrix& M) { MinusEqual(M); }
00891 void operator+=(Real f) { GeneralMatrix::Add(f); }
00892 void operator-=(Real f) { GeneralMatrix::Add(-f); }
00893 void swap(RowVector& gm)
00894 { GeneralMatrix::swap((GeneralMatrix&)gm); }
00895 NEW_DELETE(RowVector)
00896 };
00897
00898 class ColumnVector : public Matrix
00899 {
00900 GeneralMatrix* Image() const;
00901 public:
00902 ColumnVector() { ncols_value = 1; }
00903 ~ColumnVector() {}
00904 ColumnVector(ArrayLengthSpecifier n) : Matrix(n.Value(),1) {}
00905 ColumnVector(const BaseMatrix&);
00906 ColumnVector(const ColumnVector& gm) { GetMatrix(&gm); }
00907 void operator=(const BaseMatrix&);
00908 void operator=(Real f) { GeneralMatrix::operator=(f); }
00909 void operator=(const ColumnVector& m) { Eq(m); }
00910 Real& operator()(int);
00911 Real& element(int);
00912 Real operator()(int) const;
00913 Real element(int) const;
00914 #ifdef SETUP_C_SUBSCRIPTS
00915 Real& operator[](int m) { return store[m]; }
00916 const Real& operator[](int m) const { return store[m]; }
00917
00918 ColumnVector(Real a, int m) : Matrix(a, m, 1) {}
00919 ColumnVector(const Real* a, int m) : Matrix(a, m, 1) {}
00920 #endif
00921 MatrixType Type() const;
00922 GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
00923 void ReSize(int);
00924 void ReSize(int,int);
00925 void ReSize(const GeneralMatrix& A);
00926 Real* nric() const
00927 { CheckStore(); return store-1; }
00928 void CleanUp();
00929 void MiniCleanUp()
00930 { store = 0; storage = 0; nrows_value = 0; ncols_value = 1; tag = -1; }
00931
00932 void operator+=(const Matrix& M) { PlusEqual(M); }
00933 void operator-=(const Matrix& M) { MinusEqual(M); }
00934 void operator+=(Real f) { GeneralMatrix::Add(f); }
00935 void operator-=(Real f) { GeneralMatrix::Add(-f); }
00936 void swap(ColumnVector& gm)
00937 { GeneralMatrix::swap((GeneralMatrix&)gm); }
00938 NEW_DELETE(ColumnVector)
00939 };
00940
00941 class CroutMatrix : public GeneralMatrix
00942 {
00943 int* indx;
00944 bool d;
00945 bool sing;
00946 void ludcmp();
00947 void operator=(const CroutMatrix& m) {}
00948 public:
00949 CroutMatrix(const BaseMatrix&);
00950 MatrixType Type() const;
00951 void lubksb(Real*, int=0);
00952 ~CroutMatrix();
00953 GeneralMatrix* MakeSolver() { return this; }
00954 LogAndSign LogDeterminant() const;
00955 void Solver(MatrixColX&, const MatrixColX&);
00956 void GetRow(MatrixRowCol&);
00957 void GetCol(MatrixRowCol&);
00958 void GetCol(MatrixColX& c) { GetCol((MatrixRowCol&)c); }
00959 void CleanUp();
00960 void MiniCleanUp();
00961 bool IsEqual(const GeneralMatrix&) const;
00962 bool IsSingular() const { return sing; }
00963 void swap(CroutMatrix& gm);
00964 NEW_DELETE(CroutMatrix)
00965 };
00966
00967
00968
00969 class BandMatrix : public GeneralMatrix
00970 {
00971 GeneralMatrix* Image() const;
00972 protected:
00973 void CornerClear() const;
00974 short SimpleAddOK(const GeneralMatrix* gm);
00975 public:
00976 int lower, upper;
00977 BandMatrix() { lower=0; upper=0; CornerClear(); }
00978 ~BandMatrix() {}
00979 BandMatrix(int n,int lb,int ub) { ReSize(n,lb,ub); CornerClear(); }
00980
00981 BandMatrix(const BaseMatrix&);
00982 void operator=(const BaseMatrix&);
00983 void operator=(Real f) { GeneralMatrix::operator=(f); }
00984 void operator=(const BandMatrix& m) { Eq(m); }
00985 MatrixType Type() const;
00986 Real& operator()(int, int);
00987 Real& element(int, int);
00988 Real operator()(int, int) const;
00989 Real element(int, int) const;
00990 #ifdef SETUP_C_SUBSCRIPTS
00991 Real* operator[](int m) { return store+(upper+lower)*m+lower; }
00992 const Real* operator[](int m) const { return store+(upper+lower)*m+lower; }
00993 #endif
00994 BandMatrix(const BandMatrix& gm) { GetMatrix(&gm); }
00995 LogAndSign LogDeterminant() const;
00996 GeneralMatrix* MakeSolver();
00997 Real Trace() const;
00998 Real SumSquare() const { CornerClear(); return GeneralMatrix::SumSquare(); }
00999 Real SumAbsoluteValue() const
01000 { CornerClear(); return GeneralMatrix::SumAbsoluteValue(); }
01001 Real Sum() const
01002 { CornerClear(); return GeneralMatrix::Sum(); }
01003 Real MaximumAbsoluteValue() const
01004 { CornerClear(); return GeneralMatrix::MaximumAbsoluteValue(); }
01005 Real MinimumAbsoluteValue() const
01006 { int i, j; return GeneralMatrix::MinimumAbsoluteValue2(i, j); }
01007 Real Maximum() const { int i, j; return GeneralMatrix::Maximum2(i, j); }
01008 Real Minimum() const { int i, j; return GeneralMatrix::Minimum2(i, j); }
01009 void GetRow(MatrixRowCol&);
01010 void GetCol(MatrixRowCol&);
01011 void GetCol(MatrixColX&);
01012 void RestoreCol(MatrixRowCol&);
01013 void RestoreCol(MatrixColX& c) { RestoreCol((MatrixRowCol&)c); }
01014 void NextRow(MatrixRowCol&);
01015 virtual void ReSize(int, int, int);
01016 void ReSize(const GeneralMatrix& A);
01017
01018
01019
01020 MatrixBandWidth BandWidth() const;
01021 void SetParameters(const GeneralMatrix*);
01022 MatrixInput operator<<(double);
01023 MatrixInput operator<<(float);
01024 MatrixInput operator<<(int f);
01025 void operator<<(const double* r);
01026 void operator<<(const float* r);
01027 void operator<<(const int* r);
01028
01029
01030 void operator<<(const BaseMatrix& X) { GeneralMatrix::operator<<(X); }
01031 void swap(BandMatrix& gm);
01032 NEW_DELETE(BandMatrix)
01033 };
01034
01035 class UpperBandMatrix : public BandMatrix
01036 {
01037 GeneralMatrix* Image() const;
01038 public:
01039 UpperBandMatrix() {}
01040 ~UpperBandMatrix() {}
01041 UpperBandMatrix(int n, int ubw)
01042 : BandMatrix(n, 0, ubw) {}
01043 UpperBandMatrix(const BaseMatrix&);
01044 void operator=(const BaseMatrix&);
01045 void operator=(Real f) { GeneralMatrix::operator=(f); }
01046 void operator=(const UpperBandMatrix& m) { Eq(m); }
01047 MatrixType Type() const;
01048 UpperBandMatrix(const UpperBandMatrix& gm) { GetMatrix(&gm); }
01049 GeneralMatrix* MakeSolver() { return this; }
01050 void Solver(MatrixColX&, const MatrixColX&);
01051 LogAndSign LogDeterminant() const;
01052 void ReSize(int, int, int);
01053 void ReSize(int n,int ubw)
01054 { BandMatrix::ReSize(n,0,ubw); }
01055 void ReSize(const GeneralMatrix& A) { BandMatrix::ReSize(A); }
01056 Real& operator()(int, int);
01057 Real operator()(int, int) const;
01058 Real& element(int, int);
01059 Real element(int, int) const;
01060 #ifdef SETUP_C_SUBSCRIPTS
01061 Real* operator[](int m) { return store+upper*m; }
01062 const Real* operator[](int m) const { return store+upper*m; }
01063 #endif
01064 void swap(UpperBandMatrix& gm)
01065 { BandMatrix::swap((BandMatrix&)gm); }
01066 NEW_DELETE(UpperBandMatrix)
01067 };
01068
01069 class LowerBandMatrix : public BandMatrix
01070 {
01071 GeneralMatrix* Image() const;
01072 public:
01073 LowerBandMatrix() {}
01074 ~LowerBandMatrix() {}
01075 LowerBandMatrix(int n, int lbw)
01076 : BandMatrix(n, lbw, 0) {}
01077 LowerBandMatrix(const BaseMatrix&);
01078 void operator=(const BaseMatrix&);
01079 void operator=(Real f) { GeneralMatrix::operator=(f); }
01080 void operator=(const LowerBandMatrix& m) { Eq(m); }
01081 MatrixType Type() const;
01082 LowerBandMatrix(const LowerBandMatrix& gm) { GetMatrix(&gm); }
01083 GeneralMatrix* MakeSolver() { return this; }
01084 void Solver(MatrixColX&, const MatrixColX&);
01085 LogAndSign LogDeterminant() const;
01086 void ReSize(int, int, int);
01087 void ReSize(int n,int lbw)
01088 { BandMatrix::ReSize(n,lbw,0); }
01089 void ReSize(const GeneralMatrix& A) { BandMatrix::ReSize(A); }
01090 Real& operator()(int, int);
01091 Real operator()(int, int) const;
01092 Real& element(int, int);
01093 Real element(int, int) const;
01094 #ifdef SETUP_C_SUBSCRIPTS
01095 Real* operator[](int m) { return store+lower*(m+1); }
01096 const Real* operator[](int m) const { return store+lower*(m+1); }
01097 #endif
01098 void swap(LowerBandMatrix& gm)
01099 { BandMatrix::swap((BandMatrix&)gm); }
01100 NEW_DELETE(LowerBandMatrix)
01101 };
01102
01103 class SymmetricBandMatrix : public GeneralMatrix
01104 {
01105 GeneralMatrix* Image() const;
01106 void CornerClear() const;
01107 short SimpleAddOK(const GeneralMatrix* gm);
01108 public:
01109 int lower;
01110 SymmetricBandMatrix() { lower=0; CornerClear(); }
01111 ~SymmetricBandMatrix() {}
01112 SymmetricBandMatrix(int n, int lb) { ReSize(n,lb); CornerClear(); }
01113 SymmetricBandMatrix(const BaseMatrix&);
01114 void operator=(const BaseMatrix&);
01115 void operator=(Real f) { GeneralMatrix::operator=(f); }
01116 void operator=(const SymmetricBandMatrix& m) { Eq(m); }
01117 Real& operator()(int, int);
01118 Real& element(int, int);
01119 Real operator()(int, int) const;
01120 Real element(int, int) const;
01121 #ifdef SETUP_C_SUBSCRIPTS
01122 Real* operator[](int m) { return store+lower*(m+1); }
01123 const Real* operator[](int m) const { return store+lower*(m+1); }
01124 #endif
01125 MatrixType Type() const;
01126 SymmetricBandMatrix(const SymmetricBandMatrix& gm) { GetMatrix(&gm); }
01127 GeneralMatrix* MakeSolver();
01128 Real SumSquare() const;
01129 Real SumAbsoluteValue() const;
01130 Real Sum() const;
01131 Real MaximumAbsoluteValue() const
01132 { CornerClear(); return GeneralMatrix::MaximumAbsoluteValue(); }
01133 Real MinimumAbsoluteValue() const
01134 { int i, j; return GeneralMatrix::MinimumAbsoluteValue2(i, j); }
01135 Real Maximum() const { int i, j; return GeneralMatrix::Maximum2(i, j); }
01136 Real Minimum() const { int i, j; return GeneralMatrix::Minimum2(i, j); }
01137 Real Trace() const;
01138 LogAndSign LogDeterminant() const;
01139 void GetRow(MatrixRowCol&);
01140 void GetCol(MatrixRowCol&);
01141 void GetCol(MatrixColX&);
01142 void RestoreCol(MatrixRowCol&) {}
01143 void RestoreCol(MatrixColX&);
01144 GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
01145 void ReSize(int,int);
01146 void ReSize(const GeneralMatrix& A);
01147
01148
01149
01150 MatrixBandWidth BandWidth() const;
01151 void SetParameters(const GeneralMatrix*);
01152 void operator<<(const double* r);
01153 void operator<<(const float* r);
01154 void operator<<(const int* r);
01155 void operator<<(const BaseMatrix& X) { GeneralMatrix::operator<<(X); }
01156 void swap(SymmetricBandMatrix& gm);
01157 NEW_DELETE(SymmetricBandMatrix)
01158 };
01159
01160 class BandLUMatrix : public GeneralMatrix
01161
01162 {
01163 int* indx;
01164 bool d;
01165 bool sing;
01166 Real* store2;
01167 int storage2;
01168 void ludcmp();
01169 int m1,m2;
01170 void operator=(const BandLUMatrix& m) {}
01171 public:
01172 BandLUMatrix(const BaseMatrix&);
01173 MatrixType Type() const;
01174 void lubksb(Real*, int=0);
01175 ~BandLUMatrix();
01176 GeneralMatrix* MakeSolver() { return this; }
01177 LogAndSign LogDeterminant() const;
01178 void Solver(MatrixColX&, const MatrixColX&);
01179 void GetRow(MatrixRowCol&);
01180 void GetCol(MatrixRowCol&);
01181 void GetCol(MatrixColX& c) { GetCol((MatrixRowCol&)c); }
01182 void CleanUp();
01183 void MiniCleanUp();
01184 bool IsEqual(const GeneralMatrix&) const;
01185 bool IsSingular() const { return sing; }
01186 void swap(BandLUMatrix& gm);
01187 NEW_DELETE(BandLUMatrix)
01188 };
01189
01190
01191
01192 class IdentityMatrix : public GeneralMatrix
01193 {
01194 GeneralMatrix* Image() const;
01195 public:
01196 IdentityMatrix() {}
01197 ~IdentityMatrix() {}
01198 IdentityMatrix(ArrayLengthSpecifier n) : GeneralMatrix(1)
01199 { nrows_value = ncols_value = n.Value(); *store = 1; }
01200 IdentityMatrix(const IdentityMatrix& gm) { GetMatrix(&gm); }
01201 IdentityMatrix(const BaseMatrix&);
01202 void operator=(const BaseMatrix&);
01203 void operator=(const IdentityMatrix& m) { Eq(m); }
01204 void operator=(Real f) { GeneralMatrix::operator=(f); }
01205 MatrixType Type() const;
01206
01207 LogAndSign LogDeterminant() const;
01208 Real Trace() const;
01209 Real SumSquare() const;
01210 Real SumAbsoluteValue() const;
01211 Real Sum() const { return Trace(); }
01212 void GetRow(MatrixRowCol&);
01213 void GetCol(MatrixRowCol&);
01214 void GetCol(MatrixColX&);
01215 void NextRow(MatrixRowCol&);
01216 void NextCol(MatrixRowCol&);
01217 void NextCol(MatrixColX&);
01218 GeneralMatrix* MakeSolver() { return this; }
01219 void Solver(MatrixColX&, const MatrixColX&);
01220 GeneralMatrix* Transpose(TransposedMatrix*, MatrixType);
01221 void ReSize(int n);
01222 void ReSize(const GeneralMatrix& A);
01223 MatrixBandWidth BandWidth() const;
01224
01225 void swap(IdentityMatrix& gm)
01226 { GeneralMatrix::swap((GeneralMatrix&)gm); }
01227 NEW_DELETE(IdentityMatrix)
01228 };
01229
01230
01231
01232
01233
01234
01235 class GenericMatrix : public BaseMatrix
01236 {
01237 GeneralMatrix* gm;
01238 int search(const BaseMatrix* bm) const;
01239 friend class BaseMatrix;
01240 public:
01241 GenericMatrix() : gm(0) {}
01242 GenericMatrix(const BaseMatrix& bm)
01243 { gm = ((BaseMatrix&)bm).Evaluate(); gm = gm->Image(); }
01244 GenericMatrix(const GenericMatrix& bm)
01245 { gm = bm.gm->Image(); }
01246 void operator=(const GenericMatrix&);
01247 void operator=(const BaseMatrix&);
01248 void operator+=(const BaseMatrix&);
01249 void operator-=(const BaseMatrix&);
01250 void operator*=(const BaseMatrix&);
01251 void operator|=(const BaseMatrix&);
01252 void operator&=(const BaseMatrix&);
01253 void operator+=(Real);
01254 void operator-=(Real r) { operator+=(-r); }
01255 void operator*=(Real);
01256 void operator/=(Real r) { operator*=(1.0/r); }
01257 ~GenericMatrix() { delete gm; }
01258 void CleanUp() { delete gm; gm = 0; }
01259 void Release() { gm->Release(); }
01260 GeneralMatrix* Evaluate(MatrixType = MatrixTypeUnSp);
01261 MatrixBandWidth BandWidth() const;
01262 void swap(GenericMatrix& x);
01263 NEW_DELETE(GenericMatrix)
01264 };
01265
01266
01267
01268 class MultipliedMatrix : public BaseMatrix
01269 {
01270 protected:
01271
01272
01273 union { const BaseMatrix* bm1; GeneralMatrix* gm1; };
01274
01275 union { const BaseMatrix* bm2; GeneralMatrix* gm2; };
01276 MultipliedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
01277 : bm1(bm1x),bm2(bm2x) {}
01278 int search(const BaseMatrix*) const;
01279 friend class BaseMatrix;
01280 friend class GeneralMatrix;
01281 friend class GenericMatrix;
01282 public:
01283 ~MultipliedMatrix() {}
01284 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01285 MatrixBandWidth BandWidth() const;
01286 NEW_DELETE(MultipliedMatrix)
01287 };
01288
01289 class AddedMatrix : public MultipliedMatrix
01290 {
01291 protected:
01292 AddedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
01293 : MultipliedMatrix(bm1x,bm2x) {}
01294
01295 friend class BaseMatrix;
01296 friend class GeneralMatrix;
01297 friend class GenericMatrix;
01298 public:
01299 ~AddedMatrix() {}
01300 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01301 MatrixBandWidth BandWidth() const;
01302 NEW_DELETE(AddedMatrix)
01303 };
01304
01305 class SPMatrix : public AddedMatrix
01306 {
01307 protected:
01308 SPMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
01309 : AddedMatrix(bm1x,bm2x) {}
01310
01311 friend class BaseMatrix;
01312 friend class GeneralMatrix;
01313 friend class GenericMatrix;
01314 public:
01315 ~SPMatrix() {}
01316 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01317 MatrixBandWidth BandWidth() const;
01318
01319 friend SPMatrix SP(const BaseMatrix&, const BaseMatrix&);
01320
01321 NEW_DELETE(SPMatrix)
01322 };
01323
01324 class KPMatrix : public MultipliedMatrix
01325 {
01326 protected:
01327 KPMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
01328 : MultipliedMatrix(bm1x,bm2x) {}
01329
01330 friend class BaseMatrix;
01331 friend class GeneralMatrix;
01332 friend class GenericMatrix;
01333 public:
01334 ~KPMatrix() {}
01335 MatrixBandWidth BandWidth() const;
01336 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01337 friend KPMatrix KP(const BaseMatrix&, const BaseMatrix&);
01338 NEW_DELETE(KPMatrix)
01339 };
01340
01341 class ConcatenatedMatrix : public MultipliedMatrix
01342 {
01343 protected:
01344 ConcatenatedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
01345 : MultipliedMatrix(bm1x,bm2x) {}
01346
01347 friend class BaseMatrix;
01348 friend class GeneralMatrix;
01349 friend class GenericMatrix;
01350 public:
01351 ~ConcatenatedMatrix() {}
01352 MatrixBandWidth BandWidth() const;
01353 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01354 NEW_DELETE(ConcatenatedMatrix)
01355 };
01356
01357 class StackedMatrix : public ConcatenatedMatrix
01358 {
01359 protected:
01360 StackedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
01361 : ConcatenatedMatrix(bm1x,bm2x) {}
01362
01363 friend class BaseMatrix;
01364 friend class GeneralMatrix;
01365 friend class GenericMatrix;
01366 public:
01367 ~StackedMatrix() {}
01368 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01369 NEW_DELETE(StackedMatrix)
01370 };
01371
01372 class SolvedMatrix : public MultipliedMatrix
01373 {
01374 SolvedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
01375 : MultipliedMatrix(bm1x,bm2x) {}
01376 friend class BaseMatrix;
01377 friend class InvertedMatrix;
01378 public:
01379 ~SolvedMatrix() {}
01380 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01381 MatrixBandWidth BandWidth() const;
01382 NEW_DELETE(SolvedMatrix)
01383 };
01384
01385 class SubtractedMatrix : public AddedMatrix
01386 {
01387 SubtractedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
01388 : AddedMatrix(bm1x,bm2x) {}
01389 friend class BaseMatrix;
01390 friend class GeneralMatrix;
01391 friend class GenericMatrix;
01392 public:
01393 ~SubtractedMatrix() {}
01394 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01395 NEW_DELETE(SubtractedMatrix)
01396 };
01397
01398 class ShiftedMatrix : public BaseMatrix
01399 {
01400 protected:
01401 union { const BaseMatrix* bm; GeneralMatrix* gm; };
01402 Real f;
01403 ShiftedMatrix(const BaseMatrix* bmx, Real fx) : bm(bmx),f(fx) {}
01404 int search(const BaseMatrix*) const;
01405 friend class BaseMatrix;
01406 friend class GeneralMatrix;
01407 friend class GenericMatrix;
01408 public:
01409 ~ShiftedMatrix() {}
01410 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01411 friend ShiftedMatrix operator+(Real f, const BaseMatrix& BM);
01412 NEW_DELETE(ShiftedMatrix)
01413 };
01414
01415 class NegShiftedMatrix : public ShiftedMatrix
01416 {
01417 protected:
01418 NegShiftedMatrix(Real fx, const BaseMatrix* bmx) : ShiftedMatrix(bmx,fx) {}
01419 friend class BaseMatrix;
01420 friend class GeneralMatrix;
01421 friend class GenericMatrix;
01422 public:
01423 ~NegShiftedMatrix() {}
01424 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01425 friend NegShiftedMatrix operator-(Real, const BaseMatrix&);
01426 NEW_DELETE(NegShiftedMatrix)
01427 };
01428
01429 class ScaledMatrix : public ShiftedMatrix
01430 {
01431 ScaledMatrix(const BaseMatrix* bmx, Real fx) : ShiftedMatrix(bmx,fx) {}
01432 friend class BaseMatrix;
01433 friend class GeneralMatrix;
01434 friend class GenericMatrix;
01435 public:
01436 ~ScaledMatrix() {}
01437 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01438 MatrixBandWidth BandWidth() const;
01439
01440 friend ScaledMatrix operator*(Real f, const BaseMatrix& BM);
01441
01442
01443 NEW_DELETE(ScaledMatrix)
01444 };
01445
01446 class NegatedMatrix : public BaseMatrix
01447 {
01448 protected:
01449 union { const BaseMatrix* bm; GeneralMatrix* gm; };
01450 NegatedMatrix(const BaseMatrix* bmx) : bm(bmx) {}
01451 int search(const BaseMatrix*) const;
01452 private:
01453 friend class BaseMatrix;
01454 public:
01455 ~NegatedMatrix() {}
01456 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01457 MatrixBandWidth BandWidth() const;
01458 NEW_DELETE(NegatedMatrix)
01459 };
01460
01461 class TransposedMatrix : public NegatedMatrix
01462 {
01463 TransposedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
01464 friend class BaseMatrix;
01465 public:
01466 ~TransposedMatrix() {}
01467 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01468 MatrixBandWidth BandWidth() const;
01469 NEW_DELETE(TransposedMatrix)
01470 };
01471
01472 class ReversedMatrix : public NegatedMatrix
01473 {
01474 ReversedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
01475 friend class BaseMatrix;
01476 public:
01477 ~ReversedMatrix() {}
01478 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01479 NEW_DELETE(ReversedMatrix)
01480 };
01481
01482 class InvertedMatrix : public NegatedMatrix
01483 {
01484 InvertedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
01485 public:
01486 ~InvertedMatrix() {}
01487 SolvedMatrix operator*(const BaseMatrix&) const;
01488 ScaledMatrix operator*(Real t) const { return BaseMatrix::operator*(t); }
01489 friend class BaseMatrix;
01490 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01491 MatrixBandWidth BandWidth() const;
01492 NEW_DELETE(InvertedMatrix)
01493 };
01494
01495 class RowedMatrix : public NegatedMatrix
01496 {
01497 RowedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
01498 friend class BaseMatrix;
01499 public:
01500 ~RowedMatrix() {}
01501 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01502 MatrixBandWidth BandWidth() const;
01503 NEW_DELETE(RowedMatrix)
01504 };
01505
01506 class ColedMatrix : public NegatedMatrix
01507 {
01508 ColedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
01509 friend class BaseMatrix;
01510 public:
01511 ~ColedMatrix() {}
01512 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01513 MatrixBandWidth BandWidth() const;
01514 NEW_DELETE(ColedMatrix)
01515 };
01516
01517 class DiagedMatrix : public NegatedMatrix
01518 {
01519 DiagedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
01520 friend class BaseMatrix;
01521 public:
01522 ~DiagedMatrix() {}
01523 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01524 MatrixBandWidth BandWidth() const;
01525 NEW_DELETE(DiagedMatrix)
01526 };
01527
01528 class MatedMatrix : public NegatedMatrix
01529 {
01530 int nr, nc;
01531 MatedMatrix(const BaseMatrix* bmx, int nrx, int ncx)
01532 : NegatedMatrix(bmx), nr(nrx), nc(ncx) {}
01533 friend class BaseMatrix;
01534 public:
01535 ~MatedMatrix() {}
01536 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01537 MatrixBandWidth BandWidth() const;
01538 NEW_DELETE(MatedMatrix)
01539 };
01540
01541 class ReturnMatrix : public BaseMatrix
01542 {
01543 GeneralMatrix* gm;
01544 int search(const BaseMatrix*) const;
01545 public:
01546 ~ReturnMatrix() {}
01547 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01548 friend class BaseMatrix;
01549 ReturnMatrix(const ReturnMatrix& tm) : gm(tm.gm) {}
01550 ReturnMatrix(const GeneralMatrix* gmx) : gm((GeneralMatrix*&)gmx) {}
01551
01552 MatrixBandWidth BandWidth() const;
01553 NEW_DELETE(ReturnMatrix)
01554 };
01555
01556
01557
01558
01559 class GetSubMatrix : public NegatedMatrix
01560 {
01561 int row_skip;
01562 int row_number;
01563 int col_skip;
01564 int col_number;
01565 bool IsSym;
01566
01567 GetSubMatrix
01568 (const BaseMatrix* bmx, int rs, int rn, int cs, int cn, bool is)
01569 : NegatedMatrix(bmx),
01570 row_skip(rs), row_number(rn), col_skip(cs), col_number(cn), IsSym(is) {}
01571 void SetUpLHS();
01572 friend class BaseMatrix;
01573 public:
01574 GetSubMatrix(const GetSubMatrix& g)
01575 : NegatedMatrix(g.bm), row_skip(g.row_skip), row_number(g.row_number),
01576 col_skip(g.col_skip), col_number(g.col_number), IsSym(g.IsSym) {}
01577 ~GetSubMatrix() {}
01578 GeneralMatrix* Evaluate(MatrixType mt=MatrixTypeUnSp);
01579 void operator=(const BaseMatrix&);
01580 void operator+=(const BaseMatrix&);
01581 void operator-=(const BaseMatrix&);
01582 void operator=(const GetSubMatrix& m) { operator=((const BaseMatrix&)m); }
01583 void operator<<(const BaseMatrix&);
01584 void operator<<(const double*);
01585 void operator<<(const float*);
01586 void operator<<(const int*);
01587 MatrixInput operator<<(double);
01588 MatrixInput operator<<(float);
01589 MatrixInput operator<<(int f);
01590 void operator=(Real);
01591 void operator+=(Real);
01592 void operator-=(Real r) { operator+=(-r); }
01593 void operator*=(Real);
01594 void operator/=(Real r) { operator*=(1.0/r); }
01595 void Inject(const GeneralMatrix&);
01596 MatrixBandWidth BandWidth() const;
01597 NEW_DELETE(GetSubMatrix)
01598 };
01599
01600
01601
01602 class LinearEquationSolver : public BaseMatrix
01603 {
01604 GeneralMatrix* gm;
01605 int search(const BaseMatrix*) const { return 0; }
01606 friend class BaseMatrix;
01607 public:
01608 LinearEquationSolver(const BaseMatrix& bm);
01609 ~LinearEquationSolver() { delete gm; }
01610 void CleanUp() { delete gm; }
01611 GeneralMatrix* Evaluate(MatrixType) { return gm; }
01612
01613 NEW_DELETE(LinearEquationSolver)
01614 };
01615
01616
01617
01618 class MatrixInput
01619
01620
01621 {
01622 int n;
01623 Real* r;
01624 public:
01625 MatrixInput(const MatrixInput& mi) : n(mi.n), r(mi.r) {}
01626 MatrixInput(int nx, Real* rx) : n(nx), r(rx) {}
01627 ~MatrixInput();
01628 MatrixInput operator<<(double);
01629 MatrixInput operator<<(float);
01630 MatrixInput operator<<(int f);
01631 friend class GeneralMatrix;
01632 };
01633
01634
01635
01636
01637
01638
01639
01640
01641 class SimpleIntArray : public Janitor
01642 {
01643 protected:
01644 int* a;
01645 int n;
01646 public:
01647 SimpleIntArray(int xn);
01648 SimpleIntArray() : a(0), n(0) {}
01649 ~SimpleIntArray();
01650 int& operator[](int i);
01651 int operator[](int i) const;
01652
01653 void operator=(int ai);
01654 void operator=(const SimpleIntArray& b);
01655
01656 SimpleIntArray(const SimpleIntArray& b);
01657
01658 int Size() const { return n; }
01659
01660 int size() const { return n; }
01661
01662 int* Data() { return a; }
01663 const int* Data() const { return a; }
01664 int* data() { return a; }
01665 const int* data() const { return a; }
01666 const int* const_data() const { return a; }
01667 void ReSize(int i, bool keep = false);
01668
01669 void resize(int i, bool keep = false) { ReSize(i, keep); }
01670
01671 void CleanUp() { ReSize(0); }
01672 NEW_DELETE(SimpleIntArray)
01673 };
01674
01675
01676
01677 class RealStarStar
01678 {
01679 Real** a;
01680 public:
01681 RealStarStar(Matrix& A);
01682 ~RealStarStar() { delete [] a; }
01683 operator Real**() { return a; }
01684 };
01685
01686 class ConstRealStarStar
01687 {
01688 const Real** a;
01689 public:
01690 ConstRealStarStar(const Matrix& A);
01691 ~ConstRealStarStar() { delete [] a; }
01692 operator const Real**() { return a; }
01693 };
01694
01695
01696
01697 class NPDException : public Runtime_error
01698 {
01699 public:
01700 static unsigned long Select;
01701 NPDException(const GeneralMatrix&);
01702 };
01703
01704 class ConvergenceException : public Runtime_error
01705 {
01706 public:
01707 static unsigned long Select;
01708 ConvergenceException(const GeneralMatrix& A);
01709 ConvergenceException(const char* c);
01710 };
01711
01712 class SingularException : public Runtime_error
01713 {
01714 public:
01715 static unsigned long Select;
01716 SingularException(const GeneralMatrix& A);
01717 };
01718
01719 class OverflowException : public Runtime_error
01720 {
01721 public:
01722 static unsigned long Select;
01723 OverflowException(const char* c);
01724 };
01725
01726 class ProgramException : public Logic_error
01727 {
01728 protected:
01729 ProgramException();
01730 public:
01731 static unsigned long Select;
01732 ProgramException(const char* c);
01733 ProgramException(const char* c, const GeneralMatrix&);
01734 ProgramException(const char* c, const GeneralMatrix&, const GeneralMatrix&);
01735 ProgramException(const char* c, MatrixType, MatrixType);
01736 };
01737
01738 class IndexException : public Logic_error
01739 {
01740 public:
01741 static unsigned long Select;
01742 IndexException(int i, const GeneralMatrix& A);
01743 IndexException(int i, int j, const GeneralMatrix& A);
01744
01745 IndexException(int i, const GeneralMatrix& A, bool);
01746 IndexException(int i, int j, const GeneralMatrix& A, bool);
01747 };
01748
01749 class VectorException : public Logic_error
01750 {
01751 public:
01752 static unsigned long Select;
01753 VectorException();
01754 VectorException(const GeneralMatrix& A);
01755 };
01756
01757 class NotSquareException : public Logic_error
01758 {
01759 public:
01760 static unsigned long Select;
01761 NotSquareException(const GeneralMatrix& A);
01762 NotSquareException();
01763 };
01764
01765 class SubMatrixDimensionException : public Logic_error
01766 {
01767 public:
01768 static unsigned long Select;
01769 SubMatrixDimensionException();
01770 };
01771
01772 class IncompatibleDimensionsException : public Logic_error
01773 {
01774 public:
01775 static unsigned long Select;
01776 IncompatibleDimensionsException();
01777 IncompatibleDimensionsException(const GeneralMatrix&);
01778 IncompatibleDimensionsException(const GeneralMatrix&, const GeneralMatrix&);
01779 };
01780
01781 class NotDefinedException : public Logic_error
01782 {
01783 public:
01784 static unsigned long Select;
01785 NotDefinedException(const char* op, const char* matrix);
01786 };
01787
01788 class CannotBuildException : public Logic_error
01789 {
01790 public:
01791 static unsigned long Select;
01792 CannotBuildException(const char* matrix);
01793 };
01794
01795
01796 class InternalException : public Logic_error
01797 {
01798 public:
01799 static unsigned long Select;
01800 InternalException(const char* c);
01801 };
01802
01803
01804
01805 bool operator==(const GeneralMatrix& A, const GeneralMatrix& B);
01806 bool operator==(const BaseMatrix& A, const BaseMatrix& B);
01807 inline bool operator!=(const GeneralMatrix& A, const GeneralMatrix& B)
01808 { return ! (A==B); }
01809 inline bool operator!=(const BaseMatrix& A, const BaseMatrix& B)
01810 { return ! (A==B); }
01811
01812
01813
01814 inline bool operator<=(const BaseMatrix& A, const BaseMatrix&)
01815 { A.IEQND(); return true; }
01816 inline bool operator>=(const BaseMatrix& A, const BaseMatrix&)
01817 { A.IEQND(); return true; }
01818 inline bool operator<(const BaseMatrix& A, const BaseMatrix&)
01819 { A.IEQND(); return true; }
01820 inline bool operator>(const BaseMatrix& A, const BaseMatrix&)
01821 { A.IEQND(); return true; }
01822
01823 bool IsZero(const BaseMatrix& A);
01824
01825 Matrix CrossProduct(const Matrix& A, const Matrix& B);
01826 ReturnMatrix CrossProductRows(const Matrix& A, const Matrix& B);
01827 ReturnMatrix CrossProductColumns(const Matrix& A, const Matrix& B);
01828
01829
01830
01831
01832
01833 inline LogAndSign LogDeterminant(const BaseMatrix& B)
01834 { return B.LogDeterminant(); }
01835 inline Real Determinant(const BaseMatrix& B)
01836 { return B.Determinant(); }
01837 inline Real SumSquare(const BaseMatrix& B) { return B.SumSquare(); }
01838 inline Real NormFrobenius(const BaseMatrix& B) { return B.NormFrobenius(); }
01839 inline Real Trace(const BaseMatrix& B) { return B.Trace(); }
01840 inline Real SumAbsoluteValue(const BaseMatrix& B)
01841 { return B.SumAbsoluteValue(); }
01842 inline Real Sum(const BaseMatrix& B)
01843 { return B.Sum(); }
01844 inline Real MaximumAbsoluteValue(const BaseMatrix& B)
01845 { return B.MaximumAbsoluteValue(); }
01846 inline Real MinimumAbsoluteValue(const BaseMatrix& B)
01847 { return B.MinimumAbsoluteValue(); }
01848 inline Real Maximum(const BaseMatrix& B) { return B.Maximum(); }
01849 inline Real Minimum(const BaseMatrix& B) { return B.Minimum(); }
01850 inline Real Norm1(const BaseMatrix& B) { return B.Norm1(); }
01851 inline Real Norm1(RowVector& RV) { return RV.MaximumAbsoluteValue(); }
01852 inline Real NormInfinity(const BaseMatrix& B) { return B.NormInfinity(); }
01853 inline Real NormInfinity(ColumnVector& CV)
01854 { return CV.MaximumAbsoluteValue(); }
01855 inline bool IsZero(const GeneralMatrix& A) { return A.IsZero(); }
01856
01857
01858 inline MatrixInput MatrixInput::operator<<(int f) { return *this << (Real)f; }
01859 inline MatrixInput GeneralMatrix::operator<<(int f) { return *this << (Real)f; }
01860 inline MatrixInput BandMatrix::operator<<(int f) { return *this << (Real)f; }
01861 inline MatrixInput GetSubMatrix::operator<<(int f) { return *this << (Real)f; }
01862
01863 inline void swap(Matrix& A, Matrix& B) { A.swap(B); }
01864 inline void swap(SquareMatrix& A, SquareMatrix& B) { A.swap(B); }
01865 inline void swap(nricMatrix& A, nricMatrix& B) { A.swap(B); }
01866 inline void swap(UpperTriangularMatrix& A, UpperTriangularMatrix& B)
01867 { A.swap(B); }
01868 inline void swap(LowerTriangularMatrix& A, LowerTriangularMatrix& B)
01869 { A.swap(B); }
01870 inline void swap(SymmetricMatrix& A, SymmetricMatrix& B) { A.swap(B); }
01871 inline void swap(DiagonalMatrix& A, DiagonalMatrix& B) { A.swap(B); }
01872 inline void swap(RowVector& A, RowVector& B) { A.swap(B); }
01873 inline void swap(ColumnVector& A, ColumnVector& B) { A.swap(B); }
01874 inline void swap(CroutMatrix& A, CroutMatrix& B) { A.swap(B); }
01875 inline void swap(BandMatrix& A, BandMatrix& B) { A.swap(B); }
01876 inline void swap(UpperBandMatrix& A, UpperBandMatrix& B) { A.swap(B); }
01877 inline void swap(LowerBandMatrix& A, LowerBandMatrix& B) { A.swap(B); }
01878 inline void swap(SymmetricBandMatrix& A, SymmetricBandMatrix& B) { A.swap(B); }
01879 inline void swap(BandLUMatrix& A, BandLUMatrix& B) { A.swap(B); }
01880 inline void swap(IdentityMatrix& A, IdentityMatrix& B) { A.swap(B); }
01881 inline void swap(GenericMatrix& A, GenericMatrix& B) { A.swap(B); }
01882
01883
01884 #ifdef OPT_COMPATIBLE // for compatibility with opt++
01885
01886 inline ScaledMatrix operator*(Real f, const BaseMatrix& BM)
01887 { return ScaledMatrix(&BM, f); }
01888 inline Real Norm2(const ColumnVector& CV) { return CV.NormFrobenius(); }
01889 inline Real Dot(ColumnVector& CV1, ColumnVector& CV2)
01890 { return DotProduct(CV1, CV2); }
01891
01892 #endif
01893
01894
01895 #ifdef use_namespace
01896 }
01897 #endif
01898
01899
01900 #endif
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919