rmmult.c 766 B

123456789101112131415161718192021222324252627
  1. /* rmmult.c CCMATH mathematics library source code.
  2. *
  3. * Copyright (C) 2000 Daniel A. Atkinson All rights reserved.
  4. * This code may be redistributed under the terms of the GNU library
  5. * public license (LGPL). ( See the lgpl.license file for details.)
  6. * ------------------------------------------------------------------------
  7. */
  8. #include <stdlib.h>
  9. void rmmult(double *rm, double *a, double *b, int n, int m, int l)
  10. {
  11. double z, *q0, *p, *q;
  12. int i, j, k;
  13. q0 = (double *)calloc(m, sizeof(double));
  14. for (i = 0; i < l; ++i, ++rm) {
  15. for (k = 0, p = b + i; k < m; p += l)
  16. q0[k++] = *p;
  17. for (j = 0, p = a, q = rm; j < n; ++j, q += l) {
  18. for (k = 0, z = 0.; k < m;)
  19. z += *p++ * q0[k++];
  20. *q = z;
  21. }
  22. }
  23. free(q0);
  24. }