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 INDEX jx = OFFSET(N, incX) + incX * j_min;
37 for (j = j_min; j < N; j++) {
38 const BASE x_real = REAL(X, jx);
39 const BASE x_imag = IMAG(X, jx);
40 const BASE A_real = CONST_REAL(A, lda * i + j);
41 const BASE A_imag = conj * CONST_IMAG(A, lda * i + j);
43 temp_r += A_real * x_real - A_imag * x_imag;
44 temp_i += A_real * x_imag + A_imag * x_real;
49 const BASE x_real = REAL(X, ix);
50 const BASE x_imag = IMAG(X, ix);
51 const BASE A_real = CONST_REAL(A, lda * i + i);
52 const BASE A_imag = conj * CONST_IMAG(A, lda * i + i);
54 REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
55 IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
57 REAL(X, ix) += temp_r;
58 IMAG(X, ix) += temp_i;
62 } else if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasLower)
63 || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasUpper)) {
65 INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
67 for (i = N; i > 0 && i--;) {
70 const INDEX j_max = i;
71 INDEX jx = OFFSET(N, incX);
72 for (j = 0; j < j_max; j++) {
73 const BASE x_real = REAL(X, jx);
74 const BASE x_imag = IMAG(X, jx);
75 const BASE A_real = CONST_REAL(A, lda * i + j);
76 const BASE A_imag = conj * CONST_IMAG(A, lda * i + j);
78 temp_r += A_real * x_real - A_imag * x_imag;
79 temp_i += A_real * x_imag + A_imag * x_real;
84 const BASE x_real = REAL(X, ix);
85 const BASE x_imag = IMAG(X, ix);
86 const BASE A_real = CONST_REAL(A, lda * i + i);
87 const BASE A_imag = conj * CONST_IMAG(A, lda * i + i);
89 REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
90 IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
92 REAL(X, ix) += temp_r;
93 IMAG(X, ix) += temp_i;
97 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasUpper)
98 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasLower)) {
101 INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
102 for (i = N; i > 0 && i--;) {
105 const INDEX j_max = i;
106 INDEX jx = OFFSET(N, incX);
107 for (j = 0; j < j_max; j++) {
108 const BASE x_real = REAL(X, jx);
109 const BASE x_imag = IMAG(X, jx);
110 const BASE A_real = CONST_REAL(A, lda * j + i);
111 const BASE A_imag = conj * CONST_IMAG(A, lda * j + i);
113 temp_r += A_real * x_real - A_imag * x_imag;
114 temp_i += A_real * x_imag + A_imag * x_real;
119 const BASE x_real = REAL(X, ix);
120 const BASE x_imag = IMAG(X, ix);
121 const BASE A_real = CONST_REAL(A, lda * i + i);
122 const BASE A_imag = conj * CONST_IMAG(A, lda * i + i);
124 REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
125 IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
127 REAL(X, ix) += temp_r;
128 IMAG(X, ix) += temp_i;
133 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasLower)
134 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasUpper)) {
135 INDEX ix = OFFSET(N, incX);
136 for (i = 0; i < N; i++) {
139 const INDEX j_min = i + 1;
140 INDEX jx = OFFSET(N, incX) + j_min * incX;
141 for (j = j_min; j < N; j++) {
142 const BASE x_real = REAL(X, jx);
143 const BASE x_imag = IMAG(X, jx);
144 const BASE A_real = CONST_REAL(A, lda * j + i);
145 const BASE A_imag = conj * CONST_IMAG(A, lda * j + i);
147 temp_r += A_real * x_real - A_imag * x_imag;
148 temp_i += A_real * x_imag + A_imag * x_real;
153 const BASE x_real = REAL(X, ix);
154 const BASE x_imag = IMAG(X, ix);
155 const BASE A_real = CONST_REAL(A, lda * i + i);
156 const BASE A_imag = conj * CONST_IMAG(A, lda * i + i);
158 REAL(X, ix) = temp_r + (A_real * x_real - A_imag * x_imag);
159 IMAG(X, ix) = temp_i + (A_real * x_imag + A_imag * x_real);
161 REAL(X, ix) += temp_r;
162 IMAG(X, ix) += temp_i;
167 BLAS_ERROR("unrecognized operation");