Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef __matrix_H__
- #define __matrix_H__
- #include <iostream>
- #include <fstream>
- using namespace std;
- class RcMatrix
- {
- public:
- struct Array;
- Array* pArray;
- class Cref;
- public:
- //Konstruktory i Destruktory
- RcMatrix();
- RcMatrix(unsigned int);
- RcMatrix(unsigned int, unsigned int);
- RcMatrix(unsigned int, unsigned int, double*);
- ~RcMatrix();
- //Operacje matematyczne
- operator=(const RcMatrix&);
- RcMatrix operator+(const RcMatrix&)const;
- RcMatrix operator+=(const RcMatrix&);
- RcMatrix operator-(const RcMatrix&)const;
- RcMatrix operator-=(const RcMatrix&);
- RcMatrix operator-()const;
- RcMatrix operator*(const RcMatrix&)const;
- RcMatrix operator*=(const RcMatrix&);
- bool operator ==(const RcMatrix &)const;
- //Do zliczania referencji
- void detach();
- //Wpisywanie i czytanie
- friend ostream & operator << (ostream &, const RcMatrix &);
- double operator()(unsigned int j, unsigned int i) const;
- Cref operator()(unsigned int j, unsigned int i);
- void write(double**);
- void write(double*);
- double read(unsigned int,unsigned int);
- //Do obsługi błędów
- private:
- class Range{};
- void check_range(const RcMatrix& a, const RcMatrix& b);
- //Inne
- public:
- unsigned int getRef();
- };
- struct RcMatrix::Array
- {
- double** m;
- unsigned int column, line;
- unsigned int n;
- //Konstruktory i destruktory
- Array(unsigned int line, unsigned int column);
- ~Array();
- //Funkcje
- void write(double **);
- double read(unsigned int, unsigned int);
- void array_free();
- };
- class RcMatrix::Cref
- {
- friend class RcMatrix;
- RcMatrix& m;
- int i,j;
- Cref (RcMatrix& mm, unsigned int jj, unsigned int ii): m(mm), j(jj), i(ii) {};
- public:
- operator double() const;
- RcMatrix::Cref& operator = (double value);
- };
- #endif /* __matrix_H__ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement