Professional Documents
Culture Documents
h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
return C;
}
int *matrix_multiply_direct(int **A, int **B, int row, int deallocate) {
int *C = matrix_allocate(row, row);
for (int i = 0; i < row; i++) {
for (int j = 0; j < row; j++) {
int x = 0;
for (int k = 0; k < row; k++) {
x += A[i][k] * B[k][j];
}
C[i][j] = x;
}
}
if (deallocate & 1) matrix_free(A, row);
if (deallocate & 2) matrix_free(B, row);
return C;
}
matrix_print("A", A, n);
matrix_print("B", B, n);
return 0;
}