-
Notifications
You must be signed in to change notification settings - Fork 0
/
VEC.h
39 lines (35 loc) · 1.19 KB
/
VEC.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
//////VEC.h
//////Author: YUNG-SHAN SU
//////Date: 3/19
#ifndef VEC_H
#define VEC_H
class VEC {
private:
int dim; // vector length
double *val; // array to store vector
public:
VEC(int n); // uninit constructor, val set to 0
VEC(const VEC &v1); // copy constructor
VEC(int n,double *v); // init constructor
~VEC(); // destructor
int len(); // dimension of the vector
VEC &operator-(); // unary operator, negative value
VEC &operator=(const VEC &v1); // assignment
VEC &operator=(const double &a); // assignment
VEC &operator+=(const VEC v1); // V += v1;
VEC &operator-=(const VEC v1); // V -= v1;
VEC &operator*=(double a); // V *= dbl;
VEC &operator/=(double a); // V /= dbl;
VEC operator+(const VEC &v1); // V + v1
VEC operator-(const VEC &v1); // V - v1
double operator*(VEC &v1); // inner product
VEC operator*(double a); // V * dbl
VEC operator/(double a); // V / dbl
double &operator[](int n); // indexing
void print();
friend VEC operator*(double a,const VEC v1); // dbl x V
friend VEC *newVEC(int n); // create dynamic VEC
};
VEC operator*(double a,const VEC v1);
VEC *newVEC(int n); // create dynamic VEC
#endif