otrma.c 827 B

123456789101112131415161718192021222324252627282930
  1. /* otrma.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 otrma(double *c, double *a, double *b, int n)
  10. {
  11. double z, *q0, *p, *s, *t;
  12. int i, j, k;
  13. q0 = (double *)calloc(n, sizeof(double));
  14. for (i = 0; i < n; ++i, ++c) {
  15. for (j = 0, t = b; j < n; ++j) {
  16. for (k = 0, s = a + i * n, z = 0.; k < n; ++k)
  17. z += *t++ * *s++;
  18. q0[j] = z;
  19. }
  20. for (j = 0, p = c, t = a; j < n; ++j, p += n) {
  21. for (k = 0, s = q0, z = 0.; k < n; ++k)
  22. z += *t++ * *s++;
  23. *p = z;
  24. }
  25. }
  26. free(q0);
  27. }