-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix.h
More file actions
45 lines (39 loc) · 1.42 KB
/
Matrix.h
File metadata and controls
45 lines (39 loc) · 1.42 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
#pragma once
#include <vector>
#include <iomanip>
using namespace std;
class Matrix {
int m;
int n;
vector<double> vals;
public:
Matrix(int m , int n);
Matrix(int m , int n, vector<double> vals);
Matrix()=default;
friend Matrix dot(const Matrix &M1, const Matrix &M2);
friend Matrix operator+(const Matrix &M1, const Matrix &M2);
friend Matrix operator/(const Matrix &M, float num);
friend Matrix ReLU(const Matrix &M);
friend Matrix softmax(const Matrix &M);
friend Matrix elementwise(const Matrix &M1, const Matrix &M2);
friend Matrix deriv_ReLU(const Matrix &M);
friend Matrix one_hot(int label);
friend Matrix operator-(const Matrix& M1, const Matrix& M2);
friend Matrix operator*(float num, const Matrix &M);
Matrix(const Matrix& M1);
Matrix transpose() const;
void print(int precision = 8) const;
void random();
void zeroes();
int argmax();
};
Matrix dot(const Matrix &M1, const Matrix &M2);
Matrix operator+(const Matrix &M1, const Matrix &M2);
Matrix ReLU(const Matrix &M);
Matrix softmax(const Matrix &M);
Matrix operator/(const Matrix &M, float num);
Matrix elementwise(const Matrix &M1, const Matrix &M2);
Matrix deriv_ReLU(const Matrix &M);
Matrix one_hot(int label);
Matrix operator-(const Matrix& M1, const Matrix& M2);
Matrix operator*(float num, const Matrix &M);