gsl_cblas__source_tbmv_r.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* blas/source_tbmv_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. const int nonunit = (Diag == CblasNonUnit);
  22. const int Trans = (TransA != CblasConjTrans) ? TransA : CblasTrans;
  23. if (N == 0)
  24. return;
  25. if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasUpper)
  26. || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasLower)) {
  27. /* form x := A*x */
  28. INDEX ix = OFFSET(N, incX);
  29. for (i = 0; i < N; i++) {
  30. BASE temp = (nonunit ? A[lda * i + 0] : 1.0) * X[ix];
  31. const INDEX j_min = i + 1;
  32. const INDEX j_max = GSL_MIN(N, i + K + 1);
  33. INDEX jx = OFFSET(N, incX) + j_min * incX;
  34. for (j = j_min; j < j_max; j++) {
  35. temp += X[jx] * A[lda * i + (j - i)];
  36. jx += incX;
  37. }
  38. X[ix] = temp;
  39. ix += incX;
  40. }
  41. } else if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasLower)
  42. || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasUpper)) {
  43. INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
  44. for (i = N; i > 0 && i--;) {
  45. BASE temp = (nonunit ? A[lda * i + K] : 1.0) * X[ix];
  46. const INDEX j_min = (i > K ? i - K : 0);
  47. const INDEX j_max = i;
  48. INDEX jx = OFFSET(N, incX) + j_min * incX;
  49. for (j = j_min; j < j_max; j++) {
  50. temp += X[jx] * A[lda * i + (K - i + j)];
  51. jx += incX;
  52. }
  53. X[ix] = temp;
  54. ix -= incX;
  55. }
  56. } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasUpper)
  57. || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasLower)) {
  58. /* form x := A'*x */
  59. INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
  60. for (i = N; i > 0 && i--;) {
  61. BASE temp = 0.0;
  62. const INDEX j_min = (K > i ? 0 : i - K);
  63. const INDEX j_max = i;
  64. INDEX jx = OFFSET(N, incX) + j_min * incX;
  65. for (j = j_min; j < j_max; j++) {
  66. temp += X[jx] * A[lda * j + (i - j)];
  67. jx += incX;
  68. }
  69. if (nonunit) {
  70. X[ix] = temp + X[ix] * A[lda * i + 0];
  71. } else {
  72. X[ix] += temp;
  73. }
  74. ix -= incX;
  75. }
  76. } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasLower)
  77. || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasUpper)) {
  78. INDEX ix = OFFSET(N, incX);
  79. for (i = 0; i < N; i++) {
  80. BASE temp = 0.0;
  81. const INDEX j_min = i + 1;
  82. const INDEX j_max = GSL_MIN(N, i + K + 1);
  83. INDEX jx = OFFSET(N, incX) + j_min * incX;
  84. for (j = j_min; j < j_max; j++) {
  85. temp += X[jx] * A[lda * j + (K - j + i)];
  86. jx += incX;
  87. }
  88. if (nonunit) {
  89. X[ix] = temp + X[ix] * A[lda * i + K];
  90. } else {
  91. X[ix] += temp;
  92. }
  93. ix += incX;
  94. }
  95. }
  96. }