annotate ext/clapack/src/dtrtri.c @ 468:a72d98f8baa3

Revise mechanism for extending chromagram to round number of octaves - do it only in the chromagram itself, so that we can still create deviant constant-Q spectrograms if desired
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 30 May 2019 11:35:35 +0100
parents 905e45637745
children
rev   line source
c@427 1 /* dtrtri.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 static integer c_n1 = -1;
c@427 20 static integer c__2 = 2;
c@427 21 static doublereal c_b18 = 1.;
c@427 22 static doublereal c_b22 = -1.;
c@427 23
c@427 24 /* Subroutine */ int dtrtri_(char *uplo, char *diag, integer *n, doublereal *
c@427 25 a, integer *lda, integer *info)
c@427 26 {
c@427 27 /* System generated locals */
c@427 28 address a__1[2];
c@427 29 integer a_dim1, a_offset, i__1, i__2[2], i__3, i__4, i__5;
c@427 30 char ch__1[2];
c@427 31
c@427 32 /* Builtin functions */
c@427 33 /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
c@427 34
c@427 35 /* Local variables */
c@427 36 integer j, jb, nb, nn;
c@427 37 extern logical lsame_(char *, char *);
c@427 38 extern /* Subroutine */ int dtrmm_(char *, char *, char *, char *,
c@427 39 integer *, integer *, doublereal *, doublereal *, integer *,
c@427 40 doublereal *, integer *), dtrsm_(
c@427 41 char *, char *, char *, char *, integer *, integer *, doublereal *
c@427 42 , doublereal *, integer *, doublereal *, integer *);
c@427 43 logical upper;
c@427 44 extern /* Subroutine */ int dtrti2_(char *, char *, integer *, doublereal
c@427 45 *, integer *, integer *), xerbla_(char *, integer
c@427 46 *);
c@427 47 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
c@427 48 integer *, integer *);
c@427 49 logical nounit;
c@427 50
c@427 51
c@427 52 /* -- LAPACK routine (version 3.2) -- */
c@427 53 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
c@427 54 /* November 2006 */
c@427 55
c@427 56 /* .. Scalar Arguments .. */
c@427 57 /* .. */
c@427 58 /* .. Array Arguments .. */
c@427 59 /* .. */
c@427 60
c@427 61 /* Purpose */
c@427 62 /* ======= */
c@427 63
c@427 64 /* DTRTRI computes the inverse of a real upper or lower triangular */
c@427 65 /* matrix A. */
c@427 66
c@427 67 /* This is the Level 3 BLAS version of the algorithm. */
c@427 68
c@427 69 /* Arguments */
c@427 70 /* ========= */
c@427 71
c@427 72 /* UPLO (input) CHARACTER*1 */
c@427 73 /* = 'U': A is upper triangular; */
c@427 74 /* = 'L': A is lower triangular. */
c@427 75
c@427 76 /* DIAG (input) CHARACTER*1 */
c@427 77 /* = 'N': A is non-unit triangular; */
c@427 78 /* = 'U': A is unit triangular. */
c@427 79
c@427 80 /* N (input) INTEGER */
c@427 81 /* The order of the matrix A. N >= 0. */
c@427 82
c@427 83 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
c@427 84 /* On entry, the triangular matrix A. If UPLO = 'U', the */
c@427 85 /* leading N-by-N upper triangular part of the array A contains */
c@427 86 /* the upper triangular matrix, and the strictly lower */
c@427 87 /* triangular part of A is not referenced. If UPLO = 'L', the */
c@427 88 /* leading N-by-N lower triangular part of the array A contains */
c@427 89 /* the lower triangular matrix, and the strictly upper */
c@427 90 /* triangular part of A is not referenced. If DIAG = 'U', the */
c@427 91 /* diagonal elements of A are also not referenced and are */
c@427 92 /* assumed to be 1. */
c@427 93 /* On exit, the (triangular) inverse of the original matrix, in */
c@427 94 /* the same storage format. */
c@427 95
c@427 96 /* LDA (input) INTEGER */
c@427 97 /* The leading dimension of the array A. LDA >= max(1,N). */
c@427 98
c@427 99 /* INFO (output) INTEGER */
c@427 100 /* = 0: successful exit */
c@427 101 /* < 0: if INFO = -i, the i-th argument had an illegal value */
c@427 102 /* > 0: if INFO = i, A(i,i) is exactly zero. The triangular */
c@427 103 /* matrix is singular and its inverse can not be computed. */
c@427 104
c@427 105 /* ===================================================================== */
c@427 106
c@427 107 /* .. Parameters .. */
c@427 108 /* .. */
c@427 109 /* .. Local Scalars .. */
c@427 110 /* .. */
c@427 111 /* .. External Functions .. */
c@427 112 /* .. */
c@427 113 /* .. External Subroutines .. */
c@427 114 /* .. */
c@427 115 /* .. Intrinsic Functions .. */
c@427 116 /* .. */
c@427 117 /* .. Executable Statements .. */
c@427 118
c@427 119 /* Test the input parameters. */
c@427 120
c@427 121 /* Parameter adjustments */
c@427 122 a_dim1 = *lda;
c@427 123 a_offset = 1 + a_dim1;
c@427 124 a -= a_offset;
c@427 125
c@427 126 /* Function Body */
c@427 127 *info = 0;
c@427 128 upper = lsame_(uplo, "U");
c@427 129 nounit = lsame_(diag, "N");
c@427 130 if (! upper && ! lsame_(uplo, "L")) {
c@427 131 *info = -1;
c@427 132 } else if (! nounit && ! lsame_(diag, "U")) {
c@427 133 *info = -2;
c@427 134 } else if (*n < 0) {
c@427 135 *info = -3;
c@427 136 } else if (*lda < max(1,*n)) {
c@427 137 *info = -5;
c@427 138 }
c@427 139 if (*info != 0) {
c@427 140 i__1 = -(*info);
c@427 141 xerbla_("DTRTRI", &i__1);
c@427 142 return 0;
c@427 143 }
c@427 144
c@427 145 /* Quick return if possible */
c@427 146
c@427 147 if (*n == 0) {
c@427 148 return 0;
c@427 149 }
c@427 150
c@427 151 /* Check for singularity if non-unit. */
c@427 152
c@427 153 if (nounit) {
c@427 154 i__1 = *n;
c@427 155 for (*info = 1; *info <= i__1; ++(*info)) {
c@427 156 if (a[*info + *info * a_dim1] == 0.) {
c@427 157 return 0;
c@427 158 }
c@427 159 /* L10: */
c@427 160 }
c@427 161 *info = 0;
c@427 162 }
c@427 163
c@427 164 /* Determine the block size for this environment. */
c@427 165
c@427 166 /* Writing concatenation */
c@427 167 i__2[0] = 1, a__1[0] = uplo;
c@427 168 i__2[1] = 1, a__1[1] = diag;
c@427 169 s_cat(ch__1, a__1, i__2, &c__2, (ftnlen)2);
c@427 170 nb = ilaenv_(&c__1, "DTRTRI", ch__1, n, &c_n1, &c_n1, &c_n1);
c@427 171 if (nb <= 1 || nb >= *n) {
c@427 172
c@427 173 /* Use unblocked code */
c@427 174
c@427 175 dtrti2_(uplo, diag, n, &a[a_offset], lda, info);
c@427 176 } else {
c@427 177
c@427 178 /* Use blocked code */
c@427 179
c@427 180 if (upper) {
c@427 181
c@427 182 /* Compute inverse of upper triangular matrix */
c@427 183
c@427 184 i__1 = *n;
c@427 185 i__3 = nb;
c@427 186 for (j = 1; i__3 < 0 ? j >= i__1 : j <= i__1; j += i__3) {
c@427 187 /* Computing MIN */
c@427 188 i__4 = nb, i__5 = *n - j + 1;
c@427 189 jb = min(i__4,i__5);
c@427 190
c@427 191 /* Compute rows 1:j-1 of current block column */
c@427 192
c@427 193 i__4 = j - 1;
c@427 194 dtrmm_("Left", "Upper", "No transpose", diag, &i__4, &jb, &
c@427 195 c_b18, &a[a_offset], lda, &a[j * a_dim1 + 1], lda);
c@427 196 i__4 = j - 1;
c@427 197 dtrsm_("Right", "Upper", "No transpose", diag, &i__4, &jb, &
c@427 198 c_b22, &a[j + j * a_dim1], lda, &a[j * a_dim1 + 1],
c@427 199 lda);
c@427 200
c@427 201 /* Compute inverse of current diagonal block */
c@427 202
c@427 203 dtrti2_("Upper", diag, &jb, &a[j + j * a_dim1], lda, info);
c@427 204 /* L20: */
c@427 205 }
c@427 206 } else {
c@427 207
c@427 208 /* Compute inverse of lower triangular matrix */
c@427 209
c@427 210 nn = (*n - 1) / nb * nb + 1;
c@427 211 i__3 = -nb;
c@427 212 for (j = nn; i__3 < 0 ? j >= 1 : j <= 1; j += i__3) {
c@427 213 /* Computing MIN */
c@427 214 i__1 = nb, i__4 = *n - j + 1;
c@427 215 jb = min(i__1,i__4);
c@427 216 if (j + jb <= *n) {
c@427 217
c@427 218 /* Compute rows j+jb:n of current block column */
c@427 219
c@427 220 i__1 = *n - j - jb + 1;
c@427 221 dtrmm_("Left", "Lower", "No transpose", diag, &i__1, &jb,
c@427 222 &c_b18, &a[j + jb + (j + jb) * a_dim1], lda, &a[j
c@427 223 + jb + j * a_dim1], lda);
c@427 224 i__1 = *n - j - jb + 1;
c@427 225 dtrsm_("Right", "Lower", "No transpose", diag, &i__1, &jb,
c@427 226 &c_b22, &a[j + j * a_dim1], lda, &a[j + jb + j *
c@427 227 a_dim1], lda);
c@427 228 }
c@427 229
c@427 230 /* Compute inverse of current diagonal block */
c@427 231
c@427 232 dtrti2_("Lower", diag, &jb, &a[j + j * a_dim1], lda, info);
c@427 233 /* L30: */
c@427 234 }
c@427 235 }
c@427 236 }
c@427 237
c@427 238 return 0;
c@427 239
c@427 240 /* End of DTRTRI */
c@427 241
c@427 242 } /* dtrtri_ */