-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSDBP.cpp
More file actions
33 lines (22 loc) · 649 Bytes
/
Copy pathSDBP.cpp
File metadata and controls
33 lines (22 loc) · 649 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
struct Matrix {
int *mat, n, m;
Matrix(int n, int m = 1) : n(n), m(m) {
mat = malloc(n * m * sizeof(*mat));
}
int* operator[](int x) { return mat[x]; };
Matrix mul(Matrix a, Matrix b) {
if(a.m != b.n) exit(-1);
Matrix ret(a.n, b.m);
for(int i = 0; i < a.n; i++)
for(int j = 0; j < b.m; j++)
for(int k = 0; k < a.m; k++)
ret[i][j] += a[i][k] * b[k][j];
return ret;
}
Matrix operator*(Matrix b) { return mul(*this, b); };
Matrix operator+(Matrix b) { return add(*this, b); };
void erase() {
free(mat);
}
} ;
void SDBP(Matrix* in, Matrix* out, long double learning_rate,