?? 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:
////
////
////構造與解析
CMatrix();//缺省值的構造函數
CMatrix(int nRows,int nCols);//指定行列
CMatrix(int nRows,int nCols,double value[]);//指定數據構造函數
CMatrix(int nSize);//方陣構造函數
CMatrix(int nSize,double value[]);//指定數據結構的方陣構造函數
CMatrix(const CMatrix &other);//拷貝構造函數
virtual ~CMatrix();//析構函數
bool Init(int nRows,int nCols);//初始化矩陣
bool MakeUnitMatrix(int nSize);//將方陣初始化為單位陣
//////
/////
/////輸入與顯示
//將字符串轉換為矩陣數據
//將矩陣轉換為字符串
//將矩陣指定行轉換為字符串
//將矩陣指定列轉換為字符串///待補
/////
////
////元素與值操作
//設置指定元素的值
bool SetElement(int nRow, int nCol, double value);
double GetElement(int nRow,int nCol)const;//獲取指定元素的值
void SetData(double value[]);//設置矩陣的值
int GetNumCols() const;//獲取矩陣列數
int GetNumRows() const;//獲取矩陣行數
double *GetData() const;//獲取矩陣的值
int GetRowVector(int nRow,double *pVector)const;//獲取指定的行向量放在數組pVector中,返回元素個數
int GetColVector(int nCol,double *pVector)const;//獲取指定的列向量放在數組pVector中,返回元素個數
///
///
///數學運算符
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;//轉置
CMatrix Invert();//矩陣求逆
CMatrix Eigenv();//矩陣求特征值和特征根,返回矩陣,第一行為特征值,其他行為對應特征向量
CMatrix Eigenv2();//矩陣求特征值和特征根第二種方法,返回矩陣,第一行為特征值,其他行為對應特征向量
protected:
int m_NumRows;//列數
int m_NumCols;//行數
double *m_pData;//數據緩沖區
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_)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -