-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtensor.h
More file actions
52 lines (36 loc) · 904 Bytes
/
tensor.h
File metadata and controls
52 lines (36 loc) · 904 Bytes
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
#ifndef tensor_h
#define tensor_h
#include <vector>
#include "base.h"
class SpaCSR;
class Vec
{
public:
// constructor
Vec():len(0){}
Vec(INT l):val(l),len(l){}
Vec(INT l, DOUBLE v):val(l,v),len(l){}
// copy constructor
Vec(const Vec & vec):val(vec.val),len(vec.len){}
// move copy constructor
Vec(Vec && vec):len(vec.len) {val.swap(vec.val);}
// copy assignment operator
Vec & operator=(const Vec & vec);
// move assignment operator
Vec & operator=(Vec && vec);
// destructor
virtual ~Vec(){}
// get the length of the vector
INT GetLen() const;
// print partial data for verification
virtual void PrintPartialTensor(INT num) const;
// overload the operator * for spmv
friend Vec operator*(const SpaCSR & csr, const Vec & vec);
// overload the operator []
DOUBLE & operator[](INT i);
// val vector : len
std::vector<DOUBLE> val;
protected:
INT len;
};
#endif