nukede

Untitled

Mar 30th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.48 KB | None | 0 0
  1. #ifndef __QS_MATRIX_H
  2. #define __QS_MATRIX_H
  3.  
  4. #include <vector>
  5.  
  6. template <typename T> class QSMatrix {
  7.  private:
  8.   std::vector<std::vector<T> > mat;
  9.   unsigned rows;
  10.   unsigned cols;
  11.  
  12.  public:
  13.   QSMatrix(unsigned _rows, unsigned _cols, const T& _initial);
  14.   QSMatrix(const QSMatrix<T>& rhs);
  15.   virtual ~QSMatrix();
  16.  
  17.   // Operator overloading, for "standard" mathematical matrix operations                                                                                                                                                          
  18.   QSMatrix<T>& operator=(const QSMatrix<T>& rhs);
  19.  
  20.   // Matrix mathematical operations                                                                                                                                                                                              
  21.   QSMatrix<T> operator+(const QSMatrix<T>& rhs);
  22.   QSMatrix<T>& operator+=(const QSMatrix<T>& rhs);
  23.   QSMatrix<T> operator-(const QSMatrix<T>& rhs);
  24.   QSMatrix<T>& operator-=(const QSMatrix<T>& rhs);
  25.   QSMatrix<T> operator*(const QSMatrix<T>& rhs);
  26.   QSMatrix<T>& operator*=(const QSMatrix<T>& rhs);
  27.   QSMatrix<T> transpose();
  28.  
  29.   // Matrix/scalar operations                                                                                                                                                                                                    
  30.   QSMatrix<T> operator+(const T& rhs);
  31.   QSMatrix<T> operator-(const T& rhs);
  32.   QSMatrix<T> operator*(const T& rhs);
  33.   QSMatrix<T> operator/(const T& rhs);
  34.  
  35.   // Matrix/vector operations                                                                                                                                                                                                    
  36.   std::vector<T> operator*(const std::vector<T>& rhs);
  37.   std::vector<T> diag_vec();
  38.  
  39.   // Access the individual elements                                                                                                                                                                                              
  40.   T& operator()(const unsigned& row, const unsigned& col);
  41.   const T& operator()(const unsigned& row, const unsigned& col) const;
  42.  
  43.   // Access the row and column sizes                                                                                                                                                                                              
  44.   unsigned get_rows() const;
  45.   unsigned get_cols() const;
  46.  
  47. };
Advertisement
Add Comment
Please, Sign In to add comment