?? matrix.h
字號(hào):
// Matrix.h: interface for the CMatrix class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_MATRIX_H__27C7BED9_314A_4D5E_BAD3_801093E96309__INCLUDED_)
#define AFX_MATRIX_H__27C7BED9_314A_4D5E_BAD3_801093E96309__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMatrix
{
private:
int row; // 矩陣的行數(shù)
int col; // 矩陣的列數(shù)
int n; // 矩陣元素個(gè)數(shù)
double* mtx; // 動(dòng)態(tài)分配用來(lái)存放數(shù)組的空間
public:
CMatrix(int row=1, int col=1); // 帶默認(rèn)參數(shù)的構(gòu)造函數(shù)
CMatrix(int row, int col, double mtx[]); // 用數(shù)組創(chuàng)建一個(gè)矩陣
CMatrix(const CMatrix &obj); // copy構(gòu)造函數(shù)
~CMatrix() { delete[] this->mtx; }
//void print()const; // 格式化輸出矩陣
int getRow()const { return this->row; } // 訪問(wèn)矩陣行數(shù)
int getCol()const { return this->col; } // 訪問(wèn)矩陣列數(shù)
int getN()const { return this->n; } // 訪問(wèn)矩陣元素個(gè)數(shù)
double* getMtx()const { return this->mtx; } // 獲取該矩陣的數(shù)組
// 用下標(biāo)訪問(wèn)矩陣元素
double get(const int i, const int j);//const;
// 用下標(biāo)修改矩陣元素值
void set(const int i, const int j, const double e);
// 重載了一些常用操作符,包括 +,-,x,=,負(fù)號(hào),正號(hào),
// A = B
CMatrix &operator= (const CMatrix &obj);
// +A
CMatrix operator+ ()const { return *this; }
// -A
CMatrix operator- ()const;
// A + B
friend CMatrix operator+ (const CMatrix &A, const CMatrix &B);
// A - B
friend CMatrix operator- (const CMatrix &A, const CMatrix &B);
// A * B 兩矩陣相乘
friend CMatrix operator* (CMatrix &A, CMatrix &B);
// a * B 實(shí)數(shù)與矩陣相乘
friend CMatrix operator* (double &a, CMatrix &B);
// A 的轉(zhuǎn)置
//friend CMatrix trv(const CMatrix &A);
// A 的行列式值,采用列主元消去法
// 求行列式須將矩陣化為三角陣,此處為了防止修改原矩陣,采用傳值調(diào)用
//friend double det(CMatrix A);
// A 的逆矩陣,采用高斯-若當(dāng)列主元消去法
//friend CMatrix inv(CMatrix A);
/*
public:
//CMatrix(); // 默認(rèn)的構(gòu)造函數(shù)
virtual ~CMatrix();
*/
};
#endif // !defined(AFX_MATRIX_H__27C7BED9_314A_4D5E_BAD3_801093E96309__INCLUDED_)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -