Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iostream>
- #include <string>
- #include <iomanip>
- #include <exception>
- namespace labworks
- {
- class MyException : public std::exception {
- private:
- int _id;
- std::string msg;
- public:
- MyException(const char *Message, int ID)
- : _id(ID)
- , msg(Message)
- {
- }
- const char* what() const throw() override
- {
- return msg.c_str();
- }
- int ID() const
- {
- return _id;
- }
- };
- class Matrix
- {
- private:
- int _rows;
- int _cols;
- int _id;
- double* _elements;
- static int s_count;
- public:
- Matrix();
- Matrix(double Skalar);
- Matrix(const Matrix& A);
- Matrix(Matrix&& A) noexcept;
- explicit Matrix(int Rows);
- Matrix(int Rows, double Value);
- Matrix(int Rows, int Cols);
- Matrix(int Rows, int Cols, double Value);
- Matrix(int Rows, double(*func) (int, int));
- Matrix(int Rows, int Cols, double(*func) (int, int));
- Matrix(int Rows, const double* Massive, int Size = -1, bool iter = false);
- Matrix(int Rows, int Cols, const double* Massive, int Size = -1, bool iter = false);
- int GetRows() const;
- int GetCols() const;
- int GetId() const;
- static int GetCount();
- const double* GetElements() const;
- int SetRows(int Rows);
- int SetCols(int Cols);
- int SetSize(int Rows, int Cols);
- bool MultCheck(const Matrix& B) const;
- bool SummCheck(const Matrix& B) const;
- double SearchMax() const;
- double SearchMin() const;
- //operator peregruzki
- Matrix& operator = (const Matrix& A);
- Matrix& operator += (const Matrix& A);
- Matrix& operator -= (const Matrix& A);
- Matrix& operator *= (const Matrix& A);
- Matrix& operator *= (double Skalar);
- Matrix& operator = (double Skalar);
- class Pointer
- {
- public:
- Pointer(double* A, int Size, int ID) :
- a(A), size(Size), id(ID)
- {
- }
- double operator [] (int i) const
- {
- if (size > i)
- return a[i];
- else
- throw MyException("Array index out of bounds!", id);
- }
- double& operator [] (int i)
- {
- if (size > i)
- return a[i];
- else
- throw MyException("Array index out of bounds!", id);
- }
- double* a;
- int size;
- int id;
- };
- Pointer operator[] (int index);
- const Pointer operator[] (int index) const;
- double& operator() (int i, int j);
- double operator() (int i, int j) const;
- friend std::ostream& operator <<(std::ostream& s, const Matrix& A);
- ~Matrix();
- };
- Matrix operator + (const Matrix& A, const Matrix& B);
- Matrix operator - (const Matrix& A, const Matrix& B);
- Matrix operator * (const Matrix& A, const Matrix& B);
- Matrix operator * (const Matrix& A, double Skalar);
- Matrix operator * (double Skalar, const Matrix& A);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement