-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVector.h
56 lines (42 loc) · 1.69 KB
/
Vector.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
#pragma once
#include <iostream>
#include "CSRMatrix.h"
#include <cmath>
class CSRMatrix;
class Vector {
public:
Vector(int size, double defaultValue);
explicit Vector(int size);
Vector();
Vector(const Vector& other);
~Vector();
int GetDimentionCount() const;
double Magnitude() const;
Vector& operator=(const Vector& other);
Vector& operator+=(const Vector& other);
Vector& operator-=(const Vector& other);
Vector operator-() const;
const Vector& operator+() const;
friend Vector operator+(const Vector& first, const Vector& second);
friend Vector operator-(const Vector& first, const Vector& second);
friend Vector operator*(const Vector& vec, double lambda);
friend Vector operator*(double lambda, const Vector& vec);
friend double operator*(const Vector& first, const Vector& second);
friend bool operator==(const Vector& first, const Vector& second);
double& operator[](int index);
const double& operator[](int index) const;
friend std::ostream& operator<<(std::ostream& out, const Vector& vec);
friend std::istream& operator>>(std::istream& out, Vector& vec);
explicit operator double*();
private:
int size;
double* coordinates;
};
Vector operator+(const Vector& first, const Vector& second);
Vector operator-(const Vector& first, const Vector& second);
Vector operator*(const Vector& vec, double lambda);
Vector operator*(double lambda, const Vector& vec);
double operator*(const Vector& first, const Vector& second);
bool operator==(const Vector& first, const Vector& second);
std::ostream& operator<<(std::ostream& out, const Vector& vec);
std::istream& operator>>(std::istream& out, const Vector& vec);