forked from pgomoluch/simple-nn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix.h
34 lines (28 loc) · 1.01 KB
/
matrix.h
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
#ifndef MATRIX_H
#define MATRIX_H
#include <initializer_list>
#include <ostream>
class Matrix
{
public:
Matrix(unsigned _n_rows, unsigned _n_columns);
Matrix(unsigned _n_rows, unsigned _n_columns, const double *_data);
Matrix(unsigned _n_rows, unsigned _n_columns, const std::initializer_list<double> &list);
Matrix(const Matrix &other);
~Matrix();
void assign(const double *source);
void apply(double (*f)(double));
void multiply(const double s);
double at(unsigned i, unsigned j);
Matrix T() const; // transpose
void T(Matrix &result) const;
Matrix &operator=(const Matrix &other);
static void multiply(const Matrix &left, const Matrix &right, Matrix &result);
static void point_multiply(const Matrix &left, const Matrix &right, Matrix &result);
static void add(const Matrix &left, const Matrix &right, Matrix &result);
friend std::ostream& operator<<(std::ostream& out, const Matrix &m);
private:
unsigned n_rows, n_columns;
double *data;
};
#endif