?? matrix.h
字號:
/* * * * * * * * * * * * * * * * * * * * *
* FileName: Matrix.h
* Description: Matrix Class
*
* Version: 1.0
* Author: wxs
* Finish Time: 2001年7月2日
* * * * * * * * * * * * * * * * * * * * * */
#ifndef _MATRIX_H_
#define _MATRIX_H_
class CMatrix : public CObject
{
public:
//構造函數
CMatrix();
CMatrix(int nRow, int nCol);
CMatrix(int nRow, int nCol, double* pAry);
CMatrix(CMatrix & src);//拷貝構造函數
//析構函數
virtual ~CMatrix();
void Serialize(CArchive& ar);//文件流操作
void Draw(CDC *pDC, CPoint pos);//畫矩陣
//運算符重載
double* & operator [] (int nRow);
CMatrix & operator = (CMatrix & mx);
CMatrix & operator += (CMatrix & mx);
CMatrix & operator -= (CMatrix & mx);
CMatrix & operator *= (CMatrix & mx);
//矩陣運算
void Empty(void);
BOOL IsEmpty(void);
void SetMatrix(int nRow, int nCol);
void SetMatrix(int nRow, int nCol, double* pAry);
void SetMatrix(double* pAry);
int Pivot(int nRow);//private partial pivoting method
void SwapRow(int nRow1, int nRow2);//行交換
void SwapCol(int nCol1, int nCol2);//列交換
void ToUnit(void);//單位矩陣
void ToNull(void);//零矩陣
double Max(void);//矩陣大極值
double Min(void);//矩陣極小值
double Det(void);//行列式
int SolveLinearQquations(double ary []);//列主元消元法求線性方程組 Solution system of linear eqations
int Row() const { return m_nRow; }
int Col() const { return m_nCol; }
BOOL LoadMatrix();
BOOL LoadMatrix(CString strPath);
BOOL SaveMatrix(CString strPath, BOOL bASCII = TRUE);
BOOL SaveMatrix();
//友元
friend CMatrix operator + (CMatrix & mx, double k);
friend CMatrix operator + (double k, CMatrix & mx);
friend CMatrix operator + (CMatrix & mx1, CMatrix & mx2);
//friend CMatrix operator - (CMatrix & mx, double k);
//friend CMatrix operator - (double k, CMatrix & mx);
//friend CMatrix operator - (CMatrix & mx1, CMatrix & mx2);
friend CMatrix operator * (CMatrix & mx, double k);
friend CMatrix operator * (double k, CMatrix & mx);
friend CMatrix operator * (CMatrix & mx1, CMatrix & mx2);
friend CMatrix operator ^ (CMatrix & mx, int pow);//矩陣次冪
friend BOOL operator != (CMatrix & mx1, CMatrix & mx2);
friend BOOL operator == (CMatrix & mx1, CMatrix & mx2);
friend CMatrix operator ~ (CMatrix & mx);//矩陣轉置
friend CMatrix operator ! (CMatrix & mx);//逆矩陣
#ifdef _DEBUG
void Output() const;
#endif
private:
int m_nRow;//行數
int m_nCol;//列數
double* *m_pData;
};
#endif //#ifndef _MATRIX_H_
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -