Added script front-end for primer-design code
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / cblas / source_hbmv.h
1 /* blas/source_hbmv.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   const int conj = (order == CblasColMajor) ? -1 : 1;
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 (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   /* form  y := beta*y */
38   if (beta_real == 0.0 && beta_imag == 0.0) {
39     INDEX iy = OFFSET(N, incY);
40     for (i = 0; i < N; i++) {
41       REAL(Y, iy) = 0.0;
42       IMAG(Y, iy) = 0.0;
43       iy += incY;
44     }
45   } else if (!(beta_real == 1.0 && beta_imag == 0.0)) {
46     INDEX iy = OFFSET(N, incY);
47     for (i = 0; i < N; i++) {
48       const BASE y_real = REAL(Y, iy);
49       const BASE y_imag = IMAG(Y, iy);
50       const BASE tmpR = y_real * beta_real - y_imag * beta_imag;
51       const BASE tmpI = y_real * beta_imag + y_imag * beta_real;
52       REAL(Y, iy) = tmpR;
53       IMAG(Y, iy) = tmpI;
54       iy += incY;
55     }
56   }
57
58   if (alpha_real == 0.0 && alpha_imag == 0.0)
59     return;
60
61   /* form  y := alpha*A*x + y */
62
63   if ((order == CblasRowMajor && Uplo == CblasUpper)
64       || (order == CblasColMajor && Uplo == CblasLower)) {
65     INDEX ix = OFFSET(N, incX);
66     INDEX iy = OFFSET(N, incY);
67     for (i = 0; i < N; i++) {
68       BASE x_real = CONST_REAL(X, ix);
69       BASE x_imag = CONST_IMAG(X, ix);
70       BASE temp1_real = alpha_real * x_real - alpha_imag * x_imag;
71       BASE temp1_imag = alpha_real * x_imag + alpha_imag * x_real;
72       BASE temp2_real = 0.0;
73       BASE temp2_imag = 0.0;
74       const INDEX j_min = i + 1;
75       const INDEX j_max = GSL_MIN(N, i + K + 1);
76       INDEX jx = OFFSET(N, incX) + j_min * incX;
77       INDEX jy = OFFSET(N, incY) + j_min * incY;
78       BASE Aii_real = CONST_REAL(A, lda * i + 0);
79       /* Aii_imag is zero */
80       REAL(Y, iy) += temp1_real * Aii_real;
81       IMAG(Y, iy) += temp1_imag * Aii_real;
82       for (j = j_min; j < j_max; j++) {
83         BASE Aij_real = CONST_REAL(A, lda * i + (j - i));
84         BASE Aij_imag = conj * CONST_IMAG(A, lda * i + (j - i));
85         REAL(Y, jy) += temp1_real * Aij_real - temp1_imag * (-Aij_imag);
86         IMAG(Y, jy) += temp1_real * (-Aij_imag) + temp1_imag * Aij_real;
87         x_real = CONST_REAL(X, jx);
88         x_imag = CONST_IMAG(X, jx);
89         temp2_real += x_real * Aij_real - x_imag * Aij_imag;
90         temp2_imag += x_real * Aij_imag + x_imag * Aij_real;
91         jx += incX;
92         jy += incY;
93       }
94       REAL(Y, iy) += alpha_real * temp2_real - alpha_imag * temp2_imag;
95       IMAG(Y, iy) += alpha_real * temp2_imag + alpha_imag * temp2_real;
96       ix += incX;
97       iy += incY;
98     }
99   } else if ((order == CblasRowMajor && Uplo == CblasLower)
100              || (order == CblasColMajor && Uplo == CblasUpper)) {
101     INDEX ix = OFFSET(N, incX);
102     INDEX iy = OFFSET(N, incY);
103     for (i = 0; i < N; i++) {
104       BASE x_real = CONST_REAL(X, ix);
105       BASE x_imag = CONST_IMAG(X, ix);
106       BASE temp1_real = alpha_real * x_real - alpha_imag * x_imag;
107       BASE temp1_imag = alpha_real * x_imag + alpha_imag * x_real;
108       BASE temp2_real = 0.0;
109       BASE temp2_imag = 0.0;
110       const INDEX j_min = (K > i ? 0 : i - K);
111       const INDEX j_max = i;
112       INDEX jx = OFFSET(N, incX) + j_min * incX;
113       INDEX jy = OFFSET(N, incY) + j_min * incY;
114
115       for (j = j_min; j < j_max; j++) {
116         BASE Aij_real = CONST_REAL(A, i * lda + (K - i + j));
117         BASE Aij_imag = conj * CONST_IMAG(A, i * lda + (K - i + j));
118         REAL(Y, jy) += temp1_real * Aij_real - temp1_imag * (-Aij_imag);
119         IMAG(Y, jy) += temp1_real * (-Aij_imag) + temp1_imag * Aij_real;
120         x_real = CONST_REAL(X, jx);
121         x_imag = CONST_IMAG(X, jx);
122         temp2_real += x_real * Aij_real - x_imag * Aij_imag;
123         temp2_imag += x_real * Aij_imag + x_imag * Aij_real;
124         jx += incX;
125         jy += incY;
126       }
127
128       {
129         BASE Aii_real = CONST_REAL(A, lda * i + K);
130         /* Aii_imag is zero */
131         REAL(Y, iy) += temp1_real * Aii_real;
132         IMAG(Y, iy) += temp1_imag * Aii_real;
133       }
134
135       REAL(Y, iy) += alpha_real * temp2_real - alpha_imag * temp2_imag;
136       IMAG(Y, iy) += alpha_real * temp2_imag + alpha_imag * temp2_real;
137       ix += incX;
138       iy += incY;
139     }
140
141   } else {
142     BLAS_ERROR("unrecognized operation");
143   }
144
145 }