vmul.c 691 B

12345678910111213141516171819202122232425262728293031
  1. /* vmul.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. void vmul(double *vp, double *mat, double *v, int n)
  9. {
  10. double s, *q;
  11. int k, i;
  12. for (k = 0; k < n; ++k) {
  13. for (i = 0, q = v, s = 0.; i < n; ++i)
  14. s += *mat++ * *q++;
  15. *vp++ = s;
  16. }
  17. }
  18. double vnrm(double *u, double *v, int n)
  19. {
  20. double s;
  21. int i;
  22. for (i = 0, s = 0.; i < n; ++i)
  23. s += *u++ * *v++;
  24. return s;
  25. }