annotate ext/clapack/src/dtrti2.c @ 497:0d3a001e63c7

Another range fix... sigh
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 03 Jun 2019 11:45:49 +0100
parents 905e45637745
children
rev   line source
c@427 1 /* dtrti2.f -- translated by f2c (version 20061008).
c@427 2 You must link the resulting object file with libf2c:
c@427 3 on Microsoft Windows system, link with libf2c.lib;
c@427 4 on Linux or Unix systems, link with .../path/to/libf2c.a -lm
c@427 5 or, if you install libf2c.a in a standard place, with -lf2c -lm
c@427 6 -- in that order, at the end of the command line, as in
c@427 7 cc *.o -lf2c -lm
c@427 8 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
c@427 9
c@427 10 http://www.netlib.org/f2c/libf2c.zip
c@427 11 */
c@427 12
c@427 13 #include "f2c.h"
c@427 14 #include "blaswrap.h"
c@427 15
c@427 16 /* Table of constant values */
c@427 17
c@427 18 static integer c__1 = 1;
c@427 19
c@427 20 /* Subroutine */ int dtrti2_(char *uplo, char *diag, integer *n, doublereal *
c@427 21 a, integer *lda, integer *info)
c@427 22 {
c@427 23 /* System generated locals */
c@427 24 integer a_dim1, a_offset, i__1, i__2;
c@427 25
c@427 26 /* Local variables */
c@427 27 integer j;
c@427 28 doublereal ajj;
c@427 29 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
c@427 30 integer *);
c@427 31 extern logical lsame_(char *, char *);
c@427 32 logical upper;
c@427 33 extern /* Subroutine */ int dtrmv_(char *, char *, char *, integer *,
c@427 34 doublereal *, integer *, doublereal *, integer *), xerbla_(char *, integer *);
c@427 35 logical nounit;
c@427 36
c@427 37
c@427 38 /* -- LAPACK routine (version 3.2) -- */
c@427 39 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
c@427 40 /* November 2006 */
c@427 41
c@427 42 /* .. Scalar Arguments .. */
c@427 43 /* .. */
c@427 44 /* .. Array Arguments .. */
c@427 45 /* .. */
c@427 46
c@427 47 /* Purpose */
c@427 48 /* ======= */
c@427 49
c@427 50 /* DTRTI2 computes the inverse of a real upper or lower triangular */
c@427 51 /* matrix. */
c@427 52
c@427 53 /* This is the Level 2 BLAS version of the algorithm. */
c@427 54
c@427 55 /* Arguments */
c@427 56 /* ========= */
c@427 57
c@427 58 /* UPLO (input) CHARACTER*1 */
c@427 59 /* Specifies whether the matrix A is upper or lower triangular. */
c@427 60 /* = 'U': Upper triangular */
c@427 61 /* = 'L': Lower triangular */
c@427 62
c@427 63 /* DIAG (input) CHARACTER*1 */
c@427 64 /* Specifies whether or not the matrix A is unit triangular. */
c@427 65 /* = 'N': Non-unit triangular */
c@427 66 /* = 'U': Unit triangular */
c@427 67
c@427 68 /* N (input) INTEGER */
c@427 69 /* The order of the matrix A. N >= 0. */
c@427 70
c@427 71 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
c@427 72 /* On entry, the triangular matrix A. If UPLO = 'U', the */
c@427 73 /* leading n by n upper triangular part of the array A contains */
c@427 74 /* the upper triangular matrix, and the strictly lower */
c@427 75 /* triangular part of A is not referenced. If UPLO = 'L', the */
c@427 76 /* leading n by n lower triangular part of the array A contains */
c@427 77 /* the lower triangular matrix, and the strictly upper */
c@427 78 /* triangular part of A is not referenced. If DIAG = 'U', the */
c@427 79 /* diagonal elements of A are also not referenced and are */
c@427 80 /* assumed to be 1. */
c@427 81
c@427 82 /* On exit, the (triangular) inverse of the original matrix, in */
c@427 83 /* the same storage format. */
c@427 84
c@427 85 /* LDA (input) INTEGER */
c@427 86 /* The leading dimension of the array A. LDA >= max(1,N). */
c@427 87
c@427 88 /* INFO (output) INTEGER */
c@427 89 /* = 0: successful exit */
c@427 90 /* < 0: if INFO = -k, the k-th argument had an illegal value */
c@427 91
c@427 92 /* ===================================================================== */
c@427 93
c@427 94 /* .. Parameters .. */
c@427 95 /* .. */
c@427 96 /* .. Local Scalars .. */
c@427 97 /* .. */
c@427 98 /* .. External Functions .. */
c@427 99 /* .. */
c@427 100 /* .. External Subroutines .. */
c@427 101 /* .. */
c@427 102 /* .. Intrinsic Functions .. */
c@427 103 /* .. */
c@427 104 /* .. Executable Statements .. */
c@427 105
c@427 106 /* Test the input parameters. */
c@427 107
c@427 108 /* Parameter adjustments */
c@427 109 a_dim1 = *lda;
c@427 110 a_offset = 1 + a_dim1;
c@427 111 a -= a_offset;
c@427 112
c@427 113 /* Function Body */
c@427 114 *info = 0;
c@427 115 upper = lsame_(uplo, "U");
c@427 116 nounit = lsame_(diag, "N");
c@427 117 if (! upper && ! lsame_(uplo, "L")) {
c@427 118 *info = -1;
c@427 119 } else if (! nounit && ! lsame_(diag, "U")) {
c@427 120 *info = -2;
c@427 121 } else if (*n < 0) {
c@427 122 *info = -3;
c@427 123 } else if (*lda < max(1,*n)) {
c@427 124 *info = -5;
c@427 125 }
c@427 126 if (*info != 0) {
c@427 127 i__1 = -(*info);
c@427 128 xerbla_("DTRTI2", &i__1);
c@427 129 return 0;
c@427 130 }
c@427 131
c@427 132 if (upper) {
c@427 133
c@427 134 /* Compute inverse of upper triangular matrix. */
c@427 135
c@427 136 i__1 = *n;
c@427 137 for (j = 1; j <= i__1; ++j) {
c@427 138 if (nounit) {
c@427 139 a[j + j * a_dim1] = 1. / a[j + j * a_dim1];
c@427 140 ajj = -a[j + j * a_dim1];
c@427 141 } else {
c@427 142 ajj = -1.;
c@427 143 }
c@427 144
c@427 145 /* Compute elements 1:j-1 of j-th column. */
c@427 146
c@427 147 i__2 = j - 1;
c@427 148 dtrmv_("Upper", "No transpose", diag, &i__2, &a[a_offset], lda, &
c@427 149 a[j * a_dim1 + 1], &c__1);
c@427 150 i__2 = j - 1;
c@427 151 dscal_(&i__2, &ajj, &a[j * a_dim1 + 1], &c__1);
c@427 152 /* L10: */
c@427 153 }
c@427 154 } else {
c@427 155
c@427 156 /* Compute inverse of lower triangular matrix. */
c@427 157
c@427 158 for (j = *n; j >= 1; --j) {
c@427 159 if (nounit) {
c@427 160 a[j + j * a_dim1] = 1. / a[j + j * a_dim1];
c@427 161 ajj = -a[j + j * a_dim1];
c@427 162 } else {
c@427 163 ajj = -1.;
c@427 164 }
c@427 165 if (j < *n) {
c@427 166
c@427 167 /* Compute elements j+1:n of j-th column. */
c@427 168
c@427 169 i__1 = *n - j;
c@427 170 dtrmv_("Lower", "No transpose", diag, &i__1, &a[j + 1 + (j +
c@427 171 1) * a_dim1], lda, &a[j + 1 + j * a_dim1], &c__1);
c@427 172 i__1 = *n - j;
c@427 173 dscal_(&i__1, &ajj, &a[j + 1 + j * a_dim1], &c__1);
c@427 174 }
c@427 175 /* L20: */
c@427 176 }
c@427 177 }
c@427 178
c@427 179 return 0;
c@427 180
c@427 181 /* End of DTRTI2 */
c@427 182
c@427 183 } /* dtrti2_ */