Added script front-end for primer-design code
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / cblas / source_gemv_c.h
1 /* blas/source_gemv_c.h
2  * 
3  * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
4  * 
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.
9  * 
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.
14  * 
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.
18  */
19
20 {
21   INDEX i, j;
22   INDEX lenX, lenY;
23
24   const BASE alpha_real = CONST_REAL0(alpha);
25   const BASE alpha_imag = CONST_IMAG0(alpha);
26
27   const BASE beta_real = CONST_REAL0(beta);
28   const BASE beta_imag = CONST_IMAG0(beta);
29
30   if (M == 0 || N == 0)
31     return;
32
33   if ((alpha_real == 0.0 && alpha_imag == 0.0)
34       && (beta_real == 1.0 && beta_imag == 0.0))
35     return;
36
37   if (TransA == CblasNoTrans) {
38     lenX = N;
39     lenY = M;
40   } else {
41     lenX = M;
42     lenY = N;
43   }
44
45   /* form  y := beta*y */
46
47   if (beta_real == 0.0 && beta_imag == 0.0) {
48     INDEX iy = OFFSET(lenY, incY);
49     for (i = 0; i < lenY; i++) {
50       REAL(Y, iy) = 0.0;
51       IMAG(Y, iy) = 0.0;
52       iy += incY;
53     }
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;
61       REAL(Y, iy) = tmpR;
62       IMAG(Y, iy) = tmpI;
63       iy += incY;
64     }
65   }
66
67   if (alpha_real == 0.0 && alpha_imag == 0.0)
68     return;
69
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++) {
75       BASE dotR = 0.0;
76       BASE dotI = 0.0;
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);
83
84         dotR += A_real * x_real - A_imag * x_imag;
85         dotI += A_real * x_imag + A_imag * x_real;
86         ix += incX;
87       }
88
89       REAL(Y, iy) += alpha_real * dotR - alpha_imag * dotI;
90       IMAG(Y, iy) += alpha_real * dotI + alpha_imag * dotR;
91       iy += incY;
92     }
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;
102
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;
109         iy += incY;
110       }
111       ix += incX;
112     }
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;
121
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;
128         iy += incY;
129       }
130       ix += incX;
131     }
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++) {
136       BASE dotR = 0.0;
137       BASE dotI = 0.0;
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);
144
145         dotR += A_real * x_real - (-A_imag) * x_imag;
146         dotI += A_real * x_imag + (-A_imag) * x_real;
147         ix += incX;
148       }
149
150       REAL(Y, iy) += alpha_real * dotR - alpha_imag * dotI;
151       IMAG(Y, iy) += alpha_real * dotI + alpha_imag * dotR;
152       iy += incY;
153     }
154   } else {
155     BLAS_ERROR("unrecognized operation");
156   }
157
158 }