-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix_wiz.h
executable file
·97 lines (87 loc) · 2.39 KB
/
matrix_wiz.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
ver.03.03
file matrix_wiz.h
*/
#pragma once
#include <cstdarg>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <math.h>
#include "matrix.h"
class MATRIX_WIZ:virtual public MATRIX{
public:
MATRIX_WIZ();
MATRIX_WIZ(unsigned row,unsigned col);
MATRIX_WIZ(MATRIX_WIZ& src);
MATRIX_WIZ(MATRIX_WIZ* src);
virtual ~MATRIX_WIZ();
void Renew(unsigned row,unsigned col);
//utilities
void ZeroOut(void);
bool IsSqr(void);
void Input(unsigned num,...);
void Divide(MATRIX_WIZ& smaller,unsigned top,unsigned bottom,unsigned left, unsigned right);
void Identity(void);
void Print(std::string filename);
unsigned GetRow(void)const{return row;}
unsigned GetCol(void)const{return col;}
//calculation
void Eigen(MATRIX_WIZ& eigenvectors,MATRIX_WIZ& eigenvalues);
double Trace(void);
double Norm2(void);
void Inv(MATRIX_WIZ& dest);
MATRIX_WIZ& Transpose(void);
//operators
MATRIX& operator=(MATRIX_WIZ& right);
MATRIX& operator+=(MATRIX& right);
MATRIX& operator-=(MATRIX& right);
MATRIX& operator*=(double coef);
MATRIX& operator*=(MATRIX& right);
friend std::ostream& operator<<(std::ostream& os,MATRIX_WIZ& matrix);
friend MATRIX_WIZ& operator+(MATRIX_WIZ& left,MATRIX_WIZ& right);
friend MATRIX_WIZ& operator-(MATRIX_WIZ& left,MATRIX_WIZ& right);
friend MATRIX_WIZ& operator*(MATRIX_WIZ& mat1,MATRIX_WIZ& mat2);
double& operator()(unsigned i,unsigned j);
double operator()(unsigned i,unsigned j)const;
double& operator[](unsigned i){return data[i];};
double Atm(unsigned rown,unsigned coln);
double* GetData(void){return &data[0];};
double* GetData(void)const{return &data[0];};
#ifndef _DEBUG
protected:
#endif
unsigned index(unsigned _row,unsigned _col);
void gauss(unsigned _row,double coef);
void gauss(unsigned row1,unsigned row2,double coef);
void gauss(unsigned row1,unsigned row2);
unsigned row;
unsigned col;
unsigned size;
double* data;
double* data_cnt;
bool input_flag;
const static unsigned width=8;
static const double m_eps;
};
class MATRIX33_WIZ:public MATRIX_WIZ,public MATRIX33{
public:
MATRIX33_WIZ();
MATRIX33_WIZ(MATRIX33&);
MATRIX33_WIZ(MATRIX33*);
~MATRIX33_WIZ(){
if(data)
delete[] data;
data=NULL;
};
void Inv(MATRIX33& dest);
MATRIX& operator=(MATRIX33_WIZ& right);
MATRIX& operator=(MATRIX_WIZ& right);
MATRIX33_WIZ& Transpose(void);
void dev(void);
/*obsolete
double det(void)const;
double I1(void)const;
double I2(void)const;
*/
};