-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix_algebraic.h
executable file
·74 lines (67 loc) · 1.73 KB
/
matrix_algebraic.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
ver.03.03
file matrix_algebraic.h
*/
#pragma once
#include <algorithm>
#include <iostream>
#include "matrix.h"
class Matrix_body{
typedef std::ostream ostream;
friend class Matrix;
public:
virtual ~Matrix_body();
private:
Matrix_body(unsigned row,unsigned col);
double& operator()(unsigned i,unsigned j);
double operator()(unsigned i,unsigned j)const;
void print(ostream& out)const;
short referenceCount;
const unsigned row;
const unsigned col;
double* val;
};
class Matrix:virtual public MATRIX{
typedef std::ostream ostream;
public:
Matrix(void);
Matrix(const Matrix& src);
Matrix(unsigned row,unsigned col);
virtual ~Matrix();
unsigned GetRow(void)const;
unsigned GetCol(void)const;
Matrix& operator=(const Matrix& right);
double& operator()(unsigned i,unsigned j);
double operator()(unsigned i,unsigned j)const;
double& operator[](unsigned i);
Matrix operator-(void)const;
Matrix operator+(Matrix right)const;
Matrix operator-(Matrix right)const;
Matrix operator*(Matrix right)const;
Matrix operator*(double coef)const;
Matrix& operator*=(double coef);
friend Matrix operator*(double coef,Matrix right);
Matrix transpose(void)const;
void copy(const Matrix& src);
void zero_out(void);
void print(ostream& out)const;
protected:
Matrix_body* rep;
};
class Matrix33:public Matrix,public MATRIX33{
public:
Matrix33(void):Matrix(3,3){};
Matrix33(const Matrix& src):Matrix(src){};
Matrix33(const MATRIX33* src):Matrix(3,3){
for(unsigned i=0;i<3;i++)
for(unsigned j=0;j<3;j++)
(*this)(i,j)=(*src)(i,j);
};
Matrix& operator=(const Matrix& right){return Matrix::operator=(right);};
double I1(void)const;
double I2(void)const;
double I3(void)const;
void identity(void);
void dev(void);
Matrix33 inv(void)const;
};