gsl_cblas__source_symv.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* blas/source_symv.h
  2. *
  3. * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. {
  20. INDEX i, j;
  21. if (alpha == 0.0 && beta == 1.0)
  22. return;
  23. /* form y := beta*y */
  24. if (beta == 0.0) {
  25. INDEX iy = OFFSET(N, incY);
  26. for (i = 0; i < N; i++) {
  27. Y[iy] = 0.0;
  28. iy += incY;
  29. }
  30. } else if (beta != 1.0) {
  31. INDEX iy = OFFSET(N, incY);
  32. for (i = 0; i < N; i++) {
  33. Y[iy] *= beta;
  34. iy += incY;
  35. }
  36. }
  37. if (alpha == 0.0)
  38. return;
  39. /* form y := alpha*A*x + y */
  40. if ((order == CblasRowMajor && Uplo == CblasUpper)
  41. || (order == CblasColMajor && Uplo == CblasLower)) {
  42. INDEX ix = OFFSET(N, incX);
  43. INDEX iy = OFFSET(N, incY);
  44. for (i = 0; i < N; i++) {
  45. BASE temp1 = alpha * X[ix];
  46. BASE temp2 = 0.0;
  47. const INDEX j_min = i + 1;
  48. const INDEX j_max = N;
  49. INDEX jx = OFFSET(N, incX) + j_min * incX;
  50. INDEX jy = OFFSET(N, incY) + j_min * incY;
  51. Y[iy] += temp1 * A[lda * i + i];
  52. for (j = j_min; j < j_max; j++) {
  53. Y[jy] += temp1 * A[lda * i + j];
  54. temp2 += X[jx] * A[lda * i + j];
  55. jx += incX;
  56. jy += incY;
  57. }
  58. Y[iy] += alpha * temp2;
  59. ix += incX;
  60. iy += incY;
  61. }
  62. } else if ((order == CblasRowMajor && Uplo == CblasLower)
  63. || (order == CblasColMajor && Uplo == CblasUpper)) {
  64. INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
  65. INDEX iy = OFFSET(N, incY) + (N - 1) * incY;
  66. for (i = N; i > 0 && i--;) {
  67. BASE temp1 = alpha * X[ix];
  68. BASE temp2 = 0.0;
  69. const INDEX j_min = 0;
  70. const INDEX j_max = i;
  71. INDEX jx = OFFSET(N, incX) + j_min * incX;
  72. INDEX jy = OFFSET(N, incY) + j_min * incY;
  73. Y[iy] += temp1 * A[lda * i + i];
  74. for (j = j_min; j < j_max; j++) {
  75. Y[jy] += temp1 * A[lda * i + j];
  76. temp2 += X[jx] * A[lda * i + j];
  77. jx += incX;
  78. jy += incY;
  79. }
  80. Y[iy] += alpha * temp2;
  81. ix -= incX;
  82. iy -= incY;
  83. }
  84. } else {
  85. BLAS_ERROR("unrecognized operation");
  86. }
  87. }