-
Notifications
You must be signed in to change notification settings - Fork 1
/
var.cpp
56 lines (44 loc) · 1.12 KB
/
var.cpp
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
#include "autograd.h"
std::vector <std::vector <double>> nn::var::dereference_reference_vec (const std::vector <nn::var*> &x) {
std::vector <std::vector <double>> result;
for (auto &i : x) {
assert (i != nullptr);
result.push_back (i -> v);
}
return result;
}
nn::var::var (const std::vector <double> &x) {
v = x;
operation = nullptr;
}
nn::var::iterator::iterator () {
reference = nullptr;
}
nn::var::iterator::iterator (nn::var *ptr) {
reference = ptr;
}
nn::var::iterator nn::var::iterator::operator = (nn::var *ptr) {
reference = ptr;
return *this;
}
bool nn::var::iterator::operator == (nn::var *ptr) {
return ptr == reference;
}
bool nn::var::iterator::operator == (const nn::var::iterator &i) {
return reference == i.reference;
}
bool nn::var::iterator::operator != (nn::var *ptr) {
return ptr != reference;
}
bool nn::var::iterator::operator != (const nn::var::iterator &i) {
return reference != i.reference;
}
std::vector <double> nn::var::get_value () {
return v;
}
nn::var& nn::var::iterator::operator * () {
return *reference;
}
nn::var* nn::var::iterator::operator -> () const {
return reference;
}