00001 #ifndef __NEW_MAT_DIAGONAL_MATRIX_H__ 00002 #define __NEW_MAT_DIAGONAL_MATRIX_H__ 00003 00005 class DiagonalMatrix : public GeneralMatrix 00006 { 00007 GeneralMatrix* Image() const; // copy of matrix 00008 public: 00009 DiagonalMatrix() {} 00010 ~DiagonalMatrix() {} 00011 DiagonalMatrix(ArrayLengthSpecifier); 00012 DiagonalMatrix(const BaseMatrix&); 00013 DiagonalMatrix(const DiagonalMatrix& gm) 00014 : GeneralMatrix() { GetMatrix(&gm); } 00015 void operator=(const BaseMatrix&); 00016 void operator=(Real f) { GeneralMatrix::operator=(f); } 00017 void operator=(const DiagonalMatrix& m) { Eq(m); } 00018 Real& operator()(int, int); // access element 00019 Real& operator()(int); // access element 00020 Real operator()(int, int) const; // access element 00021 Real operator()(int) const; 00022 Real& element(int, int); // access element 00023 Real& element(int); // access element 00024 Real element(int, int) const; // access element 00025 Real element(int) const; // access element 00026 #ifdef SETUP_C_SUBSCRIPTS 00027 Real& operator[](int m) { return store[m]; } 00028 const Real& operator[](int m) const { return store[m]; } 00029 #endif 00030 MatrixType type() const; 00031 00032 LogAndSign log_determinant() const; 00033 Real trace() const; 00034 void GetRow(MatrixRowCol&); 00035 void GetCol(MatrixRowCol&); 00036 void GetCol(MatrixColX&); 00037 void NextRow(MatrixRowCol&); 00038 void NextCol(MatrixRowCol&); 00039 void NextCol(MatrixColX&); 00040 GeneralMatrix* MakeSolver() { return this; } // for solving 00041 void Solver(MatrixColX&, const MatrixColX&); 00042 GeneralMatrix* Transpose(TransposedMatrix*, MatrixType); 00043 void resize(int); // change dimensions 00044 void ReSize(int m) { resize(m); } 00045 void resize_keep(int); 00046 void resize(const GeneralMatrix& A); 00047 void ReSize(const GeneralMatrix& A) { resize(A); } 00048 Real* nric() const 00049 { CheckStore(); return store-1; } // for use by NRIC 00050 MatrixBandWidth bandwidth() const; 00051 // ReturnMatrix Reverse() const; // reverse order of elements 00052 void operator+=(const DiagonalMatrix& M) { PlusEqual(M); } 00053 void operator-=(const DiagonalMatrix& M) { MinusEqual(M); } 00054 void operator+=(Real f) { GeneralMatrix::operator+=(f); } 00055 void operator-=(Real f) { GeneralMatrix::operator-=(f); } 00056 void swap(DiagonalMatrix& gm) 00057 { GeneralMatrix::swap((GeneralMatrix&)gm); } 00058 NEW_DELETE(DiagonalMatrix) 00059 }; 00060 00061 #endif 00062