00001 /* ctptrs.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 ctptrs_(char *uplo, char *trans, char *diag, integer *n, 00021 integer *nrhs, complex *ap, complex *b, integer *ldb, integer *info) 00022 { 00023 /* System generated locals */ 00024 integer b_dim1, b_offset, i__1, i__2; 00025 00026 /* Local variables */ 00027 integer j, jc; 00028 extern logical lsame_(char *, char *); 00029 logical upper; 00030 extern /* Subroutine */ int ctpsv_(char *, char *, char *, integer *, 00031 complex *, complex *, integer *), xerbla_( 00032 char *, integer *); 00033 logical nounit; 00034 00035 00036 /* -- LAPACK routine (version 3.2) -- */ 00037 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00038 /* November 2006 */ 00039 00040 /* .. Scalar Arguments .. */ 00041 /* .. */ 00042 /* .. Array Arguments .. */ 00043 /* .. */ 00044 00045 /* Purpose */ 00046 /* ======= */ 00047 00048 /* CTPTRS solves a triangular system of the form */ 00049 00050 /* A * X = B, A**T * X = B, or A**H * X = B, */ 00051 00052 /* where A is a triangular matrix of order N stored in packed format, */ 00053 /* and B is an N-by-NRHS matrix. A check is made to verify that A is */ 00054 /* nonsingular. */ 00055 00056 /* Arguments */ 00057 /* ========= */ 00058 00059 /* UPLO (input) CHARACTER*1 */ 00060 /* = 'U': A is upper triangular; */ 00061 /* = 'L': A is lower triangular. */ 00062 00063 /* TRANS (input) CHARACTER*1 */ 00064 /* Specifies the form of the system of equations: */ 00065 /* = 'N': A * X = B (No transpose) */ 00066 /* = 'T': A**T * X = B (Transpose) */ 00067 /* = 'C': A**H * X = B (Conjugate transpose) */ 00068 00069 /* DIAG (input) CHARACTER*1 */ 00070 /* = 'N': A is non-unit triangular; */ 00071 /* = 'U': A is unit triangular. */ 00072 00073 /* N (input) INTEGER */ 00074 /* The order of the matrix A. N >= 0. */ 00075 00076 /* NRHS (input) INTEGER */ 00077 /* The number of right hand sides, i.e., the number of columns */ 00078 /* of the matrix B. NRHS >= 0. */ 00079 00080 /* AP (input) COMPLEX array, dimension (N*(N+1)/2) */ 00081 /* The upper or lower triangular matrix A, packed columnwise in */ 00082 /* a linear array. The j-th column of A is stored in the array */ 00083 /* AP as follows: */ 00084 /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ 00085 /* if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. */ 00086 00087 /* B (input/output) COMPLEX array, dimension (LDB,NRHS) */ 00088 /* On entry, the right hand side matrix B. */ 00089 /* On exit, if INFO = 0, the solution matrix X. */ 00090 00091 /* LDB (input) INTEGER */ 00092 /* The leading dimension of the array B. LDB >= max(1,N). */ 00093 00094 /* INFO (output) INTEGER */ 00095 /* = 0: successful exit */ 00096 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00097 /* > 0: if INFO = i, the i-th diagonal element of A is zero, */ 00098 /* indicating that the matrix is singular and the */ 00099 /* solutions X have not been computed. */ 00100 00101 /* ===================================================================== */ 00102 00103 /* .. Parameters .. */ 00104 /* .. */ 00105 /* .. Local Scalars .. */ 00106 /* .. */ 00107 /* .. External Functions .. */ 00108 /* .. */ 00109 /* .. External Subroutines .. */ 00110 /* .. */ 00111 /* .. Intrinsic Functions .. */ 00112 /* .. */ 00113 /* .. Executable Statements .. */ 00114 00115 /* Test the input parameters. */ 00116 00117 /* Parameter adjustments */ 00118 --ap; 00119 b_dim1 = *ldb; 00120 b_offset = 1 + b_dim1; 00121 b -= b_offset; 00122 00123 /* Function Body */ 00124 *info = 0; 00125 upper = lsame_(uplo, "U"); 00126 nounit = lsame_(diag, "N"); 00127 if (! upper && ! lsame_(uplo, "L")) { 00128 *info = -1; 00129 } else if (! lsame_(trans, "N") && ! lsame_(trans, 00130 "T") && ! lsame_(trans, "C")) { 00131 *info = -2; 00132 } else if (! nounit && ! lsame_(diag, "U")) { 00133 *info = -3; 00134 } else if (*n < 0) { 00135 *info = -4; 00136 } else if (*nrhs < 0) { 00137 *info = -5; 00138 } else if (*ldb < max(1,*n)) { 00139 *info = -8; 00140 } 00141 if (*info != 0) { 00142 i__1 = -(*info); 00143 xerbla_("CTPTRS", &i__1); 00144 return 0; 00145 } 00146 00147 /* Quick return if possible */ 00148 00149 if (*n == 0) { 00150 return 0; 00151 } 00152 00153 /* Check for singularity. */ 00154 00155 if (nounit) { 00156 if (upper) { 00157 jc = 1; 00158 i__1 = *n; 00159 for (*info = 1; *info <= i__1; ++(*info)) { 00160 i__2 = jc + *info - 1; 00161 if (ap[i__2].r == 0.f && ap[i__2].i == 0.f) { 00162 return 0; 00163 } 00164 jc += *info; 00165 /* L10: */ 00166 } 00167 } else { 00168 jc = 1; 00169 i__1 = *n; 00170 for (*info = 1; *info <= i__1; ++(*info)) { 00171 i__2 = jc; 00172 if (ap[i__2].r == 0.f && ap[i__2].i == 0.f) { 00173 return 0; 00174 } 00175 jc = jc + *n - *info + 1; 00176 /* L20: */ 00177 } 00178 } 00179 } 00180 *info = 0; 00181 00182 /* Solve A * x = b, A**T * x = b, or A**H * x = b. */ 00183 00184 i__1 = *nrhs; 00185 for (j = 1; j <= i__1; ++j) { 00186 ctpsv_(uplo, trans, diag, n, &ap[1], &b[j * b_dim1 + 1], &c__1); 00187 /* L30: */ 00188 } 00189 00190 return 0; 00191 00192 /* End of CTPTRS */ 00193 00194 } /* ctptrs_ */