cpotrs.c
Go to the documentation of this file.
00001 /* cpotrs.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 complex c_b1 = {1.f,0.f};
00019 
00020 /* Subroutine */ int cpotrs_(char *uplo, integer *n, integer *nrhs, complex *
00021         a, integer *lda, complex *b, integer *ldb, integer *info)
00022 {
00023     /* System generated locals */
00024     integer a_dim1, a_offset, b_dim1, b_offset, i__1;
00025 
00026     /* Local variables */
00027     extern logical lsame_(char *, char *);
00028     extern /* Subroutine */ int ctrsm_(char *, char *, char *, char *, 
00029             integer *, integer *, complex *, complex *, integer *, complex *, 
00030             integer *);
00031     logical upper;
00032     extern /* Subroutine */ int xerbla_(char *, integer *);
00033 
00034 
00035 /*  -- LAPACK routine (version 3.2) -- */
00036 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00037 /*     November 2006 */
00038 
00039 /*     .. Scalar Arguments .. */
00040 /*     .. */
00041 /*     .. Array Arguments .. */
00042 /*     .. */
00043 
00044 /*  Purpose */
00045 /*  ======= */
00046 
00047 /*  CPOTRS solves a system of linear equations A*X = B with a Hermitian */
00048 /*  positive definite matrix A using the Cholesky factorization */
00049 /*  A = U**H*U or A = L*L**H computed by CPOTRF. */
00050 
00051 /*  Arguments */
00052 /*  ========= */
00053 
00054 /*  UPLO    (input) CHARACTER*1 */
00055 /*          = 'U':  Upper triangle of A is stored; */
00056 /*          = 'L':  Lower triangle of A is stored. */
00057 
00058 /*  N       (input) INTEGER */
00059 /*          The order of the matrix A.  N >= 0. */
00060 
00061 /*  NRHS    (input) INTEGER */
00062 /*          The number of right hand sides, i.e., the number of columns */
00063 /*          of the matrix B.  NRHS >= 0. */
00064 
00065 /*  A       (input) COMPLEX array, dimension (LDA,N) */
00066 /*          The triangular factor U or L from the Cholesky factorization */
00067 /*          A = U**H*U or A = L*L**H, as computed by CPOTRF. */
00068 
00069 /*  LDA     (input) INTEGER */
00070 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00071 
00072 /*  B       (input/output) COMPLEX array, dimension (LDB,NRHS) */
00073 /*          On entry, the right hand side matrix B. */
00074 /*          On exit, the solution matrix X. */
00075 
00076 /*  LDB     (input) INTEGER */
00077 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00078 
00079 /*  INFO    (output) INTEGER */
00080 /*          = 0:  successful exit */
00081 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00082 
00083 /*  ===================================================================== */
00084 
00085 /*     .. Parameters .. */
00086 /*     .. */
00087 /*     .. Local Scalars .. */
00088 /*     .. */
00089 /*     .. External Functions .. */
00090 /*     .. */
00091 /*     .. External Subroutines .. */
00092 /*     .. */
00093 /*     .. Intrinsic Functions .. */
00094 /*     .. */
00095 /*     .. Executable Statements .. */
00096 
00097 /*     Test the input parameters. */
00098 
00099     /* Parameter adjustments */
00100     a_dim1 = *lda;
00101     a_offset = 1 + a_dim1;
00102     a -= a_offset;
00103     b_dim1 = *ldb;
00104     b_offset = 1 + b_dim1;
00105     b -= b_offset;
00106 
00107     /* Function Body */
00108     *info = 0;
00109     upper = lsame_(uplo, "U");
00110     if (! upper && ! lsame_(uplo, "L")) {
00111         *info = -1;
00112     } else if (*n < 0) {
00113         *info = -2;
00114     } else if (*nrhs < 0) {
00115         *info = -3;
00116     } else if (*lda < max(1,*n)) {
00117         *info = -5;
00118     } else if (*ldb < max(1,*n)) {
00119         *info = -7;
00120     }
00121     if (*info != 0) {
00122         i__1 = -(*info);
00123         xerbla_("CPOTRS", &i__1);
00124         return 0;
00125     }
00126 
00127 /*     Quick return if possible */
00128 
00129     if (*n == 0 || *nrhs == 0) {
00130         return 0;
00131     }
00132 
00133     if (upper) {
00134 
00135 /*        Solve A*X = B where A = U'*U. */
00136 
00137 /*        Solve U'*X = B, overwriting B with X. */
00138 
00139         ctrsm_("Left", "Upper", "Conjugate transpose", "Non-unit", n, nrhs, &
00140                 c_b1, &a[a_offset], lda, &b[b_offset], ldb);
00141 
00142 /*        Solve U*X = B, overwriting B with X. */
00143 
00144         ctrsm_("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b1, &
00145                 a[a_offset], lda, &b[b_offset], ldb);
00146     } else {
00147 
00148 /*        Solve A*X = B where A = L*L'. */
00149 
00150 /*        Solve L*X = B, overwriting B with X. */
00151 
00152         ctrsm_("Left", "Lower", "No transpose", "Non-unit", n, nrhs, &c_b1, &
00153                 a[a_offset], lda, &b[b_offset], ldb);
00154 
00155 /*        Solve L'*X = B, overwriting B with X. */
00156 
00157         ctrsm_("Left", "Lower", "Conjugate transpose", "Non-unit", n, nrhs, &
00158                 c_b1, &a[a_offset], lda, &b[b_offset], ldb);
00159     }
00160 
00161     return 0;
00162 
00163 /*     End of CPOTRS */
00164 
00165 } /* cpotrs_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:33