-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vectors.h
48 lines (42 loc) · 1.53 KB
/
Vectors.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
#ifndef VECTORS_H
#define VECTORS_H
#include <math.h>
#include <iostream>
class Vector
{
private:
int size;
double* elements;
public:
Vector(int dimension); // Ñîçäà¸òñÿ íóëåâîé âåêòîð çàäàííîé äëèíû
Vector(const Vector& vector); // Êîïèðîâàíèå
int getSize() const // Ðàçìåð âåêòîðà
{
return size;
};
double* getElements() const // Ïîëó÷åíèå ýëåìåíòîâ âåêòîðà
{
return elements;
};
void addElement(int position, double element); // Äîáàâëÿåì ñêàëÿð ê ýëåìåíòó ñ íóæíîé ïîçèöèåé
double findNorm() const; // Íîðìà L_{2}
Vector& operator =(const double* vector); // Åù¸ îäèí ïåðàòîð ïðèñâàèâàíèÿ
Vector& operator =(const Vector& vector); // Îïåðàòîð ïðèñâàèâàíèÿ
Vector operator *(const double& number) const; // Îïåðàòîð óìíîæåíèÿ íà ñêàëÿð
Vector operator /(const double& number) const; // Îïåðàòîð äåëåíèÿ íà ñêàëÿð
double operator *(const Vector& vector) const; // Îïåðàòîð óìíîæåíèÿ íà âåêòîð
Vector& operator +=(const Vector& vector); // Îïåðàòîð ñëîæåíèÿ âåêòîðîâ
Vector& operator -=(const Vector& vector); // Îïåðàòîð âû÷èòàíèÿ âåêòîðîâ
Vector operator +(const Vector& vector) const; // Åù¸ îäèí îïåðàòîð ñëîæåíèÿ âåêòîðîâ
Vector operator -(const Vector& vector) const; // Åù¸ îäèí îïåðàòîð âû÷èòàíèÿÿ âåêòîðîâ
double& operator [](int index) const // Îïåðàòîð âçÿòèÿ èíäåêñà
{
return elements[index];
};
friend std::ostream& operator<<(std::ostream&, const Vector&); // Ôóíêöèÿ âûâîäà âåêòîðà
~Vector() // Äåñòðóêòîð
{
delete[] elements;
};
};
#endif