forked from Aigo-Oggi/mp-2023-pmi2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvecmat.h
70 lines (58 loc) · 1.96 KB
/
vecmat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#ifndef VECMAT_H
#define VECMAT_H
#include <iostream>
#include <random>
#include <ctime>
class Vector;
class Matrix {
private:
int n, m;
double** matrix;
public:
Matrix(int row = 1, int col = 1);
Matrix(const Matrix& matr);
~Matrix();
// Операторы
Matrix operator+(const Matrix& matr);
Matrix& operator+=(const Matrix& matr);
Matrix operator-(const Matrix& matr);
Matrix& operator-=(const Matrix& matr);
Matrix operator*(Matrix& matr);
Matrix& operator=(const Matrix& matr);
double& operator()(int i, int j);
const double& operator()(int i, int j) const;
// Функции
int Rows() const { return n; };
int Cols() const { return m; };
void RandomMatrix(double min, double max);
friend class Gauss;
friend std::ostream& operator<<(std::ostream& os, const Matrix& matr);
friend std::istream& operator>>(std::istream& os, Matrix& matr);
friend Vector operator*(Matrix& matr, Vector& vect);
};
class Vector {
private:
double* vect;
int len;
public:
Vector(int N = 1); // Конструктор
Vector(const Vector& v); // Конструктор копирования
~Vector();
// Операторы
Vector operator+(const Vector& v);
Vector operator-(const Vector& v);
Vector& operator+=(const Vector& v);
Vector& operator-=(const Vector& v);
Vector operator*(double a);
Vector& operator=(const Vector& v);
double& operator()(int i);
const double& operator()(int i) const;
double Norm() const; // Вычисление нормы вектора
friend Vector operator*(Matrix& matr, Vector& vect);
friend std::ostream& operator<<(std::ostream& os, const Vector& vect);
friend std::istream& operator>>(std::istream& in, Vector& V);
void Generate(double min, double max);
friend Vector operator*(Matrix& matr, Vector& vect);
};
#endif