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