forked from NeuroSyn-AI-Club/simple-deep-learning
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVectorOps.h
More file actions
66 lines (45 loc) · 2.8 KB
/
Copy pathVectorOps.h
File metadata and controls
66 lines (45 loc) · 2.8 KB
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
57
58
59
60
61
62
63
64
65
66
#ifndef VECTOR_OPS_H
#define VECTOR_OPS_H
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
namespace VectorOps {
// Scalar addition DONE
std::vector<std::vector<double>> add(const std::vector<std::vector<double>>& a, double scalar);
// Element-wise addition DONE
std::vector<std::vector<double>> add(const std::vector<std::vector<double>>& a, const std::vector<std::vector<double>>& b);
// Element-wise subtraction DONE
std::vector<std::vector<double>> subtract(const std::vector<std::vector<double>>& a, const std::vector<std::vector<double>>& b);
// Scalar multiplication DONE
std::vector<std::vector<double>> multiply(const std::vector<std::vector<double>>& a, double scalar);
// Element-wise multiplication DONE
std::vector<std::vector<double>> multiply(const std::vector<std::vector<double>>& a, const std::vector<std::vector<double>>& b);
// Element-wise division DONE
std::vector<std::vector<double>> divide(const std::vector<std::vector<double>>& a, const std::vector<std::vector<double>>& b);
// Element-wise square DONE
std::vector<std::vector<double>> square(const std::vector<std::vector<double>>& a);
// Element-wise sqrt DONE
std::vector<std::vector<double>> sqrt(const std::vector<std::vector<double>>& a);
// Element-wise exponential DONE
std::vector<std::vector<double>> exp(const std::vector<std::vector<double>>& a);
// Element-wise logarithm DONE
std::vector<std::vector<double>> log(const std::vector<std::vector<double>>& a);
// Element-wise sigmoid DONE
std::vector<std::vector<double>> sigmoid(const std::vector<std::vector<double>>& a);
// Element-wise tanh DONE
std::vector<std::vector<double>> tanh(const std::vector<std::vector<double>>& a);
// Scalar max DONE
std::vector<std::vector<double>> max(const std::vector<std::vector<double>>& a, double scalar);
// Element-wise max DONE
std::vector<std::vector<double>> max(const std::vector<std::vector<double>>& a, const std::vector<std::vector<double>>& b);
// Mean along axis=1 DONE
std::vector<double> mean_axis1(const std::vector<std::vector<double>>& a);
// Sum of all elements DONE
double sum(const std::vector<std::vector<double>>& a);
// Sum of a vector DONE
double sum(const std::vector<double>& a);
// Sum along axis=0 with keepdims DONE
std::vector<std::vector<double>> sum_axis0(const std::vector<std::vector<double>>& a);
}
#endif // VECTOR_OPS_H