?? matrix.h
字號:
// Matrix.h: interface for the CMatrix class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MATRIX_H__252F1FEF_F0A7_4E2A_9DFC_DE56FB93288C__INCLUDED_)
#define AFX_MATRIX_H__252F1FEF_F0A7_4E2A_9DFC_DE56FB93288C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMatrix
{
public:
////
////
////構(gòu)造與解析
CMatrix();//缺省值的構(gòu)造函數(shù)
CMatrix(int nRows,int nCols);//指定行列
CMatrix(int nRows,int nCols,double value[]);//指定數(shù)據(jù)構(gòu)造函數(shù)
CMatrix(int nSize);//方陣構(gòu)造函數(shù)
CMatrix(int nSize,double value[]);//指定數(shù)據(jù)結(jié)構(gòu)的方陣構(gòu)造函數(shù)
CMatrix(const CMatrix &other);//拷貝構(gòu)造函數(shù)
virtual ~CMatrix();//析構(gòu)函數(shù)
bool Init(int nRows,int nCols);//初始化矩陣
bool MakeUnitMatrix(int nSize);//將方陣初始化為單位陣
//////
/////
/////輸入與顯示
//將字符串轉(zhuǎn)換為矩陣數(shù)據(jù)
//將矩陣轉(zhuǎn)換為字符串
//將矩陣指定行轉(zhuǎn)換為字符串
//將矩陣指定列轉(zhuǎn)換為字符串///待補
/////
////
////元素與值操作
//設(shè)置指定元素的值
bool SetElement(int nRow, int nCol, double value);
double GetElement(int nRow,int nCol)const;//獲取指定元素的值
void SetData(double value[]);//設(shè)置矩陣的值
int GetNumCols() const;//獲取矩陣列數(shù)
int GetNumRows() const;//獲取矩陣行數(shù)
double *GetData() const;//獲取矩陣的值
int GetRowVector(int nRow,double *pVector)const;//獲取指定的行向量放在數(shù)組pVector中,返回元素個數(shù)
int GetColVector(int nCol,double *pVector)const;//獲取指定的列向量放在數(shù)組pVector中,返回元素個數(shù)
///
///
///數(shù)學(xué)運算符
CMatrix& operator=(const CMatrix &other);
bool operator==(const CMatrix &other)const;
bool operator!=(const CMatrix &other)const;
CMatrix operator+(const CMatrix &other)const;
CMatrix operator-(const CMatrix &other)const;
CMatrix operator*(double value)const;
CMatrix operator*(const CMatrix &other)const;
CMatrix Transpose()const;//轉(zhuǎn)置
CMatrix Invert();//矩陣求逆
CMatrix Eigenv();//矩陣求特征值和特征根,返回矩陣,第一行為特征值,其他行為對應(yīng)特征向量
CMatrix Eigenv2();//矩陣求特征值和特征根第二種方法,返回矩陣,第一行為特征值,其他行為對應(yīng)特征向量
protected:
int m_NumRows;//列數(shù)
int m_NumCols;//行數(shù)
double *m_pData;//數(shù)據(jù)緩沖區(qū)
private:
bool InvertGaussJordan();
bool JacobiEigenv(double EigenValue[], CMatrix &EigenVector,int nMaxIt=60,double eps=0.000001);
bool JacobiEigenv2(double EigenValue[], CMatrix &EigenVector,int nMaxIt=60,double eps=0.000001);
void Swape(void);//對矩陣按第一行由大到小排序
};
#endif // !defined(AFX_MATRIX_H__252F1FEF_F0A7_4E2A_9DFC_DE56FB93288C__INCLUDED_)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -