Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #ifndef __matrix_H__
  2. #define __matrix_H__
  3. #include <iostream>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7. class RcMatrix
  8. {
  9. public:
  10. struct Array;
  11. Array* pArray;
  12. class Cref;
  13.  
  14. public:
  15. //Konstruktory i Destruktory
  16. RcMatrix();
  17. RcMatrix(unsigned int);
  18. RcMatrix(unsigned int, unsigned int);
  19. RcMatrix(unsigned int, unsigned int, double*);
  20. ~RcMatrix();
  21.  
  22. //Operacje matematyczne
  23. operator=(const RcMatrix&);
  24. RcMatrix operator+(const RcMatrix&)const;
  25. RcMatrix operator+=(const RcMatrix&);
  26. RcMatrix operator-(const RcMatrix&)const;
  27. RcMatrix operator-=(const RcMatrix&);
  28. RcMatrix operator-()const;
  29. RcMatrix operator*(const RcMatrix&)const;
  30. RcMatrix operator*=(const RcMatrix&);
  31. bool operator ==(const RcMatrix &)const;
  32.  
  33. //Do zliczania referencji
  34. void detach();
  35.  
  36. //Wpisywanie i czytanie
  37. friend ostream & operator << (ostream &, const RcMatrix &);
  38. double operator()(unsigned int j, unsigned int i) const;
  39. Cref operator()(unsigned int j, unsigned int i);
  40. void write(double**);
  41. void write(double*);
  42. double read(unsigned int,unsigned int);
  43.  
  44. //Do obsługi błędów
  45. private:
  46. class Range{};
  47. void check_range(const RcMatrix& a, const RcMatrix& b);
  48.  
  49. //Inne
  50. public:
  51. unsigned int getRef();
  52. };
  53.  
  54. struct RcMatrix::Array
  55. {
  56.  
  57. double** m;
  58. unsigned int column, line;
  59. unsigned int n;
  60.  
  61. //Konstruktory i destruktory
  62. Array(unsigned int line, unsigned int column);
  63. ~Array();
  64.  
  65. //Funkcje
  66. void write(double **);
  67. double read(unsigned int, unsigned int);
  68. void array_free();
  69. };
  70.  
  71. class RcMatrix::Cref
  72. {
  73. friend class RcMatrix;
  74. RcMatrix& m;
  75. int i,j;
  76. Cref (RcMatrix& mm, unsigned int jj, unsigned int ii): m(mm), j(jj), i(ii) {};
  77.  
  78. public:
  79. operator double() const;
  80. RcMatrix::Cref& operator = (double value);
  81. };
  82.  
  83.  
  84. #endif /* __matrix_H__ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement