gsl_cblas__source_sbmv.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* blas/source_sbmv.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 (N == 0)
  22. return;
  23. if (alpha == 0.0 && beta == 1.0)
  24. return;
  25. /* form y := beta*y */
  26. if (beta == 0.0) {
  27. INDEX iy = OFFSET(N, incY);
  28. for (i = 0; i < N; i++) {
  29. Y[iy] = 0.0;
  30. iy += incY;
  31. }
  32. } else if (beta != 1.0) {
  33. INDEX iy = OFFSET(N, incY);
  34. for (i = 0; i < N; i++) {
  35. Y[iy] *= beta;
  36. iy += incY;
  37. }
  38. }
  39. if (alpha == 0.0)
  40. return;
  41. /* form y := alpha*A*x + y */
  42. if ((order == CblasRowMajor && Uplo == CblasUpper)
  43. || (order == CblasColMajor && Uplo == CblasLower)) {
  44. INDEX ix = OFFSET(N, incX);
  45. INDEX iy = OFFSET(N, incY);
  46. for (i = 0; i < N; i++) {
  47. BASE tmp1 = alpha * X[ix];
  48. BASE tmp2 = 0.0;
  49. const INDEX j_min = i + 1;
  50. const INDEX j_max = GSL_MIN(N, i + K + 1);
  51. INDEX jx = OFFSET(N, incX) + j_min * incX;
  52. INDEX jy = OFFSET(N, incY) + j_min * incY;
  53. Y[iy] += tmp1 * A[0 + i * lda];
  54. for (j = j_min; j < j_max; j++) {
  55. BASE Aij = A[(j - i) + i * lda];
  56. Y[jy] += tmp1 * Aij;
  57. tmp2 += Aij * X[jx];
  58. jx += incX;
  59. jy += incY;
  60. }
  61. Y[iy] += alpha * tmp2;
  62. ix += incX;
  63. iy += incY;
  64. }
  65. } else if ((order == CblasRowMajor && Uplo == CblasLower)
  66. || (order == CblasColMajor && Uplo == CblasUpper)) {
  67. INDEX ix = OFFSET(N, incX);
  68. INDEX iy = OFFSET(N, incY);
  69. for (i = 0; i < N; i++) {
  70. BASE tmp1 = alpha * X[ix];
  71. BASE tmp2 = 0.0;
  72. const INDEX j_min = (i > K) ? i - K : 0;
  73. const INDEX j_max = i;
  74. INDEX jx = OFFSET(N, incX) + j_min * incX;
  75. INDEX jy = OFFSET(N, incY) + j_min * incY;
  76. for (j = j_min; j < j_max; j++) {
  77. BASE Aij = A[(K - i + j) + i * lda];
  78. Y[jy] += tmp1 * Aij;
  79. tmp2 += Aij * X[jx];
  80. jx += incX;
  81. jy += incY;
  82. }
  83. Y[iy] += tmp1 * A[K + i * lda] + alpha * tmp2;
  84. ix += incX;
  85. iy += incY;
  86. }
  87. } else {
  88. BLAS_ERROR("unrecognized operation");
  89. }
  90. }