forked from freudenreichan/info2Praktikum-NeuronalesNetz
Fixed all matrix.c, all tests passed
This commit is contained in:
1 parent
67f7325068
commit
7c5a0c012f
1 file changed
+4
-4
+4
-4
@@ -25,7 +25,7 @@ void clearMatrix(Matrix *matrix)
|
||||
void setMatrixAt(MatrixType value, Matrix matrix, unsigned int rowIdx, unsigned int colIdx)
|
||||
{
|
||||
if(rowIdx < matrix.rows && colIdx < matrix.cols){
|
||||
*(matrix.buffer + rowIdx * matrix.rows + colIdx) = value;
|
||||
*(matrix.buffer + rowIdx * matrix.cols + colIdx) = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ MatrixType getMatrixAt(const Matrix matrix, unsigned int rowIdx, unsigned int co
|
||||
if(rowIdx >= matrix.rows || colIdx >= matrix.cols){
|
||||
return 0;
|
||||
}
|
||||
return *(matrix.buffer + rowIdx * matrix.rows + colIdx);
|
||||
return *(matrix.buffer + rowIdx * matrix.cols + colIdx);
|
||||
}
|
||||
|
||||
Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||
@@ -42,7 +42,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||
int n1 = matrix1.cols;
|
||||
int m1 = matrix1.rows;
|
||||
int n2 = matrix2.cols;
|
||||
int m2 = matrix2.cols;
|
||||
int m2 = matrix2.rows;
|
||||
|
||||
if(n1 == 1 && m1 == m2){
|
||||
Matrix new_mat = createMatrix(m2, n2);
|
||||
@@ -68,7 +68,7 @@ Matrix add(const Matrix matrix1, const Matrix matrix2)
|
||||
return (Matrix) {0, 0, NULL};
|
||||
}
|
||||
|
||||
Matrix new_mat = createMatrix(n1, m1);
|
||||
Matrix new_mat = createMatrix(m1, n1);
|
||||
|
||||
for(int i = 0; i < m1; i++){
|
||||
for(int j = 0; j < n1; j++){
|
||||
|
||||
Reference in new issue
Block a user