1 /* blas/source_tpsv_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.
22 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);
35 X[ix] = X[ix] / Ap[TPUP(N, (N - 1), (N - 1))];
38 for (i = N - 1; i > 0 && i--;) {
41 for (j = i + 1; j < N; j++) {
42 const BASE Aij = Ap[TPUP(N, i, j)];
47 X[ix] = tmp / Ap[TPUP(N, i, i)];
53 } else if ((order == CblasRowMajor && Trans == CblasNoTrans && Uplo == CblasLower)
54 || (order == CblasColMajor && Trans == CblasTrans && Uplo == CblasUpper)) {
56 /* forward substitution */
57 INDEX ix = OFFSET(N, incX);
59 X[ix] = X[ix] / Ap[TPLO(N, 0, 0)];
62 for (i = 1; i < N; i++) {
64 INDEX jx = OFFSET(N, incX);
65 for (j = 0; j < i; j++) {
66 const BASE Aij = Ap[TPLO(N, i, j)];
71 X[ix] = tmp / Ap[TPLO(N, i, j)];
77 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasUpper)
78 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasLower)) {
80 /* form x := inv( A' )*x */
82 /* forward substitution */
83 INDEX ix = OFFSET(N, incX);
85 X[ix] = X[ix] / Ap[TPUP(N, 0, 0)];
88 for (i = 1; i < N; i++) {
90 INDEX jx = OFFSET(N, incX);
91 for (j = 0; j < i; j++) {
92 const BASE Aji = Ap[TPUP(N, j, i)];
97 X[ix] = tmp / Ap[TPUP(N, i, i)];
103 } else if ((order == CblasRowMajor && Trans == CblasTrans && Uplo == CblasLower)
104 || (order == CblasColMajor && Trans == CblasNoTrans && Uplo == CblasUpper)) {
106 /* backsubstitution */
107 INDEX ix = OFFSET(N, incX) + (N - 1) * incX;
109 X[ix] = X[ix] / Ap[TPLO(N, (N - 1), (N - 1))];
112 for (i = N - 1; i > 0 && i--;) {
114 INDEX jx = ix + incX;
115 for (j = i + 1; j < N; j++) {
116 const BASE Aji = Ap[TPLO(N, j, i)];
121 X[ix] = tmp / Ap[TPLO(N, i, i)];
128 BLAS_ERROR("unrecognized operation");