1 /* blas/source_gemv_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.
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);
33 if ((alpha_real == 0.0 && alpha_imag == 0.0)
34 && (beta_real == 1.0 && beta_imag == 0.0))
37 if (TransA == CblasNoTrans) {
45 /* form y := beta*y */
47 if (beta_real == 0.0 && beta_imag == 0.0) {
48 INDEX iy = OFFSET(lenY, incY);
49 for (i = 0; i < lenY; i++) {
54 } else if (!(beta_real == 1.0 && beta_imag == 0.0)) {
55 INDEX iy = OFFSET(lenY, incY);
56 for (i = 0; i < lenY; i++) {
57 const BASE y_real = REAL(Y, iy);
58 const BASE y_imag = IMAG(Y, iy);
59 const BASE tmpR = y_real * beta_real - y_imag * beta_imag;
60 const BASE tmpI = y_real * beta_imag + y_imag * beta_real;
67 if (alpha_real == 0.0 && alpha_imag == 0.0)
70 if ((order == CblasRowMajor && TransA == CblasNoTrans)
71 || (order == CblasColMajor && TransA == CblasTrans)) {
72 /* form y := alpha*A*x + y */
73 INDEX iy = OFFSET(lenY, incY);
74 for (i = 0; i < lenY; i++) {
77 INDEX ix = OFFSET(lenX, incX);
78 for (j = 0; j < lenX; j++) {
79 const BASE x_real = CONST_REAL(X, ix);
80 const BASE x_imag = CONST_IMAG(X, ix);
81 const BASE A_real = CONST_REAL(A, lda * i + j);
82 const BASE A_imag = CONST_IMAG(A, lda * i + j);
84 dotR += A_real * x_real - A_imag * x_imag;
85 dotI += A_real * x_imag + A_imag * x_real;
89 REAL(Y, iy) += alpha_real * dotR - alpha_imag * dotI;
90 IMAG(Y, iy) += alpha_real * dotI + alpha_imag * dotR;
93 } else if ((order == CblasRowMajor && TransA == CblasTrans)
94 || (order == CblasColMajor && TransA == CblasNoTrans)) {
95 /* form y := alpha*A'*x + y */
96 INDEX ix = OFFSET(lenX, incX);
97 for (j = 0; j < lenX; j++) {
98 BASE x_real = CONST_REAL(X, ix);
99 BASE x_imag = CONST_IMAG(X, ix);
100 BASE tmpR = alpha_real * x_real - alpha_imag * x_imag;
101 BASE tmpI = alpha_real * x_imag + alpha_imag * x_real;
103 INDEX iy = OFFSET(lenY, incY);
104 for (i = 0; i < lenY; i++) {
105 const BASE A_real = CONST_REAL(A, lda * j + i);
106 const BASE A_imag = CONST_IMAG(A, lda * j + i);
107 REAL(Y, iy) += A_real * tmpR - A_imag * tmpI;
108 IMAG(Y, iy) += A_real * tmpI + A_imag * tmpR;
113 } else if (order == CblasRowMajor && TransA == CblasConjTrans) {
114 /* form y := alpha*A^H*x + y */
115 INDEX ix = OFFSET(lenX, incX);
116 for (j = 0; j < lenX; j++) {
117 BASE x_real = CONST_REAL(X, ix);
118 BASE x_imag = CONST_IMAG(X, ix);
119 BASE tmpR = alpha_real * x_real - alpha_imag * x_imag;
120 BASE tmpI = alpha_real * x_imag + alpha_imag * x_real;
122 INDEX iy = OFFSET(lenY, incY);
123 for (i = 0; i < lenY; i++) {
124 const BASE A_real = CONST_REAL(A, lda * j + i);
125 const BASE A_imag = CONST_IMAG(A, lda * j + i);
126 REAL(Y, iy) += A_real * tmpR - (-A_imag) * tmpI;
127 IMAG(Y, iy) += A_real * tmpI + (-A_imag) * tmpR;
132 } else if (order == CblasColMajor && TransA == CblasConjTrans) {
133 /* form y := alpha*A^H*x + y */
134 INDEX iy = OFFSET(lenY, incY);
135 for (i = 0; i < lenY; i++) {
138 INDEX ix = OFFSET(lenX, incX);
139 for (j = 0; j < lenX; j++) {
140 const BASE x_real = CONST_REAL(X, ix);
141 const BASE x_imag = CONST_IMAG(X, ix);
142 const BASE A_real = CONST_REAL(A, lda * i + j);
143 const BASE A_imag = CONST_IMAG(A, lda * i + j);
145 dotR += A_real * x_real - (-A_imag) * x_imag;
146 dotI += A_real * x_imag + (-A_imag) * x_real;
150 REAL(Y, iy) += alpha_real * dotR - alpha_imag * dotI;
151 IMAG(Y, iy) += alpha_real * dotI + alpha_imag * dotR;
155 BLAS_ERROR("unrecognized operation");