1 /* blas/source_tpmv_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.
23 const int conj = (TransA == CblasConjTrans) ? -1 : 1;
24 const int Trans = (TransA != CblasConjTrans) ? TransA : CblasTrans;
25 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++) {
33 const BASE Aii_real = CONST_REAL(Ap, TPUP(N, i, i));
34 const BASE Aii_imag = conj * CONST_IMAG(Ap, TPUP(N, i, i));
38 BASE x_real = REAL(X, ix);
39 BASE x_imag = IMAG(X, ix);
40 temp_r = Aii_real * x_real - Aii_imag * x_imag;
41 temp_i = Aii_real * x_imag + Aii_imag * x_real;
48 INDEX jx = OFFSET(N, incX) + (i + 1) * incX;
49 for (j = i + 1; j < N; j++) {
50 const BASE Aij_real = CONST_REAL(Ap, TPUP(N, i, j));
51 const BASE Aij_imag = conj * CONST_IMAG(Ap, TPUP(N, i, j));
52 BASE x_real = REAL(X, jx);
53 BASE x_imag = IMAG(X, jx);
54 temp_r += Aij_real * x_real - Aij_imag * x_imag;
55 temp_i += Aij_real * x_imag + Aij_imag * x_real;
64 } else if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasLower)
65 || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasUpper)) {
67 INDEX ix = OFFSET(N, incX) + incX * (N - 1);
68 for (i = N; i > 0 && i--;) {
69 const BASE Aii_real = CONST_REAL(Ap, TPLO(N, i, i));
70 const BASE Aii_imag = conj * CONST_IMAG(Ap, TPLO(N, i, i));
74 BASE x_real = REAL(X, ix);
75 BASE x_imag = IMAG(X, ix);
76 temp_r = Aii_real * x_real - Aii_imag * x_imag;
77 temp_i = Aii_real * x_imag + Aii_imag * x_real;
84 INDEX jx = OFFSET(N, incX);
85 for (j = 0; j < i; j++) {
86 const BASE Aij_real = CONST_REAL(Ap, TPLO(N, i, j));
87 const BASE Aij_imag = conj * CONST_IMAG(Ap, TPLO(N, i, j));
88 BASE x_real = REAL(X, jx);
89 BASE x_imag = IMAG(X, jx);
90 temp_r += Aij_real * x_real - Aij_imag * x_imag;
91 temp_i += Aij_real * x_imag + Aij_imag * x_real;
100 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasUpper)
101 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasLower)) {
104 INDEX ix = OFFSET(N, incX) + incX * (N - 1);
105 for (i = N; i > 0 && i--;) {
106 const BASE Aii_real = CONST_REAL(Ap, TPUP(N, i, i));
107 const BASE Aii_imag = conj * CONST_IMAG(Ap, TPUP(N, i, i));
111 BASE x_real = REAL(X, ix);
112 BASE x_imag = IMAG(X, ix);
113 temp_r = Aii_real * x_real - Aii_imag * x_imag;
114 temp_i = Aii_real * x_imag + Aii_imag * x_real;
116 temp_r = REAL(X, ix);
117 temp_i = IMAG(X, ix);
120 INDEX jx = OFFSET(N, incX);
121 for (j = 0; j < i; j++) {
122 BASE x_real = REAL(X, jx);
123 BASE x_imag = IMAG(X, jx);
124 const BASE Aji_real = CONST_REAL(Ap, TPUP(N, j, i));
125 const BASE Aji_imag = conj * CONST_IMAG(Ap, TPUP(N, j, i));
126 temp_r += Aji_real * x_real - Aji_imag * x_imag;
127 temp_i += Aji_real * x_imag + Aji_imag * x_real;
132 REAL(X, ix) = temp_r;
133 IMAG(X, ix) = temp_i;
136 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasLower)
137 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasUpper)) {
139 INDEX ix = OFFSET(N, incX);
140 for (i = 0; i < N; i++) {
141 const BASE Aii_real = CONST_REAL(Ap, TPLO(N, i, i));
142 const BASE Aii_imag = conj * CONST_IMAG(Ap, TPLO(N, i, i));
146 BASE x_real = REAL(X, ix);
147 BASE x_imag = IMAG(X, ix);
148 temp_r = Aii_real * x_real - Aii_imag * x_imag;
149 temp_i = Aii_real * x_imag + Aii_imag * x_real;
151 temp_r = REAL(X, ix);
152 temp_i = IMAG(X, ix);
155 INDEX jx = OFFSET(N, incX) + (i + 1) * incX;
156 for (j = i + 1; j < N; j++) {
157 BASE x_real = REAL(X, jx);
158 BASE x_imag = IMAG(X, jx);
159 const BASE Aji_real = CONST_REAL(Ap, TPLO(N, j, i));
160 const BASE Aji_imag = conj * CONST_IMAG(Ap, TPLO(N, j, i));
161 temp_r += Aji_real * x_real - Aji_imag * x_imag;
162 temp_i += Aji_real * x_imag + Aji_imag * x_real;
166 REAL(X, ix) = temp_r;
167 IMAG(X, ix) = temp_i;
171 BLAS_ERROR("unrecognized operation");