gsl_cblas__source_trmv_c.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* blas/source_tbmv_c.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. const int conj = (TransA == CblasConjTrans) ? -1 : 1;
  21. const int Trans = (TransA != CblasConjTrans) ? TransA : CblasTrans;
  22. const int nonunit = (Diag == CblasNonUnit);
  23. INDEX i, j;
  24. if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasUpper)
  25. || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasLower)) {
  26. /* form x := A*x */
  27. INDEX ix = OFFSET(N, incX);
  28. for (i = 0; i < N; i++) {
  29. BASE temp_r = 0.0;
  30. BASE temp_i = 0.0;
  31. const INDEX j_min = i + 1;
  32. INDEX jx = OFFSET(N, incX) + incX * j_min;
  33. for (j = j_min; j < N; j++) {
  34. const BASE x_real = REAL(X, jx);
  35. const BASE x_imag = IMAG(X, jx);
  36. const BASE A_real = CONST_REAL(A, lda * i + j);
  37. const BASE A_imag = conj * CONST_IMAG(A, lda * i + j);
  38. temp_r += A_real * x_real - A_imag * x_imag;
  39. temp_i += A_real * x_imag + A_imag * x_real;
  40. jx += incX;
  41. }
  42. if (nonunit) {
  43. const BASE x_real = REAL(X, ix);
  44. const BASE x_imag = IMAG(X, ix);
  45. const BASE A_real = CONST_REAL(A, lda * i + i);
  46. const BASE A_imag = conj * CONST_IMAG(A, lda * i + i);
  47. REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
  48. IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
  49. } else {
  50. REAL(X, ix) += temp_r;
  51. IMAG(X, ix) += temp_i;
  52. }
  53. ix += incX;
  54. }
  55. } else if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasLower)
  56. || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasUpper)) {
  57. INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
  58. for (i = N; i > 0 && i--;) {
  59. BASE temp_r = 0.0;
  60. BASE temp_i = 0.0;
  61. const INDEX j_max = i;
  62. INDEX jx = OFFSET(N, incX);
  63. for (j = 0; j < j_max; j++) {
  64. const BASE x_real = REAL(X, jx);
  65. const BASE x_imag = IMAG(X, jx);
  66. const BASE A_real = CONST_REAL(A, lda * i + j);
  67. const BASE A_imag = conj * CONST_IMAG(A, lda * i + j);
  68. temp_r += A_real * x_real - A_imag * x_imag;
  69. temp_i += A_real * x_imag + A_imag * x_real;
  70. jx += incX;
  71. }
  72. if (nonunit) {
  73. const BASE x_real = REAL(X, ix);
  74. const BASE x_imag = IMAG(X, ix);
  75. const BASE A_real = CONST_REAL(A, lda * i + i);
  76. const BASE A_imag = conj * CONST_IMAG(A, lda * i + i);
  77. REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
  78. IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
  79. } else {
  80. REAL(X, ix) += temp_r;
  81. IMAG(X, ix) += temp_i;
  82. }
  83. ix -= incX;
  84. }
  85. } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasUpper)
  86. || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasLower)) {
  87. /* form x := A'*x */
  88. INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
  89. for (i = N; i > 0 && i--;) {
  90. BASE temp_r = 0.0;
  91. BASE temp_i = 0.0;
  92. const INDEX j_max = i;
  93. INDEX jx = OFFSET(N, incX);
  94. for (j = 0; j < j_max; j++) {
  95. const BASE x_real = REAL(X, jx);
  96. const BASE x_imag = IMAG(X, jx);
  97. const BASE A_real = CONST_REAL(A, lda * j + i);
  98. const BASE A_imag = conj * CONST_IMAG(A, lda * j + i);
  99. temp_r += A_real * x_real - A_imag * x_imag;
  100. temp_i += A_real * x_imag + A_imag * x_real;
  101. jx += incX;
  102. }
  103. if (nonunit) {
  104. const BASE x_real = REAL(X, ix);
  105. const BASE x_imag = IMAG(X, ix);
  106. const BASE A_real = CONST_REAL(A, lda * i + i);
  107. const BASE A_imag = conj * CONST_IMAG(A, lda * i + i);
  108. REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
  109. IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
  110. } else {
  111. REAL(X, ix) += temp_r;
  112. IMAG(X, ix) += temp_i;
  113. }
  114. ix -= incX;
  115. }
  116. } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasLower)
  117. || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasUpper)) {
  118. INDEX ix = OFFSET(N, incX);
  119. for (i = 0; i < N; i++) {
  120. BASE temp_r = 0.0;
  121. BASE temp_i = 0.0;
  122. const INDEX j_min = i + 1;
  123. INDEX jx = OFFSET(N, incX) + j_min * incX;
  124. for (j = j_min; j < N; j++) {
  125. const BASE x_real = REAL(X, jx);
  126. const BASE x_imag = IMAG(X, jx);
  127. const BASE A_real = CONST_REAL(A, lda * j + i);
  128. const BASE A_imag = conj * CONST_IMAG(A, lda * j + i);
  129. temp_r += A_real * x_real - A_imag * x_imag;
  130. temp_i += A_real * x_imag + A_imag * x_real;
  131. jx += incX;
  132. }
  133. if (nonunit) {
  134. const BASE x_real = REAL(X, ix);
  135. const BASE x_imag = IMAG(X, ix);
  136. const BASE A_real = CONST_REAL(A, lda * i + i);
  137. const BASE A_imag = conj * CONST_IMAG(A, lda * i + i);
  138. REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
  139. IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
  140. } else {
  141. REAL(X, ix) += temp_r;
  142. IMAG(X, ix) += temp_i;
  143. }
  144. ix += incX;
  145. }
  146. } else {
  147. BLAS_ERROR("unrecognized operation");
  148. }
  149. }