gsl_cblas__source_gemv_r.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* blas/source_gemv_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;
  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. } else {
  31. lenX = M;
  32. lenY = N;
  33. }
  34. /* form y := beta*y */
  35. if (beta == 0.0) {
  36. INDEX iy = OFFSET(lenY, incY);
  37. for (i = 0; i < lenY; i++) {
  38. Y[iy] = 0.0;
  39. iy += incY;
  40. }
  41. } else if (beta != 1.0) {
  42. INDEX iy = OFFSET(lenY, incY);
  43. for (i = 0; i < lenY; i++) {
  44. Y[iy] *= beta;
  45. iy += incY;
  46. }
  47. }
  48. if (alpha == 0.0)
  49. return;
  50. if ((order == CblasRowMajor && Trans == CblasNoTrans)
  51. || (order == CblasColMajor && Trans == CblasTrans)) {
  52. /* form y := alpha*A*x + y */
  53. INDEX iy = OFFSET(lenY, incY);
  54. for (i = 0; i < lenY; i++) {
  55. BASE temp = 0.0;
  56. INDEX ix = OFFSET(lenX, incX);
  57. for (j = 0; j < lenX; j++) {
  58. temp += X[ix] * A[lda * i + j];
  59. ix += incX;
  60. }
  61. Y[iy] += alpha * temp;
  62. iy += incY;
  63. }
  64. } else if ((order == CblasRowMajor && Trans == CblasTrans)
  65. || (order == CblasColMajor && Trans == CblasNoTrans)) {
  66. /* form y := alpha*A'*x + y */
  67. INDEX ix = OFFSET(lenX, incX);
  68. for (j = 0; j < lenX; j++) {
  69. const BASE temp = alpha * X[ix];
  70. if (temp != 0.0) {
  71. INDEX iy = OFFSET(lenY, incY);
  72. for (i = 0; i < lenY; i++) {
  73. Y[iy] += temp * A[lda * j + i];
  74. iy += incY;
  75. }
  76. }
  77. ix += incX;
  78. }
  79. } else {
  80. BLAS_ERROR("unrecognized operation");
  81. }
  82. }