⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newmat.h

📁 科学和工程计算中使用统计功能开发工具包.
💻 H
📖 第 1 页 / 共 3 页
字号:
class AddedMatrix : public MultipliedMatrix
{
protected:
   AddedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
      : MultipliedMatrix(bm1x,bm2x) {}

private:
   MatrixType Type() const;
   friend BaseMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   MatrixBandWidth BandWidth() const;
#ifdef GXX
   void SelectVersion(MatrixType, int&, int&) const;
#else
   void SelectVersion(MatrixType, Boolean&, Boolean&) const;
#endif
   NEW_DELETE(AddedMatrix)
};

class SolvedMatrix : public MultipliedMatrix
{
   SolvedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
      : MultipliedMatrix(bm1x,bm2x) {}
   MatrixType Type() const;
   friend BaseMatrix;
   friend InvertedMatrix;                        // for operator*
public:
   GeneralMatrix* Evaluate(MatrixType);
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(SolvedMatrix)
};

class SubtractedMatrix : public AddedMatrix
{
   SubtractedMatrix(const BaseMatrix* bm1x, const BaseMatrix* bm2x)
      : AddedMatrix(bm1x,bm2x) {}
   MatrixType Type() const;
   friend BaseMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   NEW_DELETE(SubtractedMatrix)
};

class ShiftedMatrix : public BaseMatrix
{
protected:
   Real f;
   union { const BaseMatrix* bm; GeneralMatrix* gm; };
   ShiftedMatrix(const BaseMatrix* bmx, Real fx) : bm(bmx),f(fx) {}
   int search(const BaseMatrix*) const;
//   int NrowsV() const;
//   int NcolsV() const;
private:
   MatrixType Type() const;
   friend BaseMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   NEW_DELETE(ShiftedMatrix)
};

class ScaledMatrix : public ShiftedMatrix
{
   ScaledMatrix(const BaseMatrix* bmx, Real fx) : ShiftedMatrix(bmx,fx) {}
   MatrixType Type() const;
   friend BaseMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(ScaledMatrix)
};

class NegatedMatrix : public BaseMatrix
{
protected:
   union { const BaseMatrix* bm; GeneralMatrix* gm; };
   NegatedMatrix(const BaseMatrix* bmx) : bm(bmx) {}
   int search(const BaseMatrix*) const;
//   int NrowsV() const;
//   int NcolsV() const;
private:
   MatrixType Type() const;
   friend BaseMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(NegatedMatrix)
};

class TransposedMatrix : public NegatedMatrix
{
   TransposedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
//   int NrowsV() const;
//   int NcolsV() const;
   MatrixType Type() const;
   friend BaseMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(TransposedMatrix)
};

class InvertedMatrix : public NegatedMatrix
{
   InvertedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
   MatrixType Type() const;
public:
#ifndef TEMPS_DESTROYED_QUICKLY
   SolvedMatrix operator*(const BaseMatrix&) const;       // inverse(A) * B
#else
   SolvedMatrix& operator*(const BaseMatrix&) const;       // inverse(A) * B
#endif
   friend BaseMatrix;
   GeneralMatrix* Evaluate(MatrixType);
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(InvertedMatrix)
};

class RowedMatrix : public NegatedMatrix
{
   MatrixType Type() const;
//   int NrowsV() const;
//   int NcolsV() const;
   RowedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
   friend BaseMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(RowedMatrix)
};

class ColedMatrix : public NegatedMatrix
{
   MatrixType Type() const;
//   int NrowsV() const;
//   int NcolsV() const;
   ColedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
   friend BaseMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(ColedMatrix)
};

class DiagedMatrix : public NegatedMatrix
{
   MatrixType Type() const;
//   int NrowsV() const;
//   int NcolsV() const;
   DiagedMatrix(const BaseMatrix* bmx) : NegatedMatrix(bmx) {}
   friend BaseMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(DiagedMatrix)
};

class MatedMatrix : public NegatedMatrix
{
   int nr, nc;
   MatrixType Type() const;
//   int NrowsV() const;
//   int NcolsV() const;
   MatedMatrix(const BaseMatrix* bmx, int nrx, int ncx)
      : NegatedMatrix(bmx), nr(nrx), nc(ncx) {}
   friend BaseMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(MatedMatrix)
};

class ConstMatrix : public BaseMatrix
{
   const GeneralMatrix* cgm;
   MatrixType Type() const;
//   int NrowsV() const;
//   int NcolsV() const;
   int search(const BaseMatrix*) const;
   ConstMatrix(const GeneralMatrix* cgmx) : cgm(cgmx) {}
   friend BaseMatrix;
   friend GeneralMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(ConstMatrix)
};

class ReturnMatrixX : public BaseMatrix    // for matrix return
{
   GeneralMatrix* gm;
   MatrixType Type() const;
//   int NrowsV() const;
//   int NcolsV() const;
   int search(const BaseMatrix*) const;
public:
   GeneralMatrix* Evaluate(MatrixType);
   friend BaseMatrix;
#ifdef TEMPS_DESTROYED_QUICKLY
   ReturnMatrixX(const ReturnMatrixX& tm);
#else
   ReturnMatrixX(const ReturnMatrixX& tm) : gm(tm.gm) {}
#endif
   ReturnMatrixX(const GeneralMatrix* gmx) : gm((GeneralMatrix*&)gmx) {}
//   ReturnMatrixX(GeneralMatrix&);
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(ReturnMatrixX)
};


/**************************** submatrices ******************************/

class GetSubMatrix : public NegatedMatrix
{
   int row_skip;
   int row_number;
   int col_skip;
   int col_number;
   MatrixType mt;

