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 = (order == CblasColMajor) ? -1 : 1;
24 const BASE alpha_real = CONST_REAL0(alpha);
25 const BASE alpha_imag = CONST_IMAG0(alpha);
27 const BASE beta_real = CONST_REAL0(beta);
28 const BASE beta_imag = CONST_IMAG0(beta);
30 if ((alpha_real == 0.0 && alpha_imag == 0.0)
31 && (beta_real == 1.0 && beta_imag == 0.0))
34 /* form y := beta*y */
35 if (beta_real == 0.0 && beta_imag == 0.0) {
36 INDEX iy = OFFSET(N, incY);
37 for (i = 0; i < N; i++) {
42 } else if (!(beta_real == 1.0 && beta_imag == 0.0)) {
43 INDEX iy = OFFSET(N, incY);
44 for (i = 0; i < N; i++) {
45 const BASE y_real = REAL(Y, iy);
46 const BASE y_imag = IMAG(Y, iy);
47 const BASE tmpR = y_real * beta_real - y_imag * beta_imag;
48 const BASE tmpI = y_real * beta_imag + y_imag * beta_real;
55 if (alpha_real == 0.0 && alpha_imag == 0.0)
58 /* form y := alpha*A*x + y */
60 if ((order == CblasRowMajor && Uplo == CblasUpper)
61 || (order == CblasColMajor && Uplo == CblasLower)) {
63 INDEX ix = OFFSET(N, incX);
64 INDEX iy = OFFSET(N, incY);
65 for (i = 0; i < N; i++) {
66 BASE x_real = CONST_REAL(X, ix);
67 BASE x_imag = CONST_IMAG(X, ix);
68 BASE temp1_real = alpha_real * x_real - alpha_imag * x_imag;
69 BASE temp1_imag = alpha_real * x_imag + alpha_imag * x_real;
70 BASE temp2_real = 0.0;
71 BASE temp2_imag = 0.0;
72 const INDEX j_min = i + 1;
73 const INDEX j_max = N;
74 INDEX jx = OFFSET(N, incX) + j_min * incX;
75 INDEX jy = OFFSET(N, incY) + j_min * incY;
76 BASE Aii_real = CONST_REAL(Ap, TPUP(N, i, i));
77 /* Aii_imag is zero */
78 REAL(Y, iy) += temp1_real * Aii_real;
79 IMAG(Y, iy) += temp1_imag * Aii_real;
80 for (j = j_min; j < j_max; j++) {
81 BASE Aij_real = CONST_REAL(Ap, TPUP(N, i, j));
82 BASE Aij_imag = conj * CONST_IMAG(Ap, TPUP(N, i, j));
83 REAL(Y, jy) += temp1_real * Aij_real - temp1_imag * (-Aij_imag);
84 IMAG(Y, jy) += temp1_real * (-Aij_imag) + temp1_imag * Aij_real;
85 x_real = CONST_REAL(X, jx);
86 x_imag = CONST_IMAG(X, jx);
87 temp2_real += x_real * Aij_real - x_imag * Aij_imag;
88 temp2_imag += x_real * Aij_imag + x_imag * Aij_real;
92 REAL(Y, iy) += alpha_real * temp2_real - alpha_imag * temp2_imag;
93 IMAG(Y, iy) += alpha_real * temp2_imag + alpha_imag * temp2_real;
97 } else if ((order == CblasRowMajor && Uplo == CblasLower)
98 || (order == CblasColMajor && Uplo == CblasUpper)) {
100 INDEX ix = OFFSET(N, incX);
101 INDEX iy = OFFSET(N, incY);
102 for (i = 0; i < N; i++) {
103 BASE x_real = CONST_REAL(X, ix);
104 BASE x_imag = CONST_IMAG(X, ix);
105 BASE temp1_real = alpha_real * x_real - alpha_imag * x_imag;
106 BASE temp1_imag = alpha_real * x_imag + alpha_imag * x_real;
107 BASE temp2_real = 0.0;
108 BASE temp2_imag = 0.0;
109 const INDEX j_min = 0;
110 const INDEX j_max = i;
111 INDEX jx = OFFSET(N, incX) + j_min * incX;
112 INDEX jy = OFFSET(N, incY) + j_min * incY;
113 BASE Aii_real = CONST_REAL(Ap, TPLO(N, i, i));
114 /* Aii_imag is zero */
115 REAL(Y, iy) += temp1_real * Aii_real;
116 IMAG(Y, iy) += temp1_imag * Aii_real;
117 for (j = j_min; j < j_max; j++) {
118 BASE Aij_real = CONST_REAL(Ap, TPLO(N, i, j));
119 BASE Aij_imag = conj * CONST_IMAG(Ap, TPLO(N, i, j));
120 REAL(Y, jy) += temp1_real * Aij_real - temp1_imag * (-Aij_imag);
121 IMAG(Y, jy) += temp1_real * (-Aij_imag) + temp1_imag * Aij_real;
122 x_real = CONST_REAL(X, jx);
123 x_imag = CONST_IMAG(X, jx);
124 temp2_real += x_real * Aij_real - x_imag * Aij_imag;
125 temp2_imag += x_real * Aij_imag + x_imag * Aij_real;
129 REAL(Y, iy) += alpha_real * temp2_real - alpha_imag * temp2_imag;
130 IMAG(Y, iy) += alpha_real * temp2_imag + alpha_imag * temp2_real;
136 BLAS_ERROR("unrecognized operation");