00001 /* dtrti2.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Table of constant values */ 00017 00018 static integer c__1 = 1; 00019 00020 /* Subroutine */ int dtrti2_(char *uplo, char *diag, integer *n, doublereal * 00021 a, integer *lda, integer *info) 00022 { 00023 /* System generated locals */ 00024 integer a_dim1, a_offset, i__1, i__2; 00025 00026 /* Local variables */ 00027 integer j; 00028 doublereal ajj; 00029 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, 00030 integer *); 00031 extern logical lsame_(char *, char *); 00032 logical upper; 00033 extern /* Subroutine */ int dtrmv_(char *, char *, char *, integer *, 00034 doublereal *, integer *, doublereal *, integer *), xerbla_(char *, integer *); 00035 logical nounit; 00036 00037 00038 /* -- LAPACK routine (version 3.2) -- */ 00039 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00040 /* November 2006 */ 00041 00042 /* .. Scalar Arguments .. */ 00043 /* .. */ 00044 /* .. Array Arguments .. */ 00045 /* .. */ 00046 00047 /* Purpose */ 00048 /* ======= */ 00049 00050 /* DTRTI2 computes the inverse of a real upper or lower triangular */ 00051 /* matrix. */ 00052 00053 /* This is the Level 2 BLAS version of the algorithm. */ 00054 00055 /* Arguments */ 00056 /* ========= */ 00057 00058 /* UPLO (input) CHARACTER*1 */ 00059 /* Specifies whether the matrix A is upper or lower triangular. */ 00060 /* = 'U': Upper triangular */ 00061 /* = 'L': Lower triangular */ 00062 00063 /* DIAG (input) CHARACTER*1 */ 00064 /* Specifies whether or not the matrix A is unit triangular. */ 00065 /* = 'N': Non-unit triangular */ 00066 /* = 'U': Unit triangular */ 00067 00068 /* N (input) INTEGER */ 00069 /* The order of the matrix A. N >= 0. */ 00070 00071 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */ 00072 /* On entry, the triangular matrix A. If UPLO = 'U', the */ 00073 /* leading n by n upper triangular part of the array A contains */ 00074 /* the upper triangular matrix, and the strictly lower */ 00075 /* triangular part of A is not referenced. If UPLO = 'L', the */ 00076 /* leading n by n lower triangular part of the array A contains */ 00077 /* the lower triangular matrix, and the strictly upper */ 00078 /* triangular part of A is not referenced. If DIAG = 'U', the */ 00079 /* diagonal elements of A are also not referenced and are */ 00080 /* assumed to be 1. */ 00081 00082 /* On exit, the (triangular) inverse of the original matrix, in */ 00083 /* the same storage format. */ 00084 00085 /* LDA (input) INTEGER */ 00086 /* The leading dimension of the array A. LDA >= max(1,N). */ 00087 00088 /* INFO (output) INTEGER */ 00089 /* = 0: successful exit */ 00090 /* < 0: if INFO = -k, the k-th argument had an illegal value */ 00091 00092 /* ===================================================================== */ 00093 00094 /* .. Parameters .. */ 00095 /* .. */ 00096 /* .. Local Scalars .. */ 00097 /* .. */ 00098 /* .. External Functions .. */ 00099 /* .. */ 00100 /* .. External Subroutines .. */ 00101 /* .. */ 00102 /* .. Intrinsic Functions .. */ 00103 /* .. */ 00104 /* .. Executable Statements .. */ 00105 00106 /* Test the input parameters. */ 00107 00108 /* Parameter adjustments */ 00109 a_dim1 = *lda; 00110 a_offset = 1 + a_dim1; 00111 a -= a_offset; 00112 00113 /* Function Body */ 00114 *info = 0; 00115 upper = lsame_(uplo, "U"); 00116 nounit = lsame_(diag, "N"); 00117 if (! upper && ! lsame_(uplo, "L")) { 00118 *info = -1; 00119 } else if (! nounit && ! lsame_(diag, "U")) { 00120 *info = -2; 00121 } else if (*n < 0) { 00122 *info = -3; 00123 } else if (*lda < max(1,*n)) { 00124 *info = -5; 00125 } 00126 if (*info != 0) { 00127 i__1 = -(*info); 00128 xerbla_("DTRTI2", &i__1); 00129 return 0; 00130 } 00131 00132 if (upper) { 00133 00134 /* Compute inverse of upper triangular matrix. */ 00135 00136 i__1 = *n; 00137 for (j = 1; j <= i__1; ++j) { 00138 if (nounit) { 00139 a[j + j * a_dim1] = 1. / a[j + j * a_dim1]; 00140 ajj = -a[j + j * a_dim1]; 00141 } else { 00142 ajj = -1.; 00143 } 00144 00145 /* Compute elements 1:j-1 of j-th column. */ 00146 00147 i__2 = j - 1; 00148 dtrmv_("Upper", "No transpose", diag, &i__2, &a[a_offset], lda, & 00149 a[j * a_dim1 + 1], &c__1); 00150 i__2 = j - 1; 00151 dscal_(&i__2, &ajj, &a[j * a_dim1 + 1], &c__1); 00152 /* L10: */ 00153 } 00154 } else { 00155 00156 /* Compute inverse of lower triangular matrix. */ 00157 00158 for (j = *n; j >= 1; --j) { 00159 if (nounit) { 00160 a[j + j * a_dim1] = 1. / a[j + j * a_dim1]; 00161 ajj = -a[j + j * a_dim1]; 00162 } else { 00163 ajj = -1.; 00164 } 00165 if (j < *n) { 00166 00167 /* Compute elements j+1:n of j-th column. */ 00168 00169 i__1 = *n - j; 00170 dtrmv_("Lower", "No transpose", diag, &i__1, &a[j + 1 + (j + 00171 1) * a_dim1], lda, &a[j + 1 + j * a_dim1], &c__1); 00172 i__1 = *n - j; 00173 dscal_(&i__1, &ajj, &a[j + 1 + j * a_dim1], &c__1); 00174 } 00175 /* L20: */ 00176 } 00177 } 00178 00179 return 0; 00180 00181 /* End of DTRTI2 */ 00182 00183 } /* dtrti2_ */