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 if (alpha_real == 0.0 && alpha_imag == 0.0)
30 if ((order == CblasRowMajor && Uplo == CblasUpper)
31 || (order == CblasColMajor && Uplo == CblasLower)) {
32 INDEX ix = OFFSET(N, incX);
33 INDEX iy = OFFSET(N, incY);
34 for (i = 0; i < N; i++) {
35 const BASE Xi_real = CONST_REAL(X, ix);
36 const BASE Xi_imag = CONST_IMAG(X, ix);
38 const BASE tmp1_real = alpha_real * Xi_real - alpha_imag * Xi_imag;
39 const BASE tmp1_imag = alpha_imag * Xi_real + alpha_real * Xi_imag;
41 const BASE Yi_real = CONST_REAL(Y, iy);
42 const BASE Yi_imag = CONST_IMAG(Y, iy);
43 /* tmp2 = conj(alpha) Yi */
44 const BASE tmp2_real = alpha_real * Yi_real + alpha_imag * Yi_imag;
45 const BASE tmp2_imag = -alpha_imag * Yi_real + alpha_real * Yi_imag;
50 /* Aij = alpha*Xi*conj(Yj) + conj(alpha)*Yi*conj(Xj) */
52 REAL(Ap, TPUP(N, i, i)) += 2 * (tmp1_real * Yi_real + tmp1_imag * Yi_imag);
53 IMAG(Ap, TPUP(N, i, i)) = 0;
55 for (j = i + 1; j < N; j++) {
56 const BASE Xj_real = CONST_REAL(X, jx);
57 const BASE Xj_imag = CONST_IMAG(X, jx);
58 const BASE Yj_real = CONST_REAL(Y, jy);
59 const BASE Yj_imag = CONST_IMAG(Y, jy);
60 REAL(Ap, TPUP(N, i, j)) += ((tmp1_real * Yj_real + tmp1_imag * Yj_imag)
61 + (tmp2_real * Xj_real + tmp2_imag * Xj_imag));
62 IMAG(Ap, TPUP(N, i, j)) +=
63 conj * ((tmp1_imag * Yj_real - tmp1_real * Yj_imag) +
64 (tmp2_imag * Xj_real - tmp2_real * Xj_imag));
71 } else if ((order == CblasRowMajor && Uplo == CblasLower)
72 || (order == CblasColMajor && Uplo == CblasUpper)) {
74 INDEX ix = OFFSET(N, incX);
75 INDEX iy = OFFSET(N, incY);
76 for (i = 0; i < N; i++) {
77 const BASE Xi_real = CONST_REAL(X, ix);
78 const BASE Xi_imag = CONST_IMAG(X, ix);
79 const BASE tmp1_real = alpha_real * Xi_real - alpha_imag * Xi_imag;
80 const BASE tmp1_imag = alpha_imag * Xi_real + alpha_real * Xi_imag;
82 const BASE Yi_real = CONST_REAL(Y, iy);
83 const BASE Yi_imag = CONST_IMAG(Y, iy);
84 const BASE tmp2_real = alpha_real * Yi_real + alpha_imag * Yi_imag;
85 const BASE tmp2_imag = -alpha_imag * Yi_real + alpha_real * Yi_imag;
87 INDEX jx = OFFSET(N, incX);
88 INDEX jy = OFFSET(N, incY);
90 /* Aij = alpha*Xi*conj(Yj) + conj(alpha)*Yi*conj(Xj) */
92 for (j = 0; j < i; j++) {
93 const BASE Xj_real = CONST_REAL(X, jx);
94 const BASE Xj_imag = CONST_IMAG(X, jx);
95 const BASE Yj_real = CONST_REAL(Y, jy);
96 const BASE Yj_imag = CONST_IMAG(Y, jy);
97 REAL(Ap, TPLO(N, i, j)) += ((tmp1_real * Yj_real + tmp1_imag * Yj_imag)
98 + (tmp2_real * Xj_real + tmp2_imag * Xj_imag));
99 IMAG(Ap, TPLO(N, i, j)) +=
100 conj * ((tmp1_imag * Yj_real - tmp1_real * Yj_imag) +
101 (tmp2_imag * Xj_real - tmp2_real * Xj_imag));
106 REAL(Ap, TPLO(N, i, i)) += 2 * (tmp1_real * Yi_real + tmp1_imag * Yi_imag);
107 IMAG(Ap, TPLO(N, i, i)) = 0;
113 BLAS_ERROR("unrecognized operation");