#include <stdio.h>

void printMatrix(int nrows, int ncols, double *m) {
  for (int i = 0; i < nrows; i++) {
    for (int j = 0; j < ncols; j++) 
      printf("%f ", m[i*ncols + j]);
    printf("\n");
  }
  printf("\n");
}

/* Multiply matrices a and b, storing result in c.
 * Dimensions: a[n][l] * b[l][m] = c[n][m] */
void mat_mul(int l, int m, int n, double *a, double *b, double *c) {
  for (int i=0; i<n; i++)
    for (int j=0; j<m; j++) {
      double tmp = 0.0;
      for (int k=0; k<l; k++)
	tmp += a[i*l+k]*b[k*m+j];
      c[i*m+j] = tmp;
    }
}
