gsl_cblas__source_gbmv_r.h 2.7 KB

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