-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmatrix.h
49 lines (36 loc) · 900 Bytes
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <iostream>
#include <vector>
class Matrix
{
public:
double* body;
int nrows;
int ncols;
void set_value(int row, int col, double value);
double get_value(int row, int col) const;
void print_matrix() const;
void fill(double value);
void swap_rows(int row1, int row2);
void identity();
Matrix transpose();
Matrix LU();
Matrix invert_pivot();
Matrix(int nrows=1, int ncols=1)
{
Matrix::nrows = nrows;
Matrix::ncols = ncols;
int size = nrows * ncols;
body = new double[size];
fill(0);
}
//Destructor
~Matrix()
{ delete[] body; }
};
Matrix addition(Matrix& mat1, Matrix& mat2);
Matrix matrix_multiplication(Matrix& mat1, Matrix& mat2);
Matrix scalar_multiplication(Matrix& mat, double scalar);
int max_in_column(Matrix& mat, int column, int start);
Matrix LU(Matrix& mat);
Matrix forward_substitution(Matrix& lower_trianglular, Matrix& b);