1 /* blas/source_tbsv_r.h
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000 Gerard Jungman
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.
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.
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.
21 const int nonunit = (Diag == CblasNonUnit);
23 const int Trans = (TransA != CblasConjTrans) ? TransA : CblasTrans;
28 /* form x := inv( A )*x */
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 for (i = N; i > 0 && i--;) {
36 const INDEX j_min = i + 1;
37 const INDEX j_max = GSL_MIN(N, i + K + 1);
38 INDEX jx = OFFSET(N, incX) + j_min * incX;
39 for (j = j_min; j < j_max; j++) {
40 const BASE Aij = A[lda * i + (j - i)];
45 X[ix] = tmp / A[lda * i + 0];
51 } else if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasLower)
52 || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasUpper)) {
54 /* forward substitution */
55 INDEX ix = OFFSET(N, incX);
57 for (i = 0; i < N; i++) {
59 const INDEX j_min = (i > K ? i - K : 0);
60 const INDEX j_max = i;
61 INDEX jx = OFFSET(N, incX) + j_min * incX;
62 for (j = j_min; j < j_max; j++) {
63 const BASE Aij = A[lda * i + (K + j - i)];
68 X[ix] = tmp / A[lda * i + K];
74 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasUpper)
75 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasLower)) {
77 /* form x := inv( A' )*x */
79 /* forward substitution */
80 INDEX ix = OFFSET(N, incX);
81 for (i = 0; i < N; i++) {
83 const INDEX j_min = (K > i ? 0 : i - K);
84 const INDEX j_max = i;
85 INDEX jx = OFFSET(N, incX) + j_min * incX;
86 for (j = j_min; j < j_max; j++) {
87 const BASE Aji = A[(i - j) + lda * j];
92 X[ix] = tmp / A[0 + lda * i];
98 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasLower)
99 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasUpper)) {
101 /* backsubstitution */
102 INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
103 for (i = N; i > 0 && i--;) {
105 const INDEX j_min = i + 1;
106 const INDEX j_max = GSL_MIN(N, i + K + 1);
107 INDEX jx = OFFSET(N, incX) + j_min * incX;
108 for (j = j_min; j < j_max; j++) {
109 const BASE Aji = A[(K + i - j) + lda * j];
114 X[ix] = tmp / A[K + lda * i];
121 BLAS_ERROR("unrecognized operation");