1 /* blas/source_trsv_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);
24 const int Trans = (TransA != CblasConjTrans) ? TransA : CblasTrans;
29 /* form x := inv( A )*x */
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);
36 X[ix] = X[ix] / A[lda * (N - 1) + (N - 1)];
39 for (i = N - 1; i > 0 && i--;) {
42 for (j = i + 1; j < N; j++) {
43 const BASE Aij = A[lda * i + j];
48 X[ix] = tmp / A[lda * i + i];
54 } else if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasLower)
55 || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasUpper)) {
57 /* forward substitution */
60 X[ix] = X[ix] / A[lda * 0 + 0];
63 for (i = 1; i < N; i++) {
66 for (j = 0; j < i; j++) {
67 const BASE Aij = A[lda * i + j];
72 X[ix] = tmp / A[lda * i + i];
78 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasUpper)
79 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasLower)) {
81 /* form x := inv( A' )*x */
83 /* forward substitution */
86 X[ix] = X[ix] / A[lda * 0 + 0];
89 for (i = 1; i < N; i++) {
92 for (j = 0; j < i; j++) {
93 const BASE Aji = A[lda * j + i];
98 X[ix] = tmp / A[lda * i + i];
104 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasLower)
105 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasUpper)) {
107 /* backsubstitution */
108 ix = OFFSET(N, incX) + (N - 1) * incX;
110 X[ix] = X[ix] / A[lda * (N - 1) + (N - 1)];
113 for (i = N - 1; i > 0 && i--;) {
116 for (j = i + 1; j < N; j++) {
117 const BASE Aji = A[lda * j + i];
122 X[ix] = tmp / A[lda * i + i];
129 BLAS_ERROR("unrecognized operation");