1 /* blas/source_tbmv_c.h
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
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.
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.
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.
21 const int conj = (TransA == CblasConjTrans) ? -1 : 1;
22 const int Trans = (TransA != CblasConjTrans) ? TransA : CblasTrans;
23 const int nonunit = (Diag == CblasNonUnit);
27 if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasUpper)
28 || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasLower)) {
31 INDEX ix = OFFSET(N, incX);
32 for (i = 0; i < N; i++) {
35 const INDEX j_min = i + 1;
36 const INDEX j_max = GSL_MIN(N, i + K + 1);
37 INDEX jx = OFFSET(N, incX) + incX * j_min;
38 for (j = j_min; j < j_max; j++) {
39 const BASE x_real = REAL(X, jx);
40 const BASE x_imag = IMAG(X, jx);
41 const BASE A_real = CONST_REAL(A, lda * i + (j - i));
42 const BASE A_imag = conj * CONST_IMAG(A, lda * i + (j - i));
44 temp_r += A_real * x_real - A_imag * x_imag;
45 temp_i += A_real * x_imag + A_imag * x_real;
50 const BASE x_real = REAL(X, ix);
51 const BASE x_imag = IMAG(X, ix);
52 const BASE A_real = CONST_REAL(A, lda * i + 0);
53 const BASE A_imag = conj * CONST_IMAG(A, lda * i + 0);
55 REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
56 IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
58 REAL(X, ix) += temp_r;
59 IMAG(X, ix) += temp_i;
63 } else if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasLower)
64 || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasUpper)) {
65 INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
67 for (i = N; i > 0 && i--;) { /* N-1 ... 0 */
70 const INDEX j_min = (K > i ? 0 : i - K);
71 const INDEX j_max = i;
72 INDEX jx = OFFSET(N, incX) + j_min * incX;
73 for (j = j_min; j < j_max; j++) {
74 const BASE x_real = REAL(X, jx);
75 const BASE x_imag = IMAG(X, jx);
76 const BASE A_real = CONST_REAL(A, lda * i + (K - i + j));
77 const BASE A_imag = conj * CONST_IMAG(A, lda * i + (K - i + j));
79 temp_r += A_real * x_real - A_imag * x_imag;
80 temp_i += A_real * x_imag + A_imag * x_real;
85 const BASE x_real = REAL(X, ix);
86 const BASE x_imag = IMAG(X, ix);
87 const BASE A_real = CONST_REAL(A, lda * i + K);
88 const BASE A_imag = conj * CONST_IMAG(A, lda * i + K);
90 REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
91 IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
93 REAL(X, ix) += temp_r;
94 IMAG(X, ix) += temp_i;
98 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasUpper)
99 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasLower)) {
102 INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
103 for (i = N; i > 0 && i--;) { /* N-1 ... 0 */
106 const INDEX j_min = (K > i ? 0 : i - K);
107 const INDEX j_max = i;
108 INDEX jx = OFFSET(N, incX) + j_min * incX;
109 for (j = j_min; j < j_max; j++) {
110 const BASE x_real = REAL(X, jx);
111 const BASE x_imag = IMAG(X, jx);
112 const BASE A_real = CONST_REAL(A, lda * j + (i - j));
113 const BASE A_imag = conj * CONST_IMAG(A, lda * j + (i - j));
115 temp_r += A_real * x_real - A_imag * x_imag;
116 temp_i += A_real * x_imag + A_imag * x_real;
121 const BASE x_real = REAL(X, ix);
122 const BASE x_imag = IMAG(X, ix);
123 const BASE A_real = CONST_REAL(A, lda * i + 0);
124 const BASE A_imag = conj * CONST_IMAG(A, lda * i + 0);
126 REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
127 IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
129 REAL(X, ix) += temp_r;
130 IMAG(X, ix) += temp_i;
134 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasLower)
135 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasUpper)) {
136 INDEX ix = OFFSET(N, incX);
137 for (i = 0; i < N; i++) {
140 const INDEX j_min = i + 1;
141 const INDEX j_max = GSL_MIN(N, i + K + 1);
142 INDEX jx = OFFSET(N, incX) + j_min * incX;
143 for (j = j_min; j < j_max; j++) {
144 const BASE x_real = REAL(X, jx);
145 const BASE x_imag = IMAG(X, jx);
146 const BASE A_real = CONST_REAL(A, lda * j + (K - j + i));
147 const BASE A_imag = conj * CONST_IMAG(A, lda * j + (K - j + i));
149 temp_r += A_real * x_real - A_imag * x_imag;
150 temp_i += A_real * x_imag + A_imag * x_real;
155 const BASE x_real = REAL(X, ix);
156 const BASE x_imag = IMAG(X, ix);
157 const BASE A_real = CONST_REAL(A, lda * i + K);
158 const BASE A_imag = conj * CONST_IMAG(A, lda * i + K);
160 REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
161 IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
163 REAL(X, ix) += temp_r;
164 IMAG(X, ix) += temp_i;
169 BLAS_ERROR("unrecognized operation");