cmatrix,C++程序报错unresolved external symbol
cmatrix,C++程序报错unresolved external symbol详细介绍
本文目录一览: 拖动cmatrix-1.2时出现不是虚拟机配置文件怎么弄
把那个虚拟硬盘文件单独摘出来。然后将你原来那个无法启动的虚拟机直接删除掉,再重新建立一个新的虚拟机,新的虚拟机配置好各项硬件参数,但新的虚拟机使用的虚拟硬盘文件使用原来的那一个。
CMatrix(T) mata,matb,matc; 是什么意思
用T类型调用默认的构造函数构造三个对象
CMatrix
mata,matb,matc;这样子之后,mata...等三个对象都是CMatrix
类型
nRow=100,nCol=100; Mat=new T*[100]; //含100个T*指针的数组 for(int i=0;i<100;i++) { Mat[i]=new T[100]; }构造函数执行上面的代码,T类型可以是int double等等,这样mata...等三个对象的Mat成员就包含了相应类型的数组
c++课程设计中出现无法解析的外部符号?
无法解析的外部符号一般指对应函数找不到函数体
这里应该是operator*没有定义
CMatrix
operator * (CMatrix
&matl,CMatrix
&mat2)
的函数体你放哪儿了?
顺便说一句,你需要关注参数的正确性,作为乘法,是没有必要改变mat1, mat2的,正确的函数原型应该改为
CMatrix
operator * (const CMatrix
&mat1,const CMatrix
&mat2)
上面代码完全乱了格式,应该把代码贴图出来,而不是文字
C++程序报错unresolved external symbol
1、问题在于为了构造一个CMatrix
类型的对象,需要调用CMatrix
::CMatrix
(void)这个构造函数,但是你的代码里没有这样的函数。注意是缺少函数,而不是声明。如果你不需要构造函数,可以尝试删除相关语句。
2、后面的不是乱码,是参数和返回值的类型编码。由于你并非专业人士,不给你过多解释了。
c++写一个矩阵类
#include
#include
using namespace std;
class CMatrix
{
private:
int x;
int y;
float * fValue;
public:
CMatrix();
CMatrix(int x,int y,float value);
CMatrix(const CMatrix & mx);
float sum() const;
friend CMatrix & operator+(const CMatrix &a,const CMatrix &b);
friend bool operator==(const CMatrix &a,const CMatrix &b);
friend ostream & operator<<(ostream & op,const CMatrix & cm);
friend istream & operator>>(istream & op,const CMatrix & cm);
};
CMatrix::CMatrix()
{
x=2;
y=2;
fValue=new float[x*y];
for(int i=0;i
<x*y;i++)
fValue[i]=0;
}
CMatrix::CMatrix(int x,int y,float value)
{
this->x=x;
this->y=y;
fValue=new float[x*y];
for(int i=0;i
<x*y;i++)
fValue[i]=value;
}
CMatrix::CMatrix(const CMatrix &cm)
{
if(NULL==cm.fValue || this->fValue==cm.fValue)
return;
this->x=cm.x;
this->y=cm.y;
this->fValue=new float[cm.x*cm.y];
for(int i=0;i
<x*y;i++)
this->fValue[i]=cm.fValue[i];
}
CMatrix & operator+(const CMatrix &a,const CMatrix &b)
{
assert(a.x==b.x && a.y==b.y);
CMatrix * cm=new CMatrix(a.x,a.y,0);
cm->x=a.x;
cm->y=a.y;
for(int i=0;i
x*cm->y;i++)
cm->fValue[i]=a.fValue[i]+b.fValue[i];
return *cm;
}
bool operator==(const CMatrix &a,const CMatrix &b)
{
assert(a.x==b.x && a.y==b.y);
for(int i=0;i
<a.x*a.y;i++)
if(a.fValue[i]!=b.fValue[i])
return false;
return true;
}
float CMatrix::sum() const
{
float temp=0;
for(int i=0;i
x*this->y;i++)
temp+=this->fValue[i];
return temp;
}
ostream & operator<<(ostream & op,const CMatrix & cm)
{
for(int i=0;i
<cm.x*cm.y;i++)
{
if(0==i%cm.y)op<
<endl;
op<
<cm.fvalue[i]<<" ";
}
return op;
}
istream & operator>>(istream & op,const CMatrix & cm)
{
for(int i=0;i
<cm.x*cm.y;i++)
{
op>>cm.fValue[i];
}
return op;
}
int main()
{
CMatrix cm(8,8,3);
cin>>cm;
cout<
<cm<<endl;
CMatrix ct(cm);
cout<
<ct.sum()<<endl;
cout<<(cm==ct)<
<endl;
cout<
<cm<<endl;
cout<
<ct+cm<<endl;
system("pause");
}
</ct+cm<<endl;
</cm<<endl;
</endl;
</ct.sum()<<endl;
</cm<<endl;
</cm.x*cm.y;i++)
</cm.fvalue[i]<
</endl;
</cm.x*cm.y;i++)
</a.x*a.y;i++)
</x*y;i++)
</x*y;i++)
</x*y;i++)
C++类,设计完成该矩阵类CMatrix。
我写了一个类,看符合楼主的需要不。 class CMatrix { public: int **num; int width; int height; public: CMatrix(int m, int n):height(m), width(n) { //height = m; //width = n; num = new int*[m]; for( int i = 0; i < m; i++) { num[i] = new int[n]; memset(num[i], 0, n * sizeof(int)); } } CMatrix() { width = 0; height = 0; } ~CMatrix() { for( int i = 0; i < height; i++) { delete(num[i]); } delete(num); } void Assign(int item[]) { int index = 0; for( int i = 0; i < height; i++) { for( int j = 0; j < width; j++) { num[i][j] = item[ i * width + j]; } } } void Display() { for( int i = 0; i < height; i++) { for( int j = 0; j < width; j++) { cout << num[i][j] << "\t"; } cout << endl; } cout << endl; } CMatrix& operator + (const CMatrix& c) { for( int i = 0; i < height; i++) { for( int j = 0; j < width; j++) { num[i][j] += c.num[i][j]; } } return *this; } };
编写矩阵类--封装矩阵的运算(加、减、乘、转置、...)
class CMatrix
{
public:
CMatrix(){m_pData = 0;}
CMatrix(int rows, int cols) : m_iRows(rows), m_iCols(cols)
{
pData = new double[m_iRows * m_iCols];
//Generate data here
}
~CMatrix()
{
if(pData) delete []pData;
}
CMatrix& operator=(CMatrix& other);
double* operator[](int row)
{
return m_pData + row*m_iCols;
}
CMatrix& operator+(CMatrix& mat);
CMatrix& operator-(CMatrix& mat);
CMatrix& operator*(CMatrix& mat);
CMatrix& operator*(double c);
CMatrix& operator/(double c);
CMatrix& trans();//transpose
CMatrix& inv();//inverse
double det();//determinant
private:
int m_iRows, m_iCols;
double *m_pData;
}
matlab这行代码:P=biograph(G,[],'ShowArrows','on','ShowWeights','on');
这个问题其实你只要稍微查一下帮助就明白了。
biograph 是生物信息工具箱(Bioinformatics Toolbox)里的函数,用于创建有向图对象,基本调用格式是:
BGobj = biograph(CMatrix, NodeIDs, 'PropertyName', PropertyValue, ...)其中第一个参数CMatrix是图的连结矩阵,第二个参数NodeIDs是节点的标识名称,后面是成对的属性名/属性值用于指定图的相关选项。
在参数说明部分,有一个专门的注解:
Note You must specify NodeIDs if you want to specify property name/value pairs. Set NodeIDs to [] to use the default values of the row/column numbers.
意思就是说,如果要用到后面的那些属性选项(比如你现在调用的那个语句),就必需指定第二个参数NodeIDs;而如果不知道该怎样指定,那就将其设为[],这种情况下,会使用默认的行(列)序号作为节点名。
C++ 类内进行该类的定义与引用
W_CMatrix operator*(const W_CMatrix& m)返回的是 W_CMatrix,当没有定义缺省的复制函数,这时C++会使用类的值复制,对你这个类定义,结果肯定是错的,加一个缺省的复制函数,就是参数是自己类引用的构造函数就行了。如:
W_CMatrix(W_CMatrix & source)
{
// 在这里要将source的值复制到当前这个实体中
// ......
}
class W_CMatrix
{
public:
double** _A;
int _row,_column;
public:
W_CMatrix(int r,int c) //构造函数
{
_row=r;
_column=c;
_A=new double*[_row];
for(int i=0;i<_row;i++)
{
_A[i]=new double[_column];
}
}
W_CMatrix(const W_CMatrix & source) //拷贝构造函数
{
_row=source._row;
_column=source._column;
_A=new double*[_row];
for(int i=0;i<_row;i++)
{
_A[i]=new double[_column];
}
for(int m=0;m<_row;m++)
{
for(int n=0;n<_column;n++)
{
_A[m][n]=source._A[m][n];
}
}
}
W_CMatrix& operator=(const W_CMatrix & source) //赋值运算符重载
{
_row=source._row;
_column=source._column;
_A=new double*[_row];
for(int i=0;i<_row;i++)
{
_A[i]=new double[_column];
}
for(int m=0;m<_row;m++)
{
for(int n=0;n<_column;n++)
{
_A[m][n]=source._A[m][n];
}
}
return *this;
}
W_CMatrix operator*() //*运算符重载
{
W_CMatrix temp(_row,_column);
return temp;
}
};
c语言编程求任意对称正定矩阵的逆。
#ifndef __MATRIX_DOT_H__
#define __MATRIX_DOT_H__
template
void Swap(T& a, T& b)
{
T temp;
temp = a;
a = b;
b = temp;
}
class CMatrix
{
static double ZERO;//极小值
public:
CMatrix(int row = 3, int col = 3); //
CMatrix(const CMatrix& right); //拷贝构造函数
~CMatrix();
void Show(const char* pre = NULL)const; //输出矩阵
void Free();
int Resize(int row, int col); //重新定义矩阵大小
int GetRow()const{ return m_iRow; } //返回矩阵行数
int GetCol()const{ return m_iCol; } //返回矩阵列数
int RowSwap(int x, int y); //行交换,成功返回1,否则0
int ColSwap(int x, int y); //列交换
static void SetZero(double z); //设定ZERO的值,所有CMatrix实例精度都将改变
const CMatrix Transpose()const; //返回转置矩阵
const CMatrix Adjoint()const; //伴随矩阵
const CMatrix Residue(int row, int col)const;//求对应元素的余子式
const CMatrix Contrary()const;//逆矩阵
const CMatrix Gauss_Jordan(double* pDet = NULL)const;//逆矩阵(高斯-约旦法),pDet为行列式,
//此法精度较低,但效率较高
double Residue_a(int row, int col)const;//求对应元素的代数余子式
double Determinant()const; //返回方阵的行列式
double Det_Recursion()const; //返回方阵的行列式(递归)
int IsZero()const; //判断元素是否全为0(零矩阵)
int IsPhalanx()const; //判断是否为方阵
int IsReverse()const; //判断矩阵是否可逆
int IsNonfunnyPhalanx()const; //判断是否非奇异方阵
double* operator[](int i)const; //操作单个元素
CMatrix& operator=(const CMatrix& right);
CMatrix& operator=(const double* pRight);
CMatrix& operator=(const double** ppRight);
const CMatrix& operator+()const; //一元操作符
const CMatrix operator-()const; //一元操作符
const CMatrix operator+(const CMatrix& right)const;
const CMatrix operator-(const CMatrix& right)const;
const CMatrix operator*(const CMatrix& right)const;
const CMatrix operator*(const double& right)const;
const CMatrix operator/(const double& right)const;
CMatrix& operator+=(const CMatrix& right);
CMatrix& operator-=(const CMatrix& right);
CMatrix& operator*=(const CMatrix& right);
CMatrix& operator*=(const double& right);
CMatrix& operator/=(const double& right);
int operator==(const CMatrix& right)const;
int operator!=(const CMatrix& right)const;
private:
int m_iRow; //行数
int m_iCol; //列数
double** m_ppData; //数据
};
#endif //__MATRIX_DOT_H__
//matrix.cpp
//
#include
#include
#include
#include
#include
#include "matrix.h"
double CMatrix::ZERO = 1e-10;
CMatrix::CMatrix(int row/*=3*/, int col/*=3*/)
{
m_ppData = NULL;
Resize(row, col);
}
//拷贝构造函数
CMatrix::CMatrix(const CMatrix& right)
{
m_ppData = NULL;//一定要加这句初始化(一个对象不会同时调用构造函数和拷贝构造函数)
Resize(right.GetRow(), right.GetCol());
for(int i = 0; i < right.GetRow(); i++)
{
for(int j = 0; j < right.GetCol(); j++)
m_ppData[i][j] = right[i][j];
}
}
CMatrix::~CMatrix()
{
Free();
}
void CMatrix::Free()
{
if(m_ppData != NULL){
for(int i = 0; i < m_iRow; i++)
{
if(m_ppData[i] != NULL)
delete[] m_ppData[i];
m_ppData[i] = NULL;
}
m_ppData = NULL;
}
}
int CMatrix::Resize(int row, int col)
{
assert(row > 0 && col > 0);
//释放空间
Free();
//申请空间
m_iRow = row;
m_iCol = col;
m_ppData = new double*[m_iRow];
assert(m_ppData != NULL);
for(int i = 0; i < m_iRow; i++)
{
m_ppData[i] = new double[m_iCol];
assert(m_ppData[i] != NULL);
}
//初始化
for(i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
m_ppData[i][j] = 0;
}
return 1;
}
//zero
void CMatrix::SetZero(double z)
{
double zero = fabs(z);
if(zero > 1.0f) return;
ZERO = zero;
}
//show
void CMatrix::Show(const char* pre/*=NULL*/)const
{
int i, j;
#ifdef _WINDOWS
if(m_iRow > 10 || m_iCol > 10)
MessageBox(NULL, "矩阵数据量太大,不能输出", "警告", MB_OK);
char buf[4096];
char temp[256];
strcpy(buf, "");
if(pre != NULL)
{
strcpy(buf, pre);
strcat(buf, "\n");
}
for(i = 0; i < m_iRow; i++)
{
for(j = 0; j < m_iCol; j++)
{
sprintf(temp, "%.3f\t", m_ppData[i][j]);
strcat(buf, temp);
}
strcat(buf, "\n");
}
MessageBox(NULL, buf, "提示信息", MB_OK);
#else
if(pre != NULL)
puts(pre);
for(i = 0; i < m_iRow; i++)
{
for(j = 0; j < m_iCol; j++)
printf("%f\t", m_ppData[i][j]);
printf("\n");
}
#endif //_WINDOWS
}
///////////////////////////////////////计算//////////////////////////////////////
//行交换
int CMatrix::RowSwap(int x, int y)
{
if(x < 0 || x >= m_iRow || y < 0 || y >= m_iRow)
return 0;
if(x == y)
return 1;
for(int i = 0; i < m_iCol; i++)
{
Swap(m_ppData[x][i], m_ppData[y][i]);
}
return 1;
}
//列交换
int CMatrix::ColSwap(int x, int y)
{
if(x < 0 || x >= m_iCol || y < 0 || y >= m_iCol)
return 0;
if(x == y)
return 1;
for(int i = 0; i < m_iRow; i++)
{
Swap(m_ppData[i][x], m_ppData[i][y]);
}
return 1;
}
//转置
const CMatrix CMatrix::Transpose()const
{
CMatrix tr(m_iCol, m_iRow);
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
tr[j][i] = m_ppData[i][j];
}
return tr;
}
//计算方阵的行列式(精度不高)
double CMatrix::Determinant()const
{
assert(m_iRow == m_iCol);
CMatrix temp = *this;
int i,j,m,n,s,t,k=1;
double f=1,c,x,sn;
for (i=0,j=0; i
<m_irow&&j<m_irow; i++,j++)
{
if (temp[i][j]==0)
{
for (m = i;m < m_iRow; m++)
{
if(fabs(temp[m][j]) > ZERO)//0
break;
}
if (m == m_iRow)
{
return 0;
}
else
for (n = j; n < m_iRow; n++)
{
c = temp[i][n];
temp[i][n] = temp[m][n];
temp[m][n] = c;
}
k *= (-1);
}
for (s = m_iRow-1; s>i; s--)
{
x = temp[s][j];
for (t = j; t < m_iRow; t++)
temp[s][t] -= temp[i][t] * (x/temp[i][j]);
}
}
for (i = 0; i < m_iRow; i++)
f *= temp[i][i];
sn = k * f;
return sn;
}
//行列式(递归,精度较高)
double CMatrix::Det_Recursion()const
{
assert(m_iRow == m_iCol);
CMatrix temp;
double ans = 0;
if(m_iRow == 1)
{
return m_ppData[0][0];
}
else if(m_iRow == 2)
{
return m_ppData[0][0]*m_ppData[1][1] - m_ppData[1][0]*m_ppData[0][1];
}
else
{
for(int i = 0; i < m_iRow; i++)
{
temp = Residue(i, 0);//this->Residue(i, 0)
ans += temp.Det_Recursion()*m_ppData[i][0]*pow(-1, i);
}
}
return ans;
}
//计算方阵的余子式
const CMatrix CMatrix::Residue(int row, int col)const
{
CMatrix re;
int index = 0;
assert(m_iRow == m_iCol);
assert(m_iRow >= 2);
assert(row < m_iRow && col < m_iCol);
assert(row >= 0 && col >= 0);
double* pData = NULL;
pData = new double[(m_iRow-1)*(m_iCol-1)];
assert(pData != NULL);
re.Resize(m_iRow-1, m_iCol-1);
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
if(i != row && j != col)
pData[index++] = m_ppData[i][j];
}
re = pData;
delete[] pData;
pData = NULL;
return re;
}
//计算方阵的代数余子式
double CMatrix::Residue_a(int row, int col)const
{
return (Residue(row, col)).Det_Recursion()*pow(-1, row+col);
}
//伴随矩阵
const CMatrix CMatrix::Adjoint()const
{
CMatrix ad(m_iRow, m_iCol);
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
ad[j][i] = Residue_a(i, j);
}
return ad;
}
//逆矩阵
const CMatrix CMatrix::Contrary()const
{
assert(IsReverse());
CMatrix co(m_iRow, m_iCol);
co = Adjoint();//this
co /= Det_Recursion();//this
return co;
}
//高斯-约旦法求逆矩阵(全选主元), pDet为原方阵的行列式
const CMatrix CMatrix::Gauss_Jordan(double* pDet/*=NULL*/)const
{
assert(IsReverse());
double fDet = 1.0f;
int flag = 1;
int k = 0, i = 0, j = 0;
CMatrix out(m_iRow, m_iCol);//逆
CMatrix m = *this;//原
CMatrix rhs(2, m_iRow);//保存主元素位置,0 i, 1 j;
for(k = 0; k < m_iRow; k++)
{
//第一步:全选主元
double fMax = 0.0f;
for(i = 0; i < m_iRow; i++)
{
for(j = 0; j < m_iCol; j++)
{
const double f = fabs(m[i][j]);
if(f > fMax)
{
fMax = f;
rhs[0][k] = i;
rhs[1][k] = j;
}
}
}
//if(fMax < 0.00001)//元素全为0
//{
// fDet = 0.0f;
// return out;
//}
if((int)rhs[0][k] != k)
{
flag = -flag;
m.RowSwap((int)rhs[0][k], k);
}
if((int)rhs[1][k] != k)
{
flag = -flag;
m.ColSwap((int)rhs[1][k], k);
}
//计算行列值
fDet *= m[k][k];
//计算逆矩阵
//第二步
m[k][k] = 1.0f/m[k][k];
//第三步
for(j = 0; j < m_iCol; j++)
{
if(j != k)
m[k][j] *= m[k][k];
}
//第四步
for(i = 0; i < m_iRow; i++)
{
if(i != k)
{
for(j = 0; j < m_iCol; j++)
{
if(j != k)
m[i][j] = m[i][j] - m[i][k]*m[k][j];
}
}
}
//第五步
for(i = 0; i < m_iRow; i++)
{
if(i != k)
{
m[i][k] *= -m[k][k];
}
}
}//end for(k);
for(k = m_iRow-1; k >= 0; k--)
{
if((int)rhs[1][k] != k)
{
m.RowSwap((int)rhs[1][k], k);
}
if((int)rhs[0][k] != k)
{
m.ColSwap((int)rhs[0][k], k);
}
}
fDet *= flag;
if(pDet != NULL)
*pDet = fDet;
return m;
}
///////////////////////////////////////判断//////////////////////////////////////
//零矩阵
int CMatrix::IsZero()const
{
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
if(fabs(m_ppData[i][j]) > ZERO)
return 0;
}
return 1;
}
//方阵
int CMatrix::IsPhalanx()const
{
return (m_iRow == m_iCol);
}
//非奇异方阵
int CMatrix::IsNonfunnyPhalanx()const
{
return (IsPhalanx() && fabs(Det_Recursion()) > ZERO);
}
//可逆矩阵
int CMatrix::IsReverse()const
{
return IsNonfunnyPhalanx();
}
///////////////////////////////////////操作符重载//////////////////////////////////////
// []
double* CMatrix::operator [](int i)const
{
assert(i >= 0 && i < m_iRow);
return m_ppData[i];
}
// =
CMatrix& CMatrix::operator =(const CMatrix& right)
{
if(this == &right) return *this;
if((m_iRow != right.GetRow())
|| (m_iCol != right.GetCol()))// 添加于 2005-11-09
{
Resize(right.GetRow(), right.GetCol());
}
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
m_ppData[i][j] = right[i][j];
}
return *this;
}
// =
CMatrix& CMatrix::operator =(const double* pRight)
{
assert(pRight != NULL);
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
m_ppData[i][j] = pRight[m_iCol*i + j];
}
return *this;
}
// =
CMatrix& CMatrix::operator =(const double** ppRight)
{
assert(ppRight != NULL);
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
m_ppData[i][j] = ppRight[i][j];
}
return *this;
}
// 一元操作符+
const CMatrix& CMatrix::operator +()const
{
return *this;
}
// 一元操作符-
const CMatrix CMatrix::operator -()const
{
CMatrix temp(m_iRow, m_iCol);
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
temp[i][j] = -m_ppData[i][j];
}
return temp;
}
// +
const CMatrix CMatrix::operator +(const CMatrix& right)const
{
CMatrix temp(m_iRow, m_iCol);
if(m_iRow == right.GetRow()
&& m_iCol == right.GetCol())
{
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
temp[i][j] = m_ppData[i][j] + right[i][j];
}
}
return temp;
}
// -
const CMatrix CMatrix::operator -(const CMatrix& right)const
{
CMatrix m_temp(m_iRow, m_iCol);
if(m_iRow == right.GetRow()
&& m_iCol == right.GetCol())
{
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
m_temp[i][j] = m_ppData[i][j] - right[i][j];
}
}
return m_temp;
}
// *
const CMatrix CMatrix::operator *(const CMatrix& right)const
{
double temp = 0;
CMatrix m_temp(m_iRow, right.GetCol());
if(m_iCol != right.GetRow())
return m_temp;
for(int i = 0; i < m_temp.GetRow(); i++)
{
for(int j = 0; j < m_temp.GetCol(); j++)
{
temp = 0;
for(int k = 0; k < right.GetRow(); k++)
temp += m_ppData[i][k] * right[k][j];
m_temp[i][j] = temp;
}
}
return m_temp;
}
// *
const CMatrix CMatrix::operator *(const double& right)const
{
CMatrix m_temp(m_iRow, m_iCol);
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
m_temp[i][j] = m_ppData[i][j] * right;
}
return m_temp;
}
// /
const CMatrix CMatrix::operator /(const double& right)const
{
CMatrix m_temp(m_iRow, m_iCol);
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
m_temp[i][j] = m_ppData[i][j] / right;
}
return m_temp;
}
// +=
CMatrix& CMatrix::operator +=(const CMatrix& right)
{
*this = (*this) + right;
return *this;
}
// -=
CMatrix& CMatrix::operator -=(const CMatrix& right)
{
*this = (*this) - right;
return *this;
}
// *=
CMatrix& CMatrix::operator *=(const CMatrix& right)
{
*this = (*this) * right;
return *this;
}
// *=
CMatrix& CMatrix::operator *=(const double& right)
{
*this = (*this) * right;
return *this;
}
// /=
CMatrix& CMatrix::operator /=(const double& right)
{
*this = (*this) / right;
return *this;
}
// ==
int CMatrix::operator ==(const CMatrix& right)const
{
if(this == &right) return 1;
if((m_iRow != right.GetRow())
|| (m_iCol != right.GetCol()))
{
return 0;
}
for(int i = 0; i < m_iRow; i++)
{
for(int j = 0; j < m_iCol; j++)
if(fabs(m_ppData[i][j] - right[i][j]) > ZERO)//0
return 0;
}
return 1;
}
// !=
int CMatrix::operator !=(const CMatrix& right)const
{
return !(*this == right);
}
</m_irow&&j