/* Subroutine */ int cerrpo_(char *path, integer *nunit) { /* System generated locals */ integer i__1; real r__1, r__2; complex q__1; /* Local variables */ complex a[16] /* was [4][4] */, b[4]; integer i__, j; real r__[4]; complex w[8], x[4]; char c2[2]; real r1[4], r2[4]; complex af[16] /* was [4][4] */; integer info; real anrm, rcond; /* Fortran I/O blocks */ static cilist io___1 = { 0, 0, 0, 0, 0 }; /* -- LAPACK test routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* CERRPO tests the error exits for the COMPLEX routines */ /* for Hermitian positive definite matrices. */ /* Arguments */ /* ========= */ /* PATH (input) CHARACTER*3 */ /* The LAPACK path name for the routines to be tested. */ /* NUNIT (input) INTEGER */ /* The unit number for output. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. Local Arrays .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Scalars in Common .. */ /* .. */ /* .. Common blocks .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ infoc_1.nout = *nunit; io___1.ciunit = infoc_1.nout; s_wsle(&io___1); e_wsle(); s_copy(c2, path + 1, (ftnlen)2, (ftnlen)2); /* Set the variables to innocuous values. */ for (j = 1; j <= 4; ++j) { for (i__ = 1; i__ <= 4; ++i__) { i__1 = i__ + (j << 2) - 5; r__1 = 1.f / (real) (i__ + j); r__2 = -1.f / (real) (i__ + j); q__1.r = r__1, q__1.i = r__2; a[i__1].r = q__1.r, a[i__1].i = q__1.i; i__1 = i__ + (j << 2) - 5; r__1 = 1.f / (real) (i__ + j); r__2 = -1.f / (real) (i__ + j); q__1.r = r__1, q__1.i = r__2; af[i__1].r = q__1.r, af[i__1].i = q__1.i; /* L10: */ } i__1 = j - 1; b[i__1].r = 0.f, b[i__1].i = 0.f; r1[j - 1] = 0.f; r2[j - 1] = 0.f; i__1 = j - 1; w[i__1].r = 0.f, w[i__1].i = 0.f; i__1 = j - 1; x[i__1].r = 0.f, x[i__1].i = 0.f; /* L20: */ } anrm = 1.f; infoc_1.ok = TRUE_; /* Test error exits of the routines that use the Cholesky */ /* decomposition of a Hermitian positive definite matrix. */ if (lsamen_(&c__2, c2, "PO")) { /* CPOTRF */ s_copy(srnamc_1.srnamt, "CPOTRF", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpotrf_("/", &c__0, a, &c__1, &info); chkxer_("CPOTRF", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpotrf_("U", &c_n1, a, &c__1, &info); chkxer_("CPOTRF", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cpotrf_("U", &c__2, a, &c__1, &info); chkxer_("CPOTRF", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPOTF2 */ s_copy(srnamc_1.srnamt, "CPOTF2", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpotf2_("/", &c__0, a, &c__1, &info); chkxer_("CPOTF2", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpotf2_("U", &c_n1, a, &c__1, &info); chkxer_("CPOTF2", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cpotf2_("U", &c__2, a, &c__1, &info); chkxer_("CPOTF2", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPOTRI */ s_copy(srnamc_1.srnamt, "CPOTRI", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpotri_("/", &c__0, a, &c__1, &info); chkxer_("CPOTRI", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpotri_("U", &c_n1, a, &c__1, &info); chkxer_("CPOTRI", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cpotri_("U", &c__2, a, &c__1, &info); chkxer_("CPOTRI", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPOTRS */ s_copy(srnamc_1.srnamt, "CPOTRS", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpotrs_("/", &c__0, &c__0, a, &c__1, b, &c__1, &info); chkxer_("CPOTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpotrs_("U", &c_n1, &c__0, a, &c__1, b, &c__1, &info); chkxer_("CPOTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpotrs_("U", &c__0, &c_n1, a, &c__1, b, &c__1, &info); chkxer_("CPOTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 5; cpotrs_("U", &c__2, &c__1, a, &c__1, b, &c__2, &info); chkxer_("CPOTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 7; cpotrs_("U", &c__2, &c__1, a, &c__2, b, &c__1, &info); chkxer_("CPOTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPORFS */ s_copy(srnamc_1.srnamt, "CPORFS", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cporfs_("/", &c__0, &c__0, a, &c__1, af, &c__1, b, &c__1, x, &c__1, r1, r2, w, r__, &info); chkxer_("CPORFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cporfs_("U", &c_n1, &c__0, a, &c__1, af, &c__1, b, &c__1, x, &c__1, r1, r2, w, r__, &info); chkxer_("CPORFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cporfs_("U", &c__0, &c_n1, a, &c__1, af, &c__1, b, &c__1, x, &c__1, r1, r2, w, r__, &info); chkxer_("CPORFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 5; cporfs_("U", &c__2, &c__1, a, &c__1, af, &c__2, b, &c__2, x, &c__2, r1, r2, w, r__, &info); chkxer_("CPORFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 7; cporfs_("U", &c__2, &c__1, a, &c__2, af, &c__1, b, &c__2, x, &c__2, r1, r2, w, r__, &info); chkxer_("CPORFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 9; cporfs_("U", &c__2, &c__1, a, &c__2, af, &c__2, b, &c__1, x, &c__2, r1, r2, w, r__, &info); chkxer_("CPORFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 11; cporfs_("U", &c__2, &c__1, a, &c__2, af, &c__2, b, &c__2, x, &c__1, r1, r2, w, r__, &info); chkxer_("CPORFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPOCON */ s_copy(srnamc_1.srnamt, "CPOCON", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpocon_("/", &c__0, a, &c__1, &anrm, &rcond, w, r__, &info) ; chkxer_("CPOCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpocon_("U", &c_n1, a, &c__1, &anrm, &rcond, w, r__, &info) ; chkxer_("CPOCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cpocon_("U", &c__2, a, &c__1, &anrm, &rcond, w, r__, &info) ; chkxer_("CPOCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 5; r__1 = -anrm; cpocon_("U", &c__1, a, &c__1, &r__1, &rcond, w, r__, &info) ; chkxer_("CPOCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPOEQU */ s_copy(srnamc_1.srnamt, "CPOEQU", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpoequ_(&c_n1, a, &c__1, r1, &rcond, &anrm, &info); chkxer_("CPOEQU", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpoequ_(&c__2, a, &c__1, r1, &rcond, &anrm, &info); chkxer_("CPOEQU", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* Test error exits of the routines that use the Cholesky */ /* decomposition of a Hermitian positive definite packed matrix. */ } else if (lsamen_(&c__2, c2, "PP")) { /* CPPTRF */ s_copy(srnamc_1.srnamt, "CPPTRF", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpptrf_("/", &c__0, a, &info); chkxer_("CPPTRF", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpptrf_("U", &c_n1, a, &info); chkxer_("CPPTRF", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPPTRI */ s_copy(srnamc_1.srnamt, "CPPTRI", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpptri_("/", &c__0, a, &info); chkxer_("CPPTRI", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpptri_("U", &c_n1, a, &info); chkxer_("CPPTRI", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPPTRS */ s_copy(srnamc_1.srnamt, "CPPTRS", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpptrs_("/", &c__0, &c__0, a, b, &c__1, &info); chkxer_("CPPTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpptrs_("U", &c_n1, &c__0, a, b, &c__1, &info); chkxer_("CPPTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpptrs_("U", &c__0, &c_n1, a, b, &c__1, &info); chkxer_("CPPTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; cpptrs_("U", &c__2, &c__1, a, b, &c__1, &info); chkxer_("CPPTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPPRFS */ s_copy(srnamc_1.srnamt, "CPPRFS", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpprfs_("/", &c__0, &c__0, a, af, b, &c__1, x, &c__1, r1, r2, w, r__, &info); chkxer_("CPPRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpprfs_("U", &c_n1, &c__0, a, af, b, &c__1, x, &c__1, r1, r2, w, r__, &info); chkxer_("CPPRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpprfs_("U", &c__0, &c_n1, a, af, b, &c__1, x, &c__1, r1, r2, w, r__, &info); chkxer_("CPPRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 7; cpprfs_("U", &c__2, &c__1, a, af, b, &c__1, x, &c__2, r1, r2, w, r__, &info); chkxer_("CPPRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 9; cpprfs_("U", &c__2, &c__1, a, af, b, &c__2, x, &c__1, r1, r2, w, r__, &info); chkxer_("CPPRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPPCON */ s_copy(srnamc_1.srnamt, "CPPCON", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cppcon_("/", &c__0, a, &anrm, &rcond, w, r__, &info); chkxer_("CPPCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cppcon_("U", &c_n1, a, &anrm, &rcond, w, r__, &info); chkxer_("CPPCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; r__1 = -anrm; cppcon_("U", &c__1, a, &r__1, &rcond, w, r__, &info); chkxer_("CPPCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPPEQU */ s_copy(srnamc_1.srnamt, "CPPEQU", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cppequ_("/", &c__0, a, r1, &rcond, &anrm, &info); chkxer_("CPPEQU", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cppequ_("U", &c_n1, a, r1, &rcond, &anrm, &info); chkxer_("CPPEQU", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* Test error exits of the routines that use the Cholesky */ /* decomposition of a Hermitian positive definite band matrix. */ } else if (lsamen_(&c__2, c2, "PB")) { /* CPBTRF */ s_copy(srnamc_1.srnamt, "CPBTRF", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpbtrf_("/", &c__0, &c__0, a, &c__1, &info); chkxer_("CPBTRF", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpbtrf_("U", &c_n1, &c__0, a, &c__1, &info); chkxer_("CPBTRF", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpbtrf_("U", &c__1, &c_n1, a, &c__1, &info); chkxer_("CPBTRF", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 5; cpbtrf_("U", &c__2, &c__1, a, &c__1, &info); chkxer_("CPBTRF", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPBTF2 */ s_copy(srnamc_1.srnamt, "CPBTF2", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpbtf2_("/", &c__0, &c__0, a, &c__1, &info); chkxer_("CPBTF2", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpbtf2_("U", &c_n1, &c__0, a, &c__1, &info); chkxer_("CPBTF2", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpbtf2_("U", &c__1, &c_n1, a, &c__1, &info); chkxer_("CPBTF2", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 5; cpbtf2_("U", &c__2, &c__1, a, &c__1, &info); chkxer_("CPBTF2", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPBTRS */ s_copy(srnamc_1.srnamt, "CPBTRS", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpbtrs_("/", &c__0, &c__0, &c__0, a, &c__1, b, &c__1, &info); chkxer_("CPBTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpbtrs_("U", &c_n1, &c__0, &c__0, a, &c__1, b, &c__1, &info); chkxer_("CPBTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpbtrs_("U", &c__1, &c_n1, &c__0, a, &c__1, b, &c__1, &info); chkxer_("CPBTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cpbtrs_("U", &c__0, &c__0, &c_n1, a, &c__1, b, &c__1, &info); chkxer_("CPBTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; cpbtrs_("U", &c__2, &c__1, &c__1, a, &c__1, b, &c__1, &info); chkxer_("CPBTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; cpbtrs_("U", &c__2, &c__0, &c__1, a, &c__1, b, &c__1, &info); chkxer_("CPBTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPBRFS */ s_copy(srnamc_1.srnamt, "CPBRFS", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpbrfs_("/", &c__0, &c__0, &c__0, a, &c__1, af, &c__1, b, &c__1, x, & c__1, r1, r2, w, r__, &info); chkxer_("CPBRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpbrfs_("U", &c_n1, &c__0, &c__0, a, &c__1, af, &c__1, b, &c__1, x, & c__1, r1, r2, w, r__, &info); chkxer_("CPBRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpbrfs_("U", &c__1, &c_n1, &c__0, a, &c__1, af, &c__1, b, &c__1, x, & c__1, r1, r2, w, r__, &info); chkxer_("CPBRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; cpbrfs_("U", &c__0, &c__0, &c_n1, a, &c__1, af, &c__1, b, &c__1, x, & c__1, r1, r2, w, r__, &info); chkxer_("CPBRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; cpbrfs_("U", &c__2, &c__1, &c__1, a, &c__1, af, &c__2, b, &c__2, x, & c__2, r1, r2, w, r__, &info); chkxer_("CPBRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; cpbrfs_("U", &c__2, &c__1, &c__1, a, &c__2, af, &c__1, b, &c__2, x, & c__2, r1, r2, w, r__, &info); chkxer_("CPBRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 10; cpbrfs_("U", &c__2, &c__0, &c__1, a, &c__1, af, &c__1, b, &c__1, x, & c__2, r1, r2, w, r__, &info); chkxer_("CPBRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 12; cpbrfs_("U", &c__2, &c__0, &c__1, a, &c__1, af, &c__1, b, &c__2, x, & c__1, r1, r2, w, r__, &info); chkxer_("CPBRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPBCON */ s_copy(srnamc_1.srnamt, "CPBCON", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpbcon_("/", &c__0, &c__0, a, &c__1, &anrm, &rcond, w, r__, &info); chkxer_("CPBCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpbcon_("U", &c_n1, &c__0, a, &c__1, &anrm, &rcond, w, r__, &info); chkxer_("CPBCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpbcon_("U", &c__1, &c_n1, a, &c__1, &anrm, &rcond, w, r__, &info); chkxer_("CPBCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 5; cpbcon_("U", &c__2, &c__1, a, &c__1, &anrm, &rcond, w, r__, &info); chkxer_("CPBCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; r__1 = -anrm; cpbcon_("U", &c__1, &c__0, a, &c__1, &r__1, &rcond, w, r__, &info); chkxer_("CPBCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* CPBEQU */ s_copy(srnamc_1.srnamt, "CPBEQU", (ftnlen)32, (ftnlen)6); infoc_1.infot = 1; cpbequ_("/", &c__0, &c__0, a, &c__1, r1, &rcond, &anrm, &info); chkxer_("CPBEQU", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; cpbequ_("U", &c_n1, &c__0, a, &c__1, r1, &rcond, &anrm, &info); chkxer_("CPBEQU", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; cpbequ_("U", &c__1, &c_n1, a, &c__1, r1, &rcond, &anrm, &info); chkxer_("CPBEQU", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 5; cpbequ_("U", &c__2, &c__1, a, &c__1, r1, &rcond, &anrm, &info); chkxer_("CPBEQU", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } /* Print a summary line. */ alaesm_(path, &infoc_1.ok, &infoc_1.nout); return 0; /* End of CERRPO */ } /* cerrpo_ */
/* Subroutine */ int cppsvx_(char *fact, char *uplo, integer *n, integer * nrhs, complex *ap, complex *afp, char *equed, real *s, complex *b, integer *ldb, complex *x, integer *ldx, real *rcond, real *ferr, real *berr, complex *work, real *rwork, integer *info) { /* System generated locals */ integer b_dim1, b_offset, x_dim1, x_offset, i__1, i__2, i__3, i__4, i__5; real r__1, r__2; complex q__1; /* Local variables */ integer i__, j; real amax, smin, smax; real scond, anorm; logical equil, rcequ; logical nofact; real bignum; integer infequ; real smlnum; /* -- LAPACK driver routine (version 3.2) -- */ /* November 2006 */ /* Purpose */ /* ======= */ /* CPPSVX uses the Cholesky factorization A = U**H*U or A = L*L**H to */ /* compute the solution to a complex system of linear equations */ /* A * X = B, */ /* where A is an N-by-N Hermitian positive definite matrix stored in */ /* packed format and X and B are N-by-NRHS matrices. */ /* Error bounds on the solution and a condition estimate are also */ /* provided. */ /* Description */ /* =========== */ /* The following steps are performed: */ /* 1. If FACT = 'E', real scaling factors are computed to equilibrate */ /* the system: */ /* diag(S) * A * diag(S) * inv(diag(S)) * X = diag(S) * B */ /* Whether or not the system will be equilibrated depends on the */ /* scaling of the matrix A, but if equilibration is used, A is */ /* overwritten by diag(S)*A*diag(S) and B by diag(S)*B. */ /* 2. If FACT = 'N' or 'E', the Cholesky decomposition is used to */ /* factor the matrix A (after equilibration if FACT = 'E') as */ /* A = U'* U , if UPLO = 'U', or */ /* A = L * L', if UPLO = 'L', */ /* where U is an upper triangular matrix, L is a lower triangular */ /* matrix, and ' indicates conjugate transpose. */ /* 3. If the leading i-by-i principal minor is not positive definite, */ /* then the routine returns with INFO = i. Otherwise, the factored */ /* form of A is used to estimate the condition number of the matrix */ /* A. If the reciprocal of the condition number is less than machine */ /* precision, INFO = N+1 is returned as a warning, but the routine */ /* still goes on to solve for X and compute error bounds as */ /* described below. */ /* 4. The system of equations is solved for X using the factored form */ /* of A. */ /* 5. Iterative refinement is applied to improve the computed solution */ /* matrix and calculate error bounds and backward error estimates */ /* for it. */ /* 6. If equilibration was used, the matrix X is premultiplied by */ /* diag(S) so that it solves the original system before */ /* equilibration. */ /* Arguments */ /* ========= */ /* FACT (input) CHARACTER*1 */ /* Specifies whether or not the factored form of the matrix A is */ /* supplied on entry, and if not, whether the matrix A should be */ /* equilibrated before it is factored. */ /* = 'F': On entry, AFP contains the factored form of A. */ /* If EQUED = 'Y', the matrix A has been equilibrated */ /* with scaling factors given by S. AP and AFP will not */ /* be modified. */ /* = 'N': The matrix A will be copied to AFP and factored. */ /* = 'E': The matrix A will be equilibrated if necessary, then */ /* copied to AFP and factored. */ /* UPLO (input) CHARACTER*1 */ /* = 'U': Upper triangle of A is stored; */ /* = 'L': Lower triangle of A is stored. */ /* N (input) INTEGER */ /* The number of linear equations, i.e., the order of the */ /* matrix A. N >= 0. */ /* NRHS (input) INTEGER */ /* The number of right hand sides, i.e., the number of columns */ /* of the matrices B and X. NRHS >= 0. */ /* AP (input/output) COMPLEX array, dimension (N*(N+1)/2) */ /* On entry, the upper or lower triangle of the Hermitian matrix */ /* A, packed columnwise in a linear array, except if FACT = 'F' */ /* and EQUED = 'Y', then A must contain the equilibrated matrix */ /* diag(S)*A*diag(S). The j-th column of A is stored in the */ /* array AP as follows: */ /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ /* See below for further details. A is not modified if */ /* FACT = 'F' or 'N', or if FACT = 'E' and EQUED = 'N' on exit. */ /* On exit, if FACT = 'E' and EQUED = 'Y', A is overwritten by */ /* diag(S)*A*diag(S). */ /* AFP (input or output) COMPLEX array, dimension (N*(N+1)/2) */ /* If FACT = 'F', then AFP is an input argument and on entry */ /* contains the triangular factor U or L from the Cholesky */ /* factorization A = U**H*U or A = L*L**H, in the same storage */ /* format as A. If EQUED .ne. 'N', then AFP is the factored */ /* form of the equilibrated matrix A. */ /* If FACT = 'N', then AFP is an output argument and on exit */ /* returns the triangular factor U or L from the Cholesky */ /* factorization A = U**H*U or A = L*L**H of the original */ /* matrix A. */ /* If FACT = 'E', then AFP is an output argument and on exit */ /* returns the triangular factor U or L from the Cholesky */ /* factorization A = U**H*U or A = L*L**H of the equilibrated */ /* matrix A (see the description of AP for the form of the */ /* equilibrated matrix). */ /* EQUED (input or output) CHARACTER*1 */ /* Specifies the form of equilibration that was done. */ /* = 'N': No equilibration (always true if FACT = 'N'). */ /* = 'Y': Equilibration was done, i.e., A has been replaced by */ /* diag(S) * A * diag(S). */ /* EQUED is an input argument if FACT = 'F'; otherwise, it is an */ /* output argument. */ /* S (input or output) REAL array, dimension (N) */ /* The scale factors for A; not accessed if EQUED = 'N'. S is */ /* an input argument if FACT = 'F'; otherwise, S is an output */ /* argument. If FACT = 'F' and EQUED = 'Y', each element of S */ /* must be positive. */ /* B (input/output) COMPLEX array, dimension (LDB,NRHS) */ /* On entry, the N-by-NRHS right hand side matrix B. */ /* On exit, if EQUED = 'N', B is not modified; if EQUED = 'Y', */ /* B is overwritten by diag(S) * B. */ /* LDB (input) INTEGER */ /* The leading dimension of the array B. LDB >= max(1,N). */ /* X (output) COMPLEX array, dimension (LDX,NRHS) */ /* If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X to */ /* the original system of equations. Note that if EQUED = 'Y', */ /* A and B are modified on exit, and the solution to the */ /* equilibrated system is inv(diag(S))*X. */ /* LDX (input) INTEGER */ /* The leading dimension of the array X. LDX >= max(1,N). */ /* RCOND (output) REAL */ /* The estimate of the reciprocal condition number of the matrix */ /* A after equilibration (if done). If RCOND is less than the */ /* machine precision (in particular, if RCOND = 0), the matrix */ /* is singular to working precision. This condition is */ /* indicated by a return code of INFO > 0. */ /* FERR (output) REAL array, dimension (NRHS) */ /* The estimated forward error bound for each solution vector */ /* X(j) (the j-th column of the solution matrix X). */ /* If XTRUE is the true solution corresponding to X(j), FERR(j) */ /* is an estimated upper bound for the magnitude of the largest */ /* element in (X(j) - XTRUE) divided by the magnitude of the */ /* largest element in X(j). The estimate is as reliable as */ /* the estimate for RCOND, and is almost always a slight */ /* overestimate of the true error. */ /* BERR (output) REAL array, dimension (NRHS) */ /* The componentwise relative backward error of each solution */ /* vector X(j) (i.e., the smallest relative change in */ /* any element of A or B that makes X(j) an exact solution). */ /* WORK (workspace) COMPLEX array, dimension (2*N) */ /* RWORK (workspace) REAL array, dimension (N) */ /* INFO (output) INTEGER */ /* = 0: successful exit */ /* < 0: if INFO = -i, the i-th argument had an illegal value */ /* > 0: if INFO = i, and i is */ /* <= N: the leading minor of order i of A is */ /* not positive definite, so the factorization */ /* could not be completed, and the solution has not */ /* been computed. RCOND = 0 is returned. */ /* = N+1: U is nonsingular, but RCOND is less than machine */ /* precision, meaning that the matrix is singular */ /* to working precision. Nevertheless, the */ /* solution and error bounds are computed because */ /* there are a number of situations where the */ /* computed solution can be more accurate than the */ /* value of RCOND would suggest. */ /* Further Details */ /* =============== */ /* The packed storage scheme is illustrated by the following example */ /* when N = 4, UPLO = 'U': */ /* Two-dimensional storage of the Hermitian matrix A: */ /* a11 a12 a13 a14 */ /* a22 a23 a24 */ /* a33 a34 (aij = conjg(aji)) */ /* a44 */ /* Packed storage of the upper triangle of A: */ /* AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] */ /* ===================================================================== */ /* Parameter adjustments */ --ap; --afp; --s; b_dim1 = *ldb; b_offset = 1 + b_dim1; b -= b_offset; x_dim1 = *ldx; x_offset = 1 + x_dim1; x -= x_offset; --ferr; --berr; --work; --rwork; /* Function Body */ *info = 0; nofact = lsame_(fact, "N"); equil = lsame_(fact, "E"); if (nofact || equil) { *(unsigned char *)equed = 'N'; rcequ = FALSE_; } else { rcequ = lsame_(equed, "Y"); smlnum = slamch_("Safe minimum"); bignum = 1.f / smlnum; } /* Test the input parameters. */ if (! nofact && ! equil && ! lsame_(fact, "F")) { *info = -1; } else if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) { *info = -2; } else if (*n < 0) { *info = -3; } else if (*nrhs < 0) { *info = -4; } else if (lsame_(fact, "F") && ! (rcequ || lsame_( equed, "N"))) { *info = -7; } else { if (rcequ) { smin = bignum; smax = 0.f; i__1 = *n; for (j = 1; j <= i__1; ++j) { /* Computing MIN */ r__1 = smin, r__2 = s[j]; smin = dmin(r__1,r__2); /* Computing MAX */ r__1 = smax, r__2 = s[j]; smax = dmax(r__1,r__2); } if (smin <= 0.f) { *info = -8; } else if (*n > 0) { scond = dmax(smin,smlnum) / dmin(smax,bignum); } else { scond = 1.f; } } if (*info == 0) { if (*ldb < max(1,*n)) { *info = -10; } else if (*ldx < max(1,*n)) { *info = -12; } } } if (*info != 0) { i__1 = -(*info); xerbla_("CPPSVX", &i__1); return 0; } if (equil) { /* Compute row and column scalings to equilibrate the matrix A. */ cppequ_(uplo, n, &ap[1], &s[1], &scond, &amax, &infequ); if (infequ == 0) { /* Equilibrate the matrix. */ claqhp_(uplo, n, &ap[1], &s[1], &scond, &amax, equed); rcequ = lsame_(equed, "Y"); } } /* Scale the right-hand side. */ if (rcequ) { i__1 = *nrhs; for (j = 1; j <= i__1; ++j) { i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { i__3 = i__ + j * b_dim1; i__4 = i__; i__5 = i__ + j * b_dim1; q__1.r = s[i__4] * b[i__5].r, q__1.i = s[i__4] * b[i__5].i; b[i__3].r = q__1.r, b[i__3].i = q__1.i; } } } if (nofact || equil) { /* Compute the Cholesky factorization A = U'*U or A = L*L'. */ i__1 = *n * (*n + 1) / 2; ccopy_(&i__1, &ap[1], &c__1, &afp[1], &c__1); cpptrf_(uplo, n, &afp[1], info); /* Return if INFO is non-zero. */ if (*info > 0) { *rcond = 0.f; return 0; } } /* Compute the norm of the matrix A. */ anorm = clanhp_("I", uplo, n, &ap[1], &rwork[1]); /* Compute the reciprocal of the condition number of A. */ cppcon_(uplo, n, &afp[1], &anorm, rcond, &work[1], &rwork[1], info); /* Compute the solution matrix X. */ clacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx); cpptrs_(uplo, n, nrhs, &afp[1], &x[x_offset], ldx, info); /* Use iterative refinement to improve the computed solution and */ /* compute error bounds and backward error estimates for it. */ cpprfs_(uplo, n, nrhs, &ap[1], &afp[1], &b[b_offset], ldb, &x[x_offset], ldx, &ferr[1], &berr[1], &work[1], &rwork[1], info); /* Transform the solution matrix X to a solution of the original */ /* system. */ if (rcequ) { i__1 = *nrhs; for (j = 1; j <= i__1; ++j) { i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { i__3 = i__ + j * x_dim1; i__4 = i__; i__5 = i__ + j * x_dim1; q__1.r = s[i__4] * x[i__5].r, q__1.i = s[i__4] * x[i__5].i; x[i__3].r = q__1.r, x[i__3].i = q__1.i; } } i__1 = *nrhs; for (j = 1; j <= i__1; ++j) { ferr[j] /= scond; } } /* Set INFO = N+1 if the matrix is singular to working precision. */ if (*rcond < slamch_("Epsilon")) { *info = *n + 1; } return 0; /* End of CPPSVX */ } /* cppsvx_ */
/* Subroutine */ int cpprfs_(char *uplo, integer *n, integer *nrhs, complex * ap, complex *afp, complex *b, integer *ldb, complex *x, integer *ldx, real *ferr, real *berr, complex *work, real *rwork, integer *info) { /* System generated locals */ integer b_dim1, b_offset, x_dim1, x_offset, i__1, i__2, i__3, i__4, i__5; real r__1, r__2, r__3, r__4; complex q__1; /* Builtin functions */ double r_imag(complex *); /* Local variables */ integer i__, j, k; real s; integer ik, kk; real xk; integer nz; real eps; integer kase; real safe1, safe2; extern logical lsame_(char *, char *); integer isave[3]; extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, complex *, integer *), chpmv_(char *, integer *, complex *, complex *, complex *, integer *, complex *, complex *, integer *), caxpy_(integer *, complex *, complex *, integer *, complex *, integer *); integer count; logical upper; extern /* Subroutine */ int clacn2_(integer *, complex *, complex *, real *, integer *, integer *); extern doublereal slamch_(char *); real safmin; extern /* Subroutine */ int xerbla_(char *, integer *), cpptrs_( char *, integer *, integer *, complex *, complex *, integer *, integer *); real lstres; /* -- LAPACK routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* Modified to call CLACN2 in place of CLACON, 10 Feb 03, SJH. */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* CPPRFS improves the computed solution to a system of linear */ /* equations when the coefficient matrix is Hermitian positive definite */ /* and packed, and provides error bounds and backward error estimates */ /* for the solution. */ /* Arguments */ /* ========= */ /* UPLO (input) CHARACTER*1 */ /* = 'U': Upper triangle of A is stored; */ /* = 'L': Lower triangle of A is stored. */ /* N (input) INTEGER */ /* The order of the matrix A. N >= 0. */ /* NRHS (input) INTEGER */ /* The number of right hand sides, i.e., the number of columns */ /* of the matrices B and X. NRHS >= 0. */ /* AP (input) COMPLEX array, dimension (N*(N+1)/2) */ /* The upper or lower triangle of the Hermitian matrix A, packed */ /* columnwise in a linear array. The j-th column of A is stored */ /* in the array AP as follows: */ /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ /* AFP (input) COMPLEX array, dimension (N*(N+1)/2) */ /* The triangular factor U or L from the Cholesky factorization */ /* A = U**H*U or A = L*L**H, as computed by SPPTRF/CPPTRF, */ /* packed columnwise in a linear array in the same format as A */ /* (see AP). */ /* B (input) COMPLEX array, dimension (LDB,NRHS) */ /* The right hand side matrix B. */ /* LDB (input) INTEGER */ /* The leading dimension of the array B. LDB >= max(1,N). */ /* X (input/output) COMPLEX array, dimension (LDX,NRHS) */ /* On entry, the solution matrix X, as computed by CPPTRS. */ /* On exit, the improved solution matrix X. */ /* LDX (input) INTEGER */ /* The leading dimension of the array X. LDX >= max(1,N). */ /* FERR (output) REAL array, dimension (NRHS) */ /* The estimated forward error bound for each solution vector */ /* X(j) (the j-th column of the solution matrix X). */ /* If XTRUE is the true solution corresponding to X(j), FERR(j) */ /* is an estimated upper bound for the magnitude of the largest */ /* element in (X(j) - XTRUE) divided by the magnitude of the */ /* largest element in X(j). The estimate is as reliable as */ /* the estimate for RCOND, and is almost always a slight */ /* overestimate of the true error. */ /* BERR (output) REAL array, dimension (NRHS) */ /* The componentwise relative backward error of each solution */ /* vector X(j) (i.e., the smallest relative change in */ /* any element of A or B that makes X(j) an exact solution). */ /* WORK (workspace) COMPLEX array, dimension (2*N) */ /* RWORK (workspace) REAL array, dimension (N) */ /* INFO (output) INTEGER */ /* = 0: successful exit */ /* < 0: if INFO = -i, the i-th argument had an illegal value */ /* Internal Parameters */ /* =================== */ /* ITMAX is the maximum number of steps of iterative refinement. */ /* ==================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. Local Arrays .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. Statement Functions .. */ /* .. */ /* .. Statement Function definitions .. */ /* .. */ /* .. Executable Statements .. */ /* Test the input parameters. */ /* Parameter adjustments */ --ap; --afp; b_dim1 = *ldb; b_offset = 1 + b_dim1; b -= b_offset; x_dim1 = *ldx; x_offset = 1 + x_dim1; x -= x_offset; --ferr; --berr; --work; --rwork; /* Function Body */ *info = 0; upper = lsame_(uplo, "U"); if (! upper && ! lsame_(uplo, "L")) { *info = -1; } else if (*n < 0) { *info = -2; } else if (*nrhs < 0) { *info = -3; } else if (*ldb < max(1,*n)) { *info = -7; } else if (*ldx < max(1,*n)) { *info = -9; } if (*info != 0) { i__1 = -(*info); xerbla_("CPPRFS", &i__1); return 0; } /* Quick return if possible */ if (*n == 0 || *nrhs == 0) { i__1 = *nrhs; for (j = 1; j <= i__1; ++j) { ferr[j] = 0.f; berr[j] = 0.f; /* L10: */ } return 0; } /* NZ = maximum number of nonzero elements in each row of A, plus 1 */ nz = *n + 1; eps = slamch_("Epsilon"); safmin = slamch_("Safe minimum"); safe1 = nz * safmin; safe2 = safe1 / eps; /* Do for each right hand side */ i__1 = *nrhs; for (j = 1; j <= i__1; ++j) { count = 1; lstres = 3.f; L20: /* Loop until stopping criterion is satisfied. */ /* Compute residual R = B - A * X */ ccopy_(n, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1); q__1.r = -1.f, q__1.i = -0.f; chpmv_(uplo, n, &q__1, &ap[1], &x[j * x_dim1 + 1], &c__1, &c_b1, & work[1], &c__1); /* Compute componentwise relative backward error from formula */ /* max(i) ( abs(R(i)) / ( abs(A)*abs(X) + abs(B) )(i) ) */ /* where abs(Z) is the componentwise absolute value of the matrix */ /* or vector Z. If the i-th component of the denominator is less */ /* than SAFE2, then SAFE1 is added to the i-th components of the */ /* numerator and denominator before dividing. */ i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { i__3 = i__ + j * b_dim1; rwork[i__] = (r__1 = b[i__3].r, dabs(r__1)) + (r__2 = r_imag(&b[ i__ + j * b_dim1]), dabs(r__2)); /* L30: */ } /* Compute abs(A)*abs(X) + abs(B). */ kk = 1; if (upper) { i__2 = *n; for (k = 1; k <= i__2; ++k) { s = 0.f; i__3 = k + j * x_dim1; xk = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 = r_imag(&x[k + j * x_dim1]), dabs(r__2)); ik = kk; i__3 = k - 1; for (i__ = 1; i__ <= i__3; ++i__) { i__4 = ik; rwork[i__] += ((r__1 = ap[i__4].r, dabs(r__1)) + (r__2 = r_imag(&ap[ik]), dabs(r__2))) * xk; i__4 = ik; i__5 = i__ + j * x_dim1; s += ((r__1 = ap[i__4].r, dabs(r__1)) + (r__2 = r_imag(& ap[ik]), dabs(r__2))) * ((r__3 = x[i__5].r, dabs( r__3)) + (r__4 = r_imag(&x[i__ + j * x_dim1]), dabs(r__4))); ++ik; /* L40: */ } i__3 = kk + k - 1; rwork[k] = rwork[k] + (r__1 = ap[i__3].r, dabs(r__1)) * xk + s; kk += k; /* L50: */ } } else { i__2 = *n; for (k = 1; k <= i__2; ++k) { s = 0.f; i__3 = k + j * x_dim1; xk = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 = r_imag(&x[k + j * x_dim1]), dabs(r__2)); i__3 = kk; rwork[k] += (r__1 = ap[i__3].r, dabs(r__1)) * xk; ik = kk + 1; i__3 = *n; for (i__ = k + 1; i__ <= i__3; ++i__) { i__4 = ik; rwork[i__] += ((r__1 = ap[i__4].r, dabs(r__1)) + (r__2 = r_imag(&ap[ik]), dabs(r__2))) * xk; i__4 = ik; i__5 = i__ + j * x_dim1; s += ((r__1 = ap[i__4].r, dabs(r__1)) + (r__2 = r_imag(& ap[ik]), dabs(r__2))) * ((r__3 = x[i__5].r, dabs( r__3)) + (r__4 = r_imag(&x[i__ + j * x_dim1]), dabs(r__4))); ++ik; /* L60: */ } rwork[k] += s; kk += *n - k + 1; /* L70: */ } } s = 0.f; i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { if (rwork[i__] > safe2) { /* Computing MAX */ i__3 = i__; r__3 = s, r__4 = ((r__1 = work[i__3].r, dabs(r__1)) + (r__2 = r_imag(&work[i__]), dabs(r__2))) / rwork[i__]; s = dmax(r__3,r__4); } else { /* Computing MAX */ i__3 = i__; r__3 = s, r__4 = ((r__1 = work[i__3].r, dabs(r__1)) + (r__2 = r_imag(&work[i__]), dabs(r__2)) + safe1) / (rwork[i__] + safe1); s = dmax(r__3,r__4); } /* L80: */ } berr[j] = s; /* Test stopping criterion. Continue iterating if */ /* 1) The residual BERR(J) is larger than machine epsilon, and */ /* 2) BERR(J) decreased by at least a factor of 2 during the */ /* last iteration, and */ /* 3) At most ITMAX iterations tried. */ if (berr[j] > eps && berr[j] * 2.f <= lstres && count <= 5) { /* Update solution and try again. */ cpptrs_(uplo, n, &c__1, &afp[1], &work[1], n, info); caxpy_(n, &c_b1, &work[1], &c__1, &x[j * x_dim1 + 1], &c__1); lstres = berr[j]; ++count; goto L20; } /* Bound error from formula */ /* norm(X - XTRUE) / norm(X) .le. FERR = */ /* norm( abs(inv(A))* */ /* ( abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) ))) / norm(X) */ /* where */ /* norm(Z) is the magnitude of the largest component of Z */ /* inv(A) is the inverse of A */ /* abs(Z) is the componentwise absolute value of the matrix or */ /* vector Z */ /* NZ is the maximum number of nonzeros in any row of A, plus 1 */ /* EPS is machine epsilon */ /* The i-th component of abs(R)+NZ*EPS*(abs(A)*abs(X)+abs(B)) */ /* is incremented by SAFE1 if the i-th component of */ /* abs(A)*abs(X) + abs(B) is less than SAFE2. */ /* Use CLACN2 to estimate the infinity-norm of the matrix */ /* inv(A) * diag(W), */ /* where W = abs(R) + NZ*EPS*( abs(A)*abs(X)+abs(B) ))) */ i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { if (rwork[i__] > safe2) { i__3 = i__; rwork[i__] = (r__1 = work[i__3].r, dabs(r__1)) + (r__2 = r_imag(&work[i__]), dabs(r__2)) + nz * eps * rwork[ i__]; } else { i__3 = i__; rwork[i__] = (r__1 = work[i__3].r, dabs(r__1)) + (r__2 = r_imag(&work[i__]), dabs(r__2)) + nz * eps * rwork[ i__] + safe1; } /* L90: */ } kase = 0; L100: clacn2_(n, &work[*n + 1], &work[1], &ferr[j], &kase, isave); if (kase != 0) { if (kase == 1) { /* Multiply by diag(W)*inv(A'). */ cpptrs_(uplo, n, &c__1, &afp[1], &work[1], n, info) ; i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { i__3 = i__; i__4 = i__; i__5 = i__; q__1.r = rwork[i__4] * work[i__5].r, q__1.i = rwork[i__4] * work[i__5].i; work[i__3].r = q__1.r, work[i__3].i = q__1.i; /* L110: */ } } else if (kase == 2) { /* Multiply by inv(A)*diag(W). */ i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { i__3 = i__; i__4 = i__; i__5 = i__; q__1.r = rwork[i__4] * work[i__5].r, q__1.i = rwork[i__4] * work[i__5].i; work[i__3].r = q__1.r, work[i__3].i = q__1.i; /* L120: */ } cpptrs_(uplo, n, &c__1, &afp[1], &work[1], n, info) ; } goto L100; } /* Normalize error. */ lstres = 0.f; i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { /* Computing MAX */ i__3 = i__ + j * x_dim1; r__3 = lstres, r__4 = (r__1 = x[i__3].r, dabs(r__1)) + (r__2 = r_imag(&x[i__ + j * x_dim1]), dabs(r__2)); lstres = dmax(r__3,r__4); /* L130: */ } if (lstres != 0.f) { ferr[j] /= lstres; } /* L140: */ } return 0; /* End of CPPRFS */ } /* cpprfs_ */
/* Subroutine */ int cppsv_(char *uplo, integer *n, integer *nrhs, complex * ap, complex *b, integer *ldb, integer *info) { /* -- LAPACK driver routine (version 3.0) -- Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and Rice University March 31, 1993 Purpose ======= CPPSV computes the solution to a complex system of linear equations A * X = B, where A is an N-by-N Hermitian positive definite matrix stored in packed format and X and B are N-by-NRHS matrices. The Cholesky decomposition is used to factor A as A = U**H* U, if UPLO = 'U', or A = L * L**H, if UPLO = 'L', where U is an upper triangular matrix and L is a lower triangular matrix. The factored form of A is then used to solve the system of equations A * X = B. Arguments ========= UPLO (input) CHARACTER*1 = 'U': Upper triangle of A is stored; = 'L': Lower triangle of A is stored. N (input) INTEGER The number of linear equations, i.e., the order of the matrix A. N >= 0. NRHS (input) INTEGER The number of right hand sides, i.e., the number of columns of the matrix B. NRHS >= 0. AP (input/output) COMPLEX array, dimension (N*(N+1)/2) On entry, the upper or lower triangle of the Hermitian matrix A, packed columnwise in a linear array. The j-th column of A is stored in the array AP as follows: if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. See below for further details. On exit, if INFO = 0, the factor U or L from the Cholesky factorization A = U**H*U or A = L*L**H, in the same storage format as A. B (input/output) COMPLEX array, dimension (LDB,NRHS) On entry, the N-by-NRHS right hand side matrix B. On exit, if INFO = 0, the N-by-NRHS solution matrix X. LDB (input) INTEGER The leading dimension of the array B. LDB >= max(1,N). INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value > 0: if INFO = i, the leading minor of order i of A is not positive definite, so the factorization could not be completed, and the solution has not been computed. Further Details =============== The packed storage scheme is illustrated by the following example when N = 4, UPLO = 'U': Two-dimensional storage of the Hermitian matrix A: a11 a12 a13 a14 a22 a23 a24 a33 a34 (aij = conjg(aji)) a44 Packed storage of the upper triangle of A: AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] ===================================================================== Test the input parameters. Parameter adjustments */ /* System generated locals */ integer b_dim1, b_offset, i__1; /* Local variables */ extern logical lsame_(char *, char *); extern /* Subroutine */ int xerbla_(char *, integer *), cpptrf_( char *, integer *, complex *, integer *), cpptrs_(char *, integer *, integer *, complex *, complex *, integer *, integer *); --ap; b_dim1 = *ldb; b_offset = 1 + b_dim1 * 1; b -= b_offset; /* Function Body */ *info = 0; if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) { *info = -1; } else if (*n < 0) { *info = -2; } else if (*nrhs < 0) { *info = -3; } else if (*ldb < max(1,*n)) { *info = -6; } if (*info != 0) { i__1 = -(*info); xerbla_("CPPSV ", &i__1); return 0; } /* Compute the Cholesky factorization A = U'*U or A = L*L'. */ cpptrf_(uplo, n, &ap[1], info); if (*info == 0) { /* Solve the system A*X = B, overwriting B with X. */ cpptrs_(uplo, n, nrhs, &ap[1], &b[b_offset], ldb, info); } return 0; /* End of CPPSV */ } /* cppsv_ */
/* Subroutine */ int cppsv_(char *uplo, integer *n, integer *nrhs, complex * ap, complex *b, integer *ldb, integer *info) { /* System generated locals */ integer b_dim1, b_offset, i__1; /* Local variables */ /* -- LAPACK driver routine (version 3.2) -- */ /* November 2006 */ /* Purpose */ /* ======= */ /* CPPSV computes the solution to a complex system of linear equations */ /* A * X = B, */ /* where A is an N-by-N Hermitian positive definite matrix stored in */ /* packed format and X and B are N-by-NRHS matrices. */ /* The Cholesky decomposition is used to factor A as */ /* A = U**H* U, if UPLO = 'U', or */ /* A = L * L**H, if UPLO = 'L', */ /* where U is an upper triangular matrix and L is a lower triangular */ /* matrix. The factored form of A is then used to solve the system of */ /* equations A * X = B. */ /* Arguments */ /* ========= */ /* UPLO (input) CHARACTER*1 */ /* = 'U': Upper triangle of A is stored; */ /* = 'L': Lower triangle of A is stored. */ /* N (input) INTEGER */ /* The number of linear equations, i.e., the order of the */ /* matrix A. N >= 0. */ /* NRHS (input) INTEGER */ /* The number of right hand sides, i.e., the number of columns */ /* of the matrix B. NRHS >= 0. */ /* AP (input/output) COMPLEX array, dimension (N*(N+1)/2) */ /* On entry, the upper or lower triangle of the Hermitian matrix */ /* A, packed columnwise in a linear array. The j-th column of A */ /* is stored in the array AP as follows: */ /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ /* See below for further details. */ /* On exit, if INFO = 0, the factor U or L from the Cholesky */ /* factorization A = U**H*U or A = L*L**H, in the same storage */ /* format as A. */ /* B (input/output) COMPLEX array, dimension (LDB,NRHS) */ /* On entry, the N-by-NRHS right hand side matrix B. */ /* On exit, if INFO = 0, the N-by-NRHS solution matrix X. */ /* LDB (input) INTEGER */ /* The leading dimension of the array B. LDB >= max(1,N). */ /* INFO (output) INTEGER */ /* = 0: successful exit */ /* < 0: if INFO = -i, the i-th argument had an illegal value */ /* > 0: if INFO = i, the leading minor of order i of A is not */ /* positive definite, so the factorization could not be */ /* completed, and the solution has not been computed. */ /* Further Details */ /* =============== */ /* The packed storage scheme is illustrated by the following example */ /* when N = 4, UPLO = 'U': */ /* Two-dimensional storage of the Hermitian matrix A: */ /* a11 a12 a13 a14 */ /* a22 a23 a24 */ /* a33 a34 (aij = conjg(aji)) */ /* a44 */ /* Packed storage of the upper triangle of A: */ /* AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] */ /* ===================================================================== */ /* Test the input parameters. */ /* Parameter adjustments */ --ap; b_dim1 = *ldb; b_offset = 1 + b_dim1; b -= b_offset; /* Function Body */ *info = 0; if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) { *info = -1; } else if (*n < 0) { *info = -2; } else if (*nrhs < 0) { *info = -3; } else if (*ldb < max(1,*n)) { *info = -6; } if (*info != 0) { i__1 = -(*info); xerbla_("CPPSV ", &i__1); return 0; } /* Compute the Cholesky factorization A = U'*U or A = L*L'. */ cpptrf_(uplo, n, &ap[1], info); if (*info == 0) { /* Solve the system A*X = B, overwriting B with X. */ cpptrs_(uplo, n, nrhs, &ap[1], &b[b_offset], ldb, info); } return 0; /* End of CPPSV */ } /* cppsv_ */
int main(void) { /* Local scalars */ char uplo, uplo_i; lapack_int n, n_i; lapack_int nrhs, nrhs_i; lapack_int ldb, ldb_i; lapack_int ldb_r; lapack_int info, info_i; lapack_int i; int failed; /* Local arrays */ lapack_complex_float *ap = NULL, *ap_i = NULL; lapack_complex_float *b = NULL, *b_i = NULL; lapack_complex_float *b_save = NULL; lapack_complex_float *ap_r = NULL; lapack_complex_float *b_r = NULL; /* Iniitialize the scalar parameters */ init_scalars_cpptrs( &uplo, &n, &nrhs, &ldb ); ldb_r = nrhs+2; uplo_i = uplo; n_i = n; nrhs_i = nrhs; ldb_i = ldb; /* Allocate memory for the LAPACK routine arrays */ ap = (lapack_complex_float *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) ); b = (lapack_complex_float *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) ); /* Allocate memory for the C interface function arrays */ ap_i = (lapack_complex_float *) LAPACKE_malloc( ((n*(n+1)/2)) * sizeof(lapack_complex_float) ); b_i = (lapack_complex_float *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) ); /* Allocate memory for the backup arrays */ b_save = (lapack_complex_float *) LAPACKE_malloc( ldb*nrhs * sizeof(lapack_complex_float) ); /* Allocate memory for the row-major arrays */ ap_r = (lapack_complex_float *) LAPACKE_malloc( n*(n+1)/2 * sizeof(lapack_complex_float) ); b_r = (lapack_complex_float *) LAPACKE_malloc( n*(nrhs+2) * sizeof(lapack_complex_float) ); /* Initialize input arrays */ init_ap( (n*(n+1)/2), ap ); init_b( ldb*nrhs, b ); /* Backup the ouptut arrays */ for( i = 0; i < ldb*nrhs; i++ ) { b_save[i] = b[i]; } /* Call the LAPACK routine */ cpptrs_( &uplo, &n, &nrhs, ap, b, &ldb, &info ); /* Initialize input data, call the column-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } info_i = LAPACKE_cpptrs_work( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, b_i, ldb_i ); failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: column-major middle-level interface to cpptrs\n" ); } else { printf( "FAILED: column-major middle-level interface to cpptrs\n" ); } /* Initialize input data, call the column-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } info_i = LAPACKE_cpptrs( LAPACK_COL_MAJOR, uplo_i, n_i, nrhs_i, ap_i, b_i, ldb_i ); failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: column-major high-level interface to cpptrs\n" ); } else { printf( "FAILED: column-major high-level interface to cpptrs\n" ); } /* Initialize input data, call the row-major middle-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 ); info_i = LAPACKE_cpptrs_work( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, b_r, ldb_r ); LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb ); failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: row-major middle-level interface to cpptrs\n" ); } else { printf( "FAILED: row-major middle-level interface to cpptrs\n" ); } /* Initialize input data, call the row-major high-level * interface to LAPACK routine and check the results */ for( i = 0; i < (n*(n+1)/2); i++ ) { ap_i[i] = ap[i]; } for( i = 0; i < ldb*nrhs; i++ ) { b_i[i] = b_save[i]; } /* Init row_major arrays */ LAPACKE_cpp_trans( LAPACK_COL_MAJOR, uplo, n, ap_i, ap_r ); LAPACKE_cge_trans( LAPACK_COL_MAJOR, n, nrhs, b_i, ldb, b_r, nrhs+2 ); info_i = LAPACKE_cpptrs( LAPACK_ROW_MAJOR, uplo_i, n_i, nrhs_i, ap_r, b_r, ldb_r ); LAPACKE_cge_trans( LAPACK_ROW_MAJOR, n, nrhs, b_r, nrhs+2, b_i, ldb ); failed = compare_cpptrs( b, b_i, info, info_i, ldb, nrhs ); if( failed == 0 ) { printf( "PASSED: row-major high-level interface to cpptrs\n" ); } else { printf( "FAILED: row-major high-level interface to cpptrs\n" ); } /* Release memory */ if( ap != NULL ) { LAPACKE_free( ap ); } if( ap_i != NULL ) { LAPACKE_free( ap_i ); } if( ap_r != NULL ) { LAPACKE_free( ap_r ); } if( b != NULL ) { LAPACKE_free( b ); } if( b_i != NULL ) { LAPACKE_free( b_i ); } if( b_r != NULL ) { LAPACKE_free( b_r ); } if( b_save != NULL ) { LAPACKE_free( b_save ); } return 0; }