This repository was archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray.h
More file actions
163 lines (113 loc) · 4.11 KB
/
array.h
File metadata and controls
163 lines (113 loc) · 4.11 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#pragma once
/* Anticipating declaration */
class TMatrix;
/* Declaration of the class vectors */
class TVector
{
/* Access modifier */
protected:
/* Dimension of the vector */
int n;
/* Data of the vector */
double *data;
/* Access modifier */
public:
/* Constructor standart */
TVector();
/* Constructor of set */
TVector(int n);
/* Constructor copy */
TVector(const TVector& rvalue);
/* Assignment operator */
TVector& operator = (const TVector& rvalue);
/* Destructor */
virtual ~TVector();
/* A method of obtaining the number of elements */
inline int size() const { return n; }
/* A method of obtaining the last item */
inline int high() const { return n - 1; }
/* Method used to set the number of elements */
void resize(int n);
/* Access operator elements of vector */
inline double& operator[](int i) { return data[i]; }
/* Operator const access elements of a vector */
inline const double& operator[](int i) const { return data[i]; }
/* Operator - unary minus */
TVector operator - () const;
/* Subtraction operator vectors */
TVector operator - (const TVector& arg) const;
/* Addition operator vectors */
TVector operator + (const TVector& arg) const;
/* The module (length) vector */
double length() const;
/* Operator of vector multiplication of vectors */
TVector operator ^ (const TVector& arg) const;
/* Operator of multiplication of a vector by a number */
TVector operator * (double arg) const;
/* Normalization of the vector */
TVector& norm();
/* Operator for scalar multiplication of vectors */
double operator * (const TVector& arg) const;
/* Operator of multiplication of a vector by a matrix */
TVector operator * (const TMatrix& arg) const;
/* Friendly function - the operator multiplying the number of vector */
friend TVector operator * (double lvalue, const TVector& rvalue);
};
/* Declaration of the class matrix */
class TMatrix
{
/* Access modifier */
protected:
/* Dimension of the matrix */
int n, m;
/* Data of the matrix */
double **data;
/* Access modifier */
public:
/* Constructor standart */
TMatrix();
/* Constructor of set */
TMatrix(int n, int m);
/* Constructor copy */
TMatrix(const TMatrix& rvalue);
/* Assignment operator */
TMatrix& operator = (const TMatrix& rvalue);
/* Destructor */
virtual ~TMatrix();
/* A method of obtaining the number row of the vector */
inline int rowCount() const { return n; }
/* A method of obtaining the number column of the vector */
inline int colCount() const { return m; }
/* Function to obtain the index of the last row */
inline int rowHigh() const { return n-1; }
/* Function to obtain the index of the last column */
inline int colHigh() const { return m-1; }
/* Method used to set the number of elements */
void resize(int n, int m);
/* Access operator elements of matrix */
inline double& operator()(int i, int j) { return data[i][j]; }
/* Operator const access elements of a matrix */
inline const double& operator()(int i, int j) const { return data[i][j]; }
/* Operator - unary minus */
TMatrix operator - () const;
/* Subtraction operator matrix */
TMatrix operator - (const TMatrix& arg) const;
/* Addition operator matrix */
TMatrix operator + (const TMatrix& arg) const;
/* Operator to multiply a matrix by a number */
TMatrix operator * (double arg) const;
/* Matrix multiplication operator */
TMatrix operator * (const TMatrix& arg) const;
/* Multiplication operator for the matrix-vector */
TVector operator * (const TVector& arg) const;
/* Transpose of the matrix */
TMatrix t() const;
/* Friendly feature - the operator multiplying the number of the matrix */
friend TMatrix operator * (double lvalue, const TMatrix& rvalue);
/* Function of the formation of the identity matrix */
static TMatrix E(int n);
/* Inversion operator matrix (Gauss method) */
TMatrix operator ! () const throw(int);
/* Function swap rows */
TMatrix& swapRows(int i, int j);
};