forked from hsuhsuanhao/MARS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMATRIX.h
43 lines (40 loc) · 1.52 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
35
36
37
38
39
40
41
42
43
#ifndef _My_Matrix_H
#define _My_Matrix_H
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
class Matrix
{
public:
Matrix();
Matrix( int rows, int cols ); // size rows x cols
~Matrix();
int row(); //number of rows
int col(); //number of columns
double dtm(); //determinant
int display(ostream& outs=cout);
int assign(int,int,double val); //assign value to matrix item
int resize( int newRows, int newCols ); // resizes matrix to newRows x newCols
vector<double>& operator[] (int row); //assign value to matrix item
Matrix operator+ (Matrix m2); //matrix addition
Matrix operator- (Matrix m2); //matrix subtraction
Matrix operator* (Matrix m2); //matrix multiplication
Matrix operator* (double a);
Matrix operator^ (int); //inverse of self-multiplication
friend ostream& operator<< (ostream& outs, Matrix m2); //matrix output
Matrix inverse();
void rotate(Matrix &, Matrix &,double);
int nRows; // # of rows (capacity)
int nCols; // # of cols (capacity)
vector< vector <double> > Mtrx; // the matrix of items
int check_range (int row); //range protection
int rank; //rank of matrix
double det; //determinant
int sol(Matrix &, Matrix &,Matrix &);
int func(Matrix &, Matrix &, Matrix &,Matrix &);
int dfun(Matrix &, Matrix &, Matrix &,Matrix &);
int ludcmp(Matrix &a,int *indx,double &d); //LU decomposition
int lubksb(Matrix &a,int *indx,double *b); //LU back substitution
}; // end Matrix class specification
#endif