gsl_cblas__source_trmv_r.h 3.5 KB

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