Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

CMatrix.hh

Go to the documentation of this file.
00001 #ifndef CMATRIX_HH
00002 #define CMATRIX_HH
00003  
00004 #include <iostream>
00005 #include <math/Complex.hh>
00006 #include <CRlcException.hh>
00007 
00008 template <typename Type>
00009 class CMatrix
00010 {
00011 public:
00012  CMatrix();
00013  CMatrix(int rows, int columns);
00014  CMatrix(const CMatrix<Type>& m);
00015  ~CMatrix();
00016  
00017  void zero();
00018  Type* operator[](int i);
00019  const Type* operator[](int i) const;
00020  int rows() const {return m_rows;}
00021  int columns() const {return m_columns;}
00022 
00023  void setRows(int r) {m_rows=r;}
00024  
00025  void invert();
00026 
00027  CMatrix<Type>& operator=(const CMatrix<Type>& x);
00028  CMatrix<Type>& operator+=(Type x);
00029  CMatrix<Type>& operator-=(Type x);
00030  CMatrix<Type>& operator*=(Type x);
00031  CMatrix<Type>& operator/=(Type x);
00032  CMatrix<Type>& operator+=(const CMatrix<Type>& x);
00033  CMatrix<Type>& operator-=(const CMatrix<Type>& x);
00034  
00035  CMatrix<Type> operator*(Type x) const;
00036  CMatrix<Type> operator/(Type x) const;
00037  CMatrix<Type> operator+(const CMatrix<Type>& x) const;
00038  CMatrix<Type> operator-(const CMatrix<Type>& x) const;
00039  CMatrix<Type> operator*(const CMatrix<Type>& x) const;
00040  CMatrix<Type> operator-() const;
00041  CMatrix<Type> T() const; // transpose
00042   
00043  void print(std::ostream& os = std::cout) const;
00044  
00045  class CMatrixException:public CRlcException
00046  {
00047    public:
00048      CMatrixException(const std::string &e="Matrix Exception"):CRlcException(e){};
00049  };
00050  
00051  class CMatrixSizeError:public CMatrixException
00052  {
00053    public:
00054      CMatrixSizeError(const std::string &e="Matrix Size Error"):CMatrixException(e){};
00055  };
00056  
00057 
00058 private:
00059  
00060  int m_rows, m_columns; //number of rows and colums
00061  Type* m_data; //pointer to data
00062   
00063 };
00064 
00065 template <typename Type>
00066 inline Type* CMatrix<Type>::operator[](int i) {return m_data + m_columns * i;}
00067 
00068 template <typename Type>
00069 inline const Type* CMatrix<Type>::operator[](int i) const {return m_data + m_columns * i;}
00070 
00071 template <typename Type>
00072 inline CMatrix<Type> operator*(float x, const CMatrix<Type>& y) {return y * x;}
00073  
00074 #endif 

Generated on Sun Jan 16 11:05:56 2005 for RolLerCoaster by  doxygen 1.3.9.1