00001 /* zgetrs.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 doublecomplex c_b1 = {1.,0.}; 00019 static integer c__1 = 1; 00020 static integer c_n1 = -1; 00021 00022 /* Subroutine */ int zgetrs_(char *trans, integer *n, integer *nrhs, 00023 doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *b, 00024 integer *ldb, integer *info) 00025 { 00026 /* System generated locals */ 00027 integer a_dim1, a_offset, b_dim1, b_offset, i__1; 00028 00029 /* Local variables */ 00030 extern logical lsame_(char *, char *); 00031 extern /* Subroutine */ int ztrsm_(char *, char *, char *, char *, 00032 integer *, integer *, doublecomplex *, doublecomplex *, integer *, 00033 doublecomplex *, integer *), 00034 xerbla_(char *, integer *); 00035 logical notran; 00036 extern /* Subroutine */ int zlaswp_(integer *, doublecomplex *, integer *, 00037 integer *, integer *, integer *, integer *); 00038 00039 00040 /* -- LAPACK routine (version 3.2) -- */ 00041 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00042 /* November 2006 */ 00043 00044 /* .. Scalar Arguments .. */ 00045 /* .. */ 00046 /* .. Array Arguments .. */ 00047 /* .. */ 00048 00049 /* Purpose */ 00050 /* ======= */ 00051 00052 /* ZGETRS solves a system of linear equations */ 00053 /* A * X = B, A**T * X = B, or A**H * X = B */ 00054 /* with a general N-by-N matrix A using the LU factorization computed */ 00055 /* by ZGETRF. */ 00056 00057 /* Arguments */ 00058 /* ========= */ 00059 00060 /* TRANS (input) CHARACTER*1 */ 00061 /* Specifies the form of the system of equations: */ 00062 /* = 'N': A * X = B (No transpose) */ 00063 /* = 'T': A**T * X = B (Transpose) */ 00064 /* = 'C': A**H * X = B (Conjugate transpose) */ 00065 00066 /* N (input) INTEGER */ 00067 /* The order of the matrix A. N >= 0. */ 00068 00069 /* NRHS (input) INTEGER */ 00070 /* The number of right hand sides, i.e., the number of columns */ 00071 /* of the matrix B. NRHS >= 0. */ 00072 00073 /* A (input) COMPLEX*16 array, dimension (LDA,N) */ 00074 /* The factors L and U from the factorization A = P*L*U */ 00075 /* as computed by ZGETRF. */ 00076 00077 /* LDA (input) INTEGER */ 00078 /* The leading dimension of the array A. LDA >= max(1,N). */ 00079 00080 /* IPIV (input) INTEGER array, dimension (N) */ 00081 /* The pivot indices from ZGETRF; for 1<=i<=N, row i of the */ 00082 /* matrix was interchanged with row IPIV(i). */ 00083 00084 /* B (input/output) COMPLEX*16 array, dimension (LDB,NRHS) */ 00085 /* On entry, the right hand side matrix B. */ 00086 /* On exit, the solution matrix X. */ 00087 00088 /* LDB (input) INTEGER */ 00089 /* The leading dimension of the array B. LDB >= max(1,N). */ 00090 00091 /* INFO (output) INTEGER */ 00092 /* = 0: successful exit */ 00093 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00094 00095 /* ===================================================================== */ 00096 00097 /* .. Parameters .. */ 00098 /* .. */ 00099 /* .. Local Scalars .. */ 00100 /* .. */ 00101 /* .. External Functions .. */ 00102 /* .. */ 00103 /* .. External Subroutines .. */ 00104 /* .. */ 00105 /* .. Intrinsic Functions .. */ 00106 /* .. */ 00107 /* .. Executable Statements .. */ 00108 00109 /* Test the input parameters. */ 00110 00111 /* Parameter adjustments */ 00112 a_dim1 = *lda; 00113 a_offset = 1 + a_dim1; 00114 a -= a_offset; 00115 --ipiv; 00116 b_dim1 = *ldb; 00117 b_offset = 1 + b_dim1; 00118 b -= b_offset; 00119 00120 /* Function Body */ 00121 *info = 0; 00122 notran = lsame_(trans, "N"); 00123 if (! notran && ! lsame_(trans, "T") && ! lsame_( 00124 trans, "C")) { 00125 *info = -1; 00126 } else if (*n < 0) { 00127 *info = -2; 00128 } else if (*nrhs < 0) { 00129 *info = -3; 00130 } else if (*lda < max(1,*n)) { 00131 *info = -5; 00132 } else if (*ldb < max(1,*n)) { 00133 *info = -8; 00134 } 00135 if (*info != 0) { 00136 i__1 = -(*info); 00137 xerbla_("ZGETRS", &i__1); 00138 return 0; 00139 } 00140 00141 /* Quick return if possible */ 00142 00143 if (*n == 0 || *nrhs == 0) { 00144 return 0; 00145 } 00146 00147 if (notran) { 00148 00149 /* Solve A * X = B. */ 00150 00151 /* Apply row interchanges to the right hand sides. */ 00152 00153 zlaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c__1); 00154 00155 /* Solve L*X = B, overwriting B with X. */ 00156 00157 ztrsm_("Left", "Lower", "No transpose", "Unit", n, nrhs, &c_b1, &a[ 00158 a_offset], lda, &b[b_offset], ldb); 00159 00160 /* Solve U*X = B, overwriting B with X. */ 00161 00162 ztrsm_("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b1, & 00163 a[a_offset], lda, &b[b_offset], ldb); 00164 } else { 00165 00166 /* Solve A**T * X = B or A**H * X = B. */ 00167 00168 /* Solve U'*X = B, overwriting B with X. */ 00169 00170 ztrsm_("Left", "Upper", trans, "Non-unit", n, nrhs, &c_b1, &a[ 00171 a_offset], lda, &b[b_offset], ldb); 00172 00173 /* Solve L'*X = B, overwriting B with X. */ 00174 00175 ztrsm_("Left", "Lower", trans, "Unit", n, nrhs, &c_b1, &a[a_offset], 00176 lda, &b[b_offset], ldb); 00177 00178 /* Apply row interchanges to the solution vectors. */ 00179 00180 zlaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c_n1); 00181 } 00182 00183 return 0; 00184 00185 /* End of ZGETRS */ 00186 00187 } /* zgetrs_ */