Debian Codegraph @

external/gsl/gsl_cblas__source_tpsv_r.h

raw
1 /* blas/source_tpsv_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 /* form x := inv( A )*x */
29
30 if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasUpper)
31 || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasLower)) {
32 /* backsubstitution */
33 INDEX ix = OFFSET(N, incX) + incX * (N - 1);
34 if (nonunit) {
35 X[ix] = X[ix] / Ap[TPUP(N, (N - 1), (N - 1))];
36 }
37 ix -= incX;
38 for (i = N - 1; i > 0 && i--;) {
39 BASE tmp = X[ix];
40 INDEX jx = ix + incX;
41 for (j = i + 1; j < N; j++) {
42 const BASE Aij = Ap[TPUP(N, i, j)];
43 tmp -= Aij * X[jx];
44 jx += incX;
45 }
46 if (nonunit) {
47 X[ix] = tmp / Ap[TPUP(N, i, i)];
48 } else {
49 X[ix] = tmp;
50 }
51 ix -= incX;
52 }
53 } else if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasLower)
54 || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasUpper)) {
55
56 /* forward substitution */
57 INDEX ix = OFFSET(N, incX);
58 if (nonunit) {
59 X[ix] = X[ix] / Ap[TPLO(N, 0, 0)];
60 }
61 ix += incX;
62 for (i = 1; i < N; i++) {
63 BASE tmp = X[ix];
64 INDEX jx = OFFSET(N, incX);
65 for (j = 0; j < i; j++) {
66 const BASE Aij = Ap[TPLO(N, i, j)];
67 tmp -= Aij * X[jx];
68 jx += incX;
69 }
70 if (nonunit) {
71 X[ix] = tmp / Ap[TPLO(N, i, j)];
72 } else {
73 X[ix] = tmp;
74 }
75 ix += incX;
76 }
77 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasUpper)
78 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasLower)) {
79
80 /* form x := inv( A' )*x */
81
82 /* forward substitution */
83 INDEX ix = OFFSET(N, incX);
84 if (nonunit) {
85 X[ix] = X[ix] / Ap[TPUP(N, 0, 0)];
86 }
87 ix += incX;
88 for (i = 1; i < N; i++) {
89 BASE tmp = X[ix];
90 INDEX jx = OFFSET(N, incX);
91 for (j = 0; j < i; j++) {
92 const BASE Aji = Ap[TPUP(N, j, i)];
93 tmp -= Aji * X[jx];
94 jx += incX;
95 }
96 if (nonunit) {
97 X[ix] = tmp / Ap[TPUP(N, i, i)];
98 } else {
99 X[ix] = tmp;
100 }
101 ix += incX;
102 }
103 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasLower)
104 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasUpper)) {
105
106 /* backsubstitution */
107 INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
108 if (nonunit) {
109 X[ix] = X[ix] / Ap[TPLO(N, (N - 1), (N - 1))];
110 }
111 ix -= incX;
112 for (i = N - 1; i > 0 && i--;) {
113 BASE tmp = X[ix];
114 INDEX jx = ix + incX;
115 for (j = i + 1; j < N; j++) {
116 const BASE Aji = Ap[TPLO(N, j, i)];
117 tmp -= Aji * X[jx];
118 jx += incX;
119 }
120 if (nonunit) {
121 X[ix] = tmp / Ap[TPLO(N, i, i)];
122 } else {
123 X[ix] = tmp;
124 }
125 ix -= incX;
126 }
127 } else {
128 BLAS_ERROR("unrecognized operation");
129 }
130
131 }