在类矩阵
typedef std::vector < std::vector <double> > TItems;
class Matrix
{
private :
TItems items;
public:
double & operator() ( int r, int c ) {return items[r][c];}
Matrix & operator = (const Matrix A, short r1, short r2, short c1, short c2 )
}
我正在尝试重新定义运算符 = 以便能够将子矩阵分配给矩阵。
Matrix & operator = (const Matrix &A, short r1, short r2, short c1, short c2)
{
Matrix A_sub( r2 - r1 + 1, c2 - c1 + 1 );
for ( int i = 0; i < ( r2 - r1 + 1 ); i++ )
{
for ( unsigned int j = 0; j < ( c2 - c1 + 1); j++ )
items[i][j] = A (r1 + i, c1 + j );
}
return *this;
}
但是这样的定义是不可能的......如果需要这种类型的符号,如何解决这个问题?
Matrix A(8,8), B (3,9), C(3,4), D(2, 3), E (8, 8);, F(8,8)
...
A(1,3,2,5) = B (0,2,5,8) + C(0,2,0, 3) + D;
F = A + E;
谢谢你的帮助。