1 /* blas/source_gbmv_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.
22 INDEX lenX, lenY, L, U;
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) {
49 /* form y := beta*y */
50 if (beta_real == 0.0 && beta_imag == 0.0) {
51 INDEX iy = OFFSET(lenY, incY);
52 for (i = 0; i < lenY; i++) {
57 } else if (!(beta_real == 1.0 && beta_imag == 0.0)) {
58 INDEX iy = OFFSET(lenY, incY);
59 for (i = 0; i < lenY; i++) {
60 const BASE y_real = REAL(Y, iy);
61 const BASE y_imag = IMAG(Y, iy);
62 const BASE tmpR = y_real * beta_real - y_imag * beta_imag;
63 const BASE tmpI = y_real * beta_imag + y_imag * beta_real;
70 if (alpha_real == 0.0 && alpha_imag == 0.0)
73 if ((order == CblasRowMajor && TransA == CblasNoTrans)
74 || (order == CblasColMajor && TransA == CblasTrans)) {
75 /* form y := alpha*A*x + y */
76 INDEX iy = OFFSET(lenY, incY);
77 for (i = 0; i < lenY; i++) {
80 const INDEX j_min = (i > L ? i - L : 0);
81 const INDEX j_max = GSL_MIN(lenX, i + U + 1);
82 INDEX ix = OFFSET(lenX, incX) + j_min * incX;
83 for (j = j_min; j < j_max; j++) {
84 const BASE x_real = CONST_REAL(X, ix);
85 const BASE x_imag = CONST_IMAG(X, ix);
86 const BASE A_real = CONST_REAL(A, lda * i + (L + j - i));
87 const BASE A_imag = CONST_IMAG(A, lda * i + (L + j - i));
89 dotR += A_real * x_real - A_imag * x_imag;
90 dotI += A_real * x_imag + A_imag * x_real;
94 REAL(Y, iy) += alpha_real * dotR - alpha_imag * dotI;
95 IMAG(Y, iy) += alpha_real * dotI + alpha_imag * dotR;
98 } else if ((order == CblasRowMajor && TransA == CblasTrans)
99 || (order == CblasColMajor && TransA == CblasNoTrans)) {
100 /* form y := alpha*A'*x + y */
101 INDEX ix = OFFSET(lenX, incX);
102 for (j = 0; j < lenX; j++) {
103 const BASE x_real = CONST_REAL(X, ix);
104 const BASE x_imag = CONST_IMAG(X, ix);
105 BASE tmpR = alpha_real * x_real - alpha_imag * x_imag;
106 BASE tmpI = alpha_real * x_imag + alpha_imag * x_real;
107 if (!(tmpR == 0.0 && tmpI == 0.0)) {
108 const INDEX i_min = (j > U ? j - U : 0);
109 const INDEX i_max = GSL_MIN(lenY, j + L + 1);
110 INDEX iy = OFFSET(lenY, incY) + i_min * incY;
111 for (i = i_min; i < i_max; i++) {
112 const BASE A_real = CONST_REAL(A, lda * j + (U + i - j));
113 const BASE A_imag = CONST_IMAG(A, lda * j + (U + i - j));
114 REAL(Y, iy) += A_real * tmpR - A_imag * tmpI;
115 IMAG(Y, iy) += A_real * tmpI + A_imag * tmpR;
121 } else if (order == CblasRowMajor && TransA == CblasConjTrans) {
122 /* form y := alpha*A^H*x + y */
123 INDEX ix = OFFSET(lenX, incX);
124 for (j = 0; j < lenX; j++) {
125 const BASE x_real = CONST_REAL(X, ix);
126 const BASE x_imag = CONST_IMAG(X, ix);
127 BASE tmpR = alpha_real * x_real - alpha_imag * x_imag;
128 BASE tmpI = alpha_real * x_imag + alpha_imag * x_real;
129 if (!(tmpR == 0.0 && tmpI == 0.0)) {
130 const INDEX i_min = (j > U ? j - U : 0);
131 const INDEX i_max = GSL_MIN(lenY, j + L + 1);
132 INDEX iy = OFFSET(lenY, incY) + i_min * incY;
133 for (i = i_min; i < i_max; i++) {
134 const BASE A_real = CONST_REAL(A, lda * j + (U + i - j));
135 const BASE A_imag = CONST_IMAG(A, lda * j + (U + i - j));
136 REAL(Y, iy) += A_real * tmpR - (-A_imag) * tmpI;
137 IMAG(Y, iy) += A_real * tmpI + (-A_imag) * tmpR;
143 } else if (order == CblasColMajor && TransA == CblasConjTrans) {
144 /* form y := alpha*A^H*x + y */
145 INDEX iy = OFFSET(lenY, incY);
146 for (i = 0; i < lenY; i++) {
149 const INDEX j_min = (i > L ? i - L : 0);
150 const INDEX j_max = GSL_MIN(lenX, i + U + 1);
151 INDEX ix = OFFSET(lenX, incX) + j_min * incX;
152 for (j = j_min; j < j_max; j++) {
153 const BASE x_real = CONST_REAL(X, ix);
154 const BASE x_imag = CONST_IMAG(X, ix);
155 const BASE A_real = CONST_REAL(A, lda * i + (L + j - i));
156 const BASE A_imag = CONST_IMAG(A, lda * i + (L + j - i));
158 dotR += A_real * x_real - (-A_imag) * x_imag;
159 dotI += A_real * x_imag + (-A_imag) * x_real;
163 REAL(Y, iy) += alpha_real * dotR - alpha_imag * dotI;
164 IMAG(Y, iy) += alpha_real * dotI + alpha_imag * dotR;
168 BLAS_ERROR("unrecognized operation");