Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. #ifndef MATRIX_HPP
  2. #define MATRIX_HPP
  3.  
  4. #include <cmath>
  5. #include <cassert>
  6. #include <iostream>
  7.  
  8. class Matrix {
  9. private:
  10.   int height;
  11.   int width;
  12.   double* coeff;
  13.  
  14. public:
  15.   //konstruktor, destruktor, zuweisung
  16.  
  17.   Matrix();
  18.   Matrix(int height_new, int width_new, double init=0);
  19.   Matrix(const Matrix&);
  20.   ~Matrix();
  21.   Matrix& operator=(const Matrix&);
  22.  
  23.   //size of zurueckgeben
  24.   int rows() const;
  25.   int columns() const;
  26.  
  27.   //lesen und schreiben von matrix eintraegen A(j, k)
  28.   const double& operator()(int j, int k) const;
  29.   double& operator()(int j, int k);
  30.  
  31.   //speichervektoren lesen und schreiben A[ell]
  32.   const double& operator[](int ell) const;
  33.   double& operator[](int ell);
  34.  
  35.   //norm berechnen
  36.   double norm() const;
  37. };
  38.  
  39.  
  40. class SqMatrix : public Matrix {
  41.   //keine neue elemente, nur neue methoden
  42. public:
  43.   SqMatrix();
  44.   SqMatrix(int dim, double init=0);
  45.   SqMatrix(const Matrix&); //type cast Matrix to SqMatrix
  46.  
  47.   int dimension() const;
  48. };
  49.  
  50.  
  51.  
  52.  
  53. //matrix-matrix summe und produkt
  54.  
  55. const Matrix operator+(const Matrix&, const Matrix&);
  56. const Matrix operator*(const Matrix&, const Matrix&);
  57.  
  58. //print via output stream
  59.  
  60. std::ostream& operator<<(std::ostream& output, const Matrix&);
  61.  
  62.  
  63.  
  64. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement