Added MACS source
[htsworkflow.git] / htswanalysis / MACS / lib / gsl / gsl-1.11 / cblas / source_tbmv_r.h
1 /* blas/source_tbmv_r.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 nonunit = (Diag == CblasNonUnit);
23   const int Trans = (TransA != CblasConjTrans) ? TransA : CblasTrans;
24
25   if (N == 0)
26     return;
27
28   if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasUpper)
29       || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasLower)) {
30     /* form  x := A*x */
31
32     INDEX ix = OFFSET(N, incX);
33     for (i = 0; i < N; i++) {
34       BASE temp = (nonunit ? A[lda * i + 0] : 1.0) * X[ix];
35       const INDEX j_min = i + 1;
36       const INDEX j_max = GSL_MIN(N, i + K + 1);
37       INDEX jx = OFFSET(N, incX) + j_min * incX;
38
39       for (j = j_min; j < j_max; j++) {
40         temp += X[jx] * A[lda * i + (j - i)];
41         jx += incX;
42       }
43
44       X[ix] = temp;
45       ix += incX;
46     }
47   } else if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasLower)
48              || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasUpper)) {
49
50     INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
51     for (i = N; i > 0 && i--;) {
52       BASE temp = (nonunit ? A[lda * i + K] : 1.0) * X[ix];
53       const INDEX j_min = (i > K ? i - K : 0);
54       const INDEX j_max = i;
55       INDEX jx = OFFSET(N, incX) + j_min * incX;
56       for (j = j_min; j < j_max; j++) {
57         temp += X[jx] * A[lda * i + (K - i + j)];
58         jx += incX;
59       }
60       X[ix] = temp;
61       ix -= incX;
62     }
63
64   } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasUpper)
65              || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasLower)) {
66     /* form  x := A'*x */
67     INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
68
69     for (i = N; i > 0 && i--;) {
70       BASE temp = 0.0;
71       const INDEX j_min = (K > i ? 0 : i - K);
72       const INDEX j_max = i;
73       INDEX jx = OFFSET(N, incX) + j_min * incX;
74       for (j = j_min; j < j_max; j++) {
75         temp += X[jx] * A[lda * j + (i - j)];
76         jx += incX;
77       }
78       if (nonunit) {
79         X[ix] = temp + X[ix] * A[lda * i + 0];
80       } else {
81         X[ix] += temp;
82       }
83       ix -= incX;
84     }
85   } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasLower)
86              || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasUpper)) {
87
88     INDEX ix = OFFSET(N, incX);
89     for (i = 0; i < N; i++) {
90       BASE temp = 0.0;
91       const INDEX j_min = i + 1;
92       const INDEX j_max = GSL_MIN(N, i + K + 1);
93       INDEX jx = OFFSET(N, incX) + j_min * incX;
94       for (j = j_min; j < j_max; j++) {
95         temp += X[jx] * A[lda * j + (K - j + i)];
96         jx += incX;
97       }
98       if (nonunit) {
99         X[ix] = temp + X[ix] * A[lda * i + K];
100       } else {
101         X[ix] += temp;
102       }
103       ix += incX;
104     }
105   }
106 }