}
printf("\n");
}
printf("\n");
}
/* 矩阵相加 */
Matrix matrixAdd(Matrix a, Matrix b) {
Matrix c = matrixAlloc(a.rows, a.cols);
int i;
int j;
assert(a.rows == b.rows);
assert(a.cols == b.cols);
for ( i = 0; i < a.rows; ++i) {
for ( j = 0; j < a.cols; ++j) {
c.data[i][j] = a.data[i][j] + b.data[i][j];
}
}
return c;
}
Matrix matrixAddThree(Matrix a, Matrix b, Matrix c)
{
Matrix d = matrixAlloc(a.rows, a.cols);
int i;
int j;
assert(a.rows == b.rows);
assert(a.cols == b.cols);
assert(a.rows == c.rows);
assert(a.cols == c.cols);
for ( i = 0; i < a.rows; ++i) {
for ( j = 0; j < a.cols; ++j) {
d.data[i][j] = a.data[i][j] + b.data[i][j] + c.data[i][j];
}
}
return d;
}
/* 矩阵相减 */
Matrix matrixSubstract(Matrix a, Matrix b) {
Matrix c = matrixAlloc(a.rows, a.cols);
int i;
int j;
assert(a.rows == b.rows);
assert(a.cols == b.cols);
for ( i = 0; i < a.rows; ++i) {
for ( j = 0; j < a.cols; ++j) {
c.data[i][j] = a.data[i][j] - b.data[i][j];
}
}
return c;
}
/* 用单元矩阵减去该矩阵 */
void matrixSubstractFromIdentity(Matrix a) {
int i;