Debian Codegraph @

external/gsl/gsl_cblas__source_trsv_r.h

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