   GetSubMatrix
      (const BaseMatrix* bmx, int rs, int rn, int cs, int cn, MatrixType mtx)
      : NegatedMatrix(bmx),
      row_skip(rs), row_number(rn), col_skip(cs), col_number(cn), mt(mtx) {}
   GetSubMatrix(const GetSubMatrix& g)
      : NegatedMatrix(g.bm), row_skip(g.row_skip), row_number(g.row_number),
      col_skip(g.col_skip), col_number(g.col_number), mt(g.mt) {}
   void SetUpLHS();
   MatrixType Type() const;
//   int NrowsV() const;
//   int NcolsV() const;
   friend BaseMatrix;
public:
   GeneralMatrix* Evaluate(MatrixType);
   void operator=(const BaseMatrix&);
   void operator<<(const BaseMatrix&);
   void operator<<(const Real*);                // copy from array
   void operator<<(Real);                       // copy from constant
   void Inject(const GeneralMatrix&);           // copy stored els only
   MatrixBandWidth BandWidth() const;
   NEW_DELETE(GetSubMatrix)
};


/***************************** exceptions ********************************/

class MatrixDetails
{
   MatrixType type;
   int nrows;
   int ncols;
   int ubw;
   int lbw;
public:
   MatrixDetails(const GeneralMatrix& A);
   void PrintOut();
};
   


class SpaceException : public Exception
{
public:
   static long st_type() { return 2; }
   long type() const { return 2; }
   static int action;
   SpaceException();
   static void SetAction(int a) { action=a; }
};


class MatrixException : public Exception
{
public:
   static long st_type() { return 3; }
   long type() const { return 3; }
   MatrixException(int);
   MatrixException(int, const GeneralMatrix&);
   MatrixException(int, const GeneralMatrix&, const GeneralMatrix&);
};

class DataException : public MatrixException
{
public:
   static long st_type() { return 3*53; }
   long type() const { return 3*53; }
   static int action;
   DataException(const GeneralMatrix& A);
   static void SetAction(int a) { action=a; }
};

class SingularException : public DataException
{
public:
   static long st_type() { return 3*53*109; }
   long type() const { return 3*53*109; }
   SingularException(const GeneralMatrix& A);
};

class NPDException : public DataException     // Not positive definite
{
public:
   static long st_type() { return 3*53*113; }
   long type() const { return 3*53*113; }
   NPDException(const GeneralMatrix&);
};

class ConvergenceException : public MatrixException
{
public:
   static long st_type() { return 3*59; }
   long type() const { return 3*59; }
   static int action;
   ConvergenceException(const GeneralMatrix& A);
   static void SetAction(int a) { action=a; }
};

class ProgramException : public MatrixException
{
public:
   static long st_type() { return 3*61; }
   long type() const { return 3*61; }
   static int action;
   ProgramException(char* c);
   ProgramException(char* c, const GeneralMatrix&);
   ProgramException(char* c, const GeneralMatrix&, const GeneralMatrix&);
   ProgramException();
   ProgramException(const GeneralMatrix&);
   static void SetAction(int a) { action=a; }
};

class IndexException : public ProgramException
{
public:
   static long st_type() { return 3*61*101; }
   long type() const { return 3*61*101; }
   IndexException(int i, const GeneralMatrix& A);
   IndexException(int i, int j, const GeneralMatrix& A);
   // next two are for access via element function
   IndexException(int i, const GeneralMatrix& A, Boolean);
   IndexException(int i, int j, const GeneralMatrix& A, Boolean);
};

class VectorException : public ProgramException    // can't convert to vector
{
public:
   static long st_type() { return 3*61*107; }
   long type() const { return 3*61*107; }
   VectorException();
   VectorException(const GeneralMatrix& A);
};

class NotSquareException : public ProgramException
{
public:
   static long st_type() { return 3*61*109; }
   long type() const { return 3*61*109; }
   NotSquareException(const GeneralMatrix& A);
};

class SubMatrixDimensionException : public ProgramException
{
public:
   static long st_type() { return 3*61*113; }
   long type() const { return 3*61*113; }
   SubMatrixDimensionException();
};

class IncompatibleDimensionsException : public ProgramException
{
public:
   static long st_type() { return 3*61*127; }
   long type() const { return 3*61*127; }
   IncompatibleDimensionsException();
};

class NotDefinedException : public ProgramException
{
public:
   static long st_type() { return 3*61*131; }
   long type() const { return 3*61*131; }
   NotDefinedException(char* op, char* matrix);
};

class CannotBuildException : public ProgramException
{
public:
   static long st_type() { return 3*61*137; }
   long type() const { return 3*61*137; }
   CannotBuildException(char* matrix);
};


class InternalException : public MatrixException
{
public:
   static long st_type() { return 3*67; }
   long type() const { return 3*67; }
   static int action;
   InternalException(char* c);
   static void SetAction(int a) { action=a; }
};


/***************************** functions ***********************************/


inline LogAndSign LogDeterminant(const BaseMatrix& B)
   { return B.LogDeterminant(); }
inline Real SumSquare(const BaseMatrix& B) { return B.SumSquare(); }
inline Real Trace(const BaseMatrix& B) { return B.Trace(); }
inline Real SumAbsoluteValue(const BaseMatrix& B)
   { return B.SumAbsoluteValue(); }
inline Real MaximumAbsoluteValue(const BaseMatrix& B)
   { return B.MaximumAbsoluteValue(); }
inline Real Norm1(const BaseMatrix& B) { return B.Norm1(); }
inline Real Norm1(RowVector& RV) { return RV.MaximumAbsoluteValue(); }
inline Real NormInfinity(const BaseMatrix& B) { return B.NormInfinity(); }
inline Real NormInfinity(ColumnVector& CV)
   { return CV.MaximumAbsoluteValue(); } 

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -