/* Subroutine */ int spst01_(char *uplo, integer *n, real *a, integer *lda, real *afac, integer *ldafac, real *perm, integer *ldperm, integer * piv, real *rwork, real *resid, integer *rank) { /* System generated locals */ integer a_dim1, a_offset, afac_dim1, afac_offset, perm_dim1, perm_offset, i__1, i__2; /* Local variables */ integer i__, j, k; real t, eps; extern doublereal sdot_(integer *, real *, integer *, real *, integer *); extern /* Subroutine */ int ssyr_(char *, integer *, real *, real *, integer *, real *, integer *); extern logical lsame_(char *, char *); extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *); real anorm; extern /* Subroutine */ int strmv_(char *, char *, char *, integer *, real *, integer *, real *, integer *); extern doublereal slamch_(char *), slansy_(char *, char *, integer *, real *, integer *, real *); /* -- LAPACK test routine (version 3.1) -- */ /* Craig Lucas, University of Manchester / NAG Ltd. */ /* October, 2008 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SPST01 reconstructs a symmetric positive semidefinite matrix A */ /* from its L or U factors and the permutation matrix P and computes */ /* the residual */ /* norm( P*L*L'*P' - A ) / ( N * norm(A) * EPS ) or */ /* norm( P*U'*U*P' - A ) / ( N * norm(A) * EPS ), */ /* where EPS is the machine epsilon. */ /* Arguments */ /* ========== */ /* UPLO (input) CHARACTER*1 */ /* Specifies whether the upper or lower triangular part of the */ /* symmetric matrix A is stored: */ /* = 'U': Upper triangular */ /* = 'L': Lower triangular */ /* N (input) INTEGER */ /* The number of rows and columns of the matrix A. N >= 0. */ /* A (input) REAL array, dimension (LDA,N) */ /* The original symmetric matrix A. */ /* LDA (input) INTEGER */ /* The leading dimension of the array A. LDA >= max(1,N) */ /* AFAC (input) REAL array, dimension (LDAFAC,N) */ /* The factor L or U from the L*L' or U'*U */ /* factorization of A. */ /* LDAFAC (input) INTEGER */ /* The leading dimension of the array AFAC. LDAFAC >= max(1,N). */ /* PERM (output) REAL array, dimension (LDPERM,N) */ /* Overwritten with the reconstructed matrix, and then with the */ /* difference P*L*L'*P' - A (or P*U'*U*P' - A) */ /* LDPERM (input) INTEGER */ /* The leading dimension of the array PERM. */ /* LDAPERM >= max(1,N). */ /* PIV (input) INTEGER array, dimension (N) */ /* PIV is such that the nonzero entries are */ /* P( PIV( K ), K ) = 1. */ /* RWORK (workspace) REAL array, dimension (N) */ /* RESID (output) REAL */ /* If UPLO = 'L', norm(L*L' - A) / ( N * norm(A) * EPS ) */ /* If UPLO = 'U', norm(U'*U - A) / ( N * norm(A) * EPS ) */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Quick exit if N = 0. */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; afac_dim1 = *ldafac; afac_offset = 1 + afac_dim1; afac -= afac_offset; perm_dim1 = *ldperm; perm_offset = 1 + perm_dim1; perm -= perm_offset; --piv; --rwork; /* Function Body */ if (*n <= 0) { *resid = 0.f; return 0; } /* Exit with RESID = 1/EPS if ANORM = 0. */ eps = slamch_("Epsilon"); anorm = slansy_("1", uplo, n, &a[a_offset], lda, &rwork[1]); if (anorm <= 0.f) { *resid = 1.f / eps; return 0; } /* Compute the product U'*U, overwriting U. */ if (lsame_(uplo, "U")) { if (*rank < *n) { i__1 = *n; for (j = *rank + 1; j <= i__1; ++j) { i__2 = j; for (i__ = *rank + 1; i__ <= i__2; ++i__) { afac[i__ + j * afac_dim1] = 0.f; /* L100: */ } /* L110: */ } } for (k = *n; k >= 1; --k) { /* Compute the (K,K) element of the result. */ t = sdot_(&k, &afac[k * afac_dim1 + 1], &c__1, &afac[k * afac_dim1 + 1], &c__1); afac[k + k * afac_dim1] = t; /* Compute the rest of column K. */ i__1 = k - 1; strmv_("Upper", "Transpose", "Non-unit", &i__1, &afac[afac_offset] , ldafac, &afac[k * afac_dim1 + 1], &c__1); /* L120: */ } /* Compute the product L*L', overwriting L. */ } else { if (*rank < *n) { i__1 = *n; for (j = *rank + 1; j <= i__1; ++j) { i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { afac[i__ + j * afac_dim1] = 0.f; /* L130: */ } /* L140: */ } } for (k = *n; k >= 1; --k) { /* Add a multiple of column K of the factor L to each of */ /* columns K+1 through N. */ if (k + 1 <= *n) { i__1 = *n - k; ssyr_("Lower", &i__1, &c_b18, &afac[k + 1 + k * afac_dim1], & c__1, &afac[k + 1 + (k + 1) * afac_dim1], ldafac); } /* Scale column K by the diagonal element. */ t = afac[k + k * afac_dim1]; i__1 = *n - k + 1; sscal_(&i__1, &t, &afac[k + k * afac_dim1], &c__1); /* L150: */ } } /* Form P*L*L'*P' or P*U'*U*P' */ if (lsame_(uplo, "U")) { i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { if (piv[i__] <= piv[j]) { if (i__ <= j) { perm[piv[i__] + piv[j] * perm_dim1] = afac[i__ + j * afac_dim1]; } else { perm[piv[i__] + piv[j] * perm_dim1] = afac[j + i__ * afac_dim1]; } } /* L160: */ } /* L170: */ } } else { i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { if (piv[i__] >= piv[j]) { if (i__ >= j) { perm[piv[i__] + piv[j] * perm_dim1] = afac[i__ + j * afac_dim1]; } else { perm[piv[i__] + piv[j] * perm_dim1] = afac[j + i__ * afac_dim1]; } } /* L180: */ } /* L190: */ } } /* Compute the difference P*L*L'*P' - A (or P*U'*U*P' - A). */ if (lsame_(uplo, "U")) { i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { perm[i__ + j * perm_dim1] -= a[i__ + j * a_dim1]; /* L200: */ } /* L210: */ } } else { i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { perm[i__ + j * perm_dim1] -= a[i__ + j * a_dim1]; /* L220: */ } /* L230: */ } } /* Compute norm( P*L*L'P - A ) / ( N * norm(A) * EPS ), or */ /* ( P*U'*U*P' - A )/ ( N * norm(A) * EPS ). */ *resid = slansy_("1", uplo, n, &perm[perm_offset], ldafac, &rwork[1]); *resid = *resid / (real) (*n) / anorm / eps; return 0; /* End of SPST01 */ } /* spst01_ */
/* Subroutine */ int sdrvrf1_(integer *nout, integer *nn, integer *nval, real *thresh, real *a, integer *lda, real *arf, real *work) { /* Initialized data */ static integer iseedy[4] = { 1988,1989,1990,1991 }; static char uplos[1*2] = "U" "L"; static char forms[1*2] = "N" "T"; static char norms[1*4] = "M" "1" "I" "F"; /* Format strings */ static char fmt_9999[] = "(1x,\002 *** Error(s) or Failure(s) while test" "ing SLANSF ***\002)"; static char fmt_9998[] = "(1x,\002 Error in \002,a6,\002 with UPLO=" "'\002,a1,\002', FORM='\002,a1,\002', N=\002,i5)"; static char fmt_9997[] = "(1x,\002 Failure in \002,a6,\002 N=\002," "i5,\002 TYPE=\002,i5,\002 UPLO='\002,a1,\002', FORM ='\002,a1" ",\002', NORM='\002,a1,\002', test=\002,g12.5)"; static char fmt_9996[] = "(1x,\002All tests for \002,a6,\002 auxiliary r" "outine passed the \002,\002threshold (\002,i5,\002 tests run)" "\002)"; static char fmt_9995[] = "(1x,a6,\002 auxiliary routine:\002,i5,\002 out" " of \002,i5,\002 tests failed to pass the threshold\002)"; static char fmt_9994[] = "(26x,i5,\002 error message recorded (\002,a6" ",\002)\002)"; /* System generated locals */ integer a_dim1, a_offset, i__1, i__2, i__3; /* Builtin functions */ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen); integer s_wsle(cilist *), e_wsle(void), s_wsfe(cilist *), e_wsfe(void), do_fio(integer *, char *, ftnlen); /* Local variables */ integer i__, j, n, iin, iit; real eps; integer info; char norm[1], uplo[1]; integer nrun, nfail; real large; integer iseed[4]; char cform[1]; real small; integer iform; real norma; integer inorm, iuplo, nerrs; extern doublereal slamch_(char *), slarnd_(integer *, integer *), slansf_(char *, char *, char *, integer *, real *, real *), slansy_(char *, char *, integer *, real *, integer *, real *); real result[1]; extern /* Subroutine */ int strttf_(char *, char *, integer *, real *, integer *, real *, integer *); real normarf; /* Fortran I/O blocks */ static cilist io___22 = { 0, 0, 0, 0, 0 }; static cilist io___23 = { 0, 0, 0, fmt_9999, 0 }; static cilist io___24 = { 0, 0, 0, fmt_9998, 0 }; static cilist io___30 = { 0, 0, 0, 0, 0 }; static cilist io___31 = { 0, 0, 0, fmt_9999, 0 }; static cilist io___32 = { 0, 0, 0, fmt_9997, 0 }; static cilist io___33 = { 0, 0, 0, fmt_9996, 0 }; static cilist io___34 = { 0, 0, 0, fmt_9995, 0 }; static cilist io___35 = { 0, 0, 0, fmt_9994, 0 }; /* -- LAPACK test routine (version 3.2.0) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2008 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SDRVRF1 tests the LAPACK RFP routines: */ /* SLANSF */ /* Arguments */ /* ========= */ /* NOUT (input) INTEGER */ /* The unit number for output. */ /* NN (input) INTEGER */ /* The number of values of N contained in the vector NVAL. */ /* NVAL (input) INTEGER array, dimension (NN) */ /* The values of the matrix dimension N. */ /* THRESH (input) REAL */ /* The threshold value for the test ratios. A result is */ /* included in the output file if RESULT >= THRESH. To have */ /* every test ratio printed, use THRESH = 0. */ /* A (workspace) REAL array, dimension (LDA,NMAX) */ /* LDA (input) INTEGER */ /* The leading dimension of the array A. LDA >= max(1,NMAX). */ /* ARF (workspace) REAL array, dimension ((NMAX*(NMAX+1))/2). */ /* WORK (workspace) REAL array, dimension ( NMAX ) */ /* ===================================================================== */ /* .. */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. Local Arrays .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Scalars in Common .. */ /* .. */ /* .. Common blocks .. */ /* .. */ /* .. Data statements .. */ /* Parameter adjustments */ --nval; a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; --arf; --work; /* Function Body */ /* .. */ /* .. Executable Statements .. */ /* Initialize constants and the random number seed. */ nrun = 0; nfail = 0; nerrs = 0; info = 0; for (i__ = 1; i__ <= 4; ++i__) { iseed[i__ - 1] = iseedy[i__ - 1]; /* L10: */ } eps = slamch_("Precision"); small = slamch_("Safe minimum"); large = 1.f / small; small = small * *lda * *lda; large = large / *lda / *lda; i__1 = *nn; for (iin = 1; iin <= i__1; ++iin) { n = nval[iin]; for (iit = 1; iit <= 3; ++iit) { /* IIT = 1 : random matrix */ /* IIT = 2 : random matrix scaled near underflow */ /* IIT = 3 : random matrix scaled near overflow */ i__2 = n; for (j = 1; j <= i__2; ++j) { i__3 = n; for (i__ = 1; i__ <= i__3; ++i__) { a[i__ + j * a_dim1] = slarnd_(&c__2, iseed); } } if (iit == 2) { i__2 = n; for (j = 1; j <= i__2; ++j) { i__3 = n; for (i__ = 1; i__ <= i__3; ++i__) { a[i__ + j * a_dim1] *= large; } } } if (iit == 3) { i__2 = n; for (j = 1; j <= i__2; ++j) { i__3 = n; for (i__ = 1; i__ <= i__3; ++i__) { a[i__ + j * a_dim1] *= small; } } } /* Do first for UPLO = 'U', then for UPLO = 'L' */ for (iuplo = 1; iuplo <= 2; ++iuplo) { *(unsigned char *)uplo = *(unsigned char *)&uplos[iuplo - 1]; /* Do first for CFORM = 'N', then for CFORM = 'C' */ for (iform = 1; iform <= 2; ++iform) { *(unsigned char *)cform = *(unsigned char *)&forms[iform - 1]; s_copy(srnamc_1.srnamt, "STRTTF", (ftnlen)32, (ftnlen)6); strttf_(cform, uplo, &n, &a[a_offset], lda, &arf[1], & info); /* Check error code from STRTTF */ if (info != 0) { if (nfail == 0 && nerrs == 0) { io___22.ciunit = *nout; s_wsle(&io___22); e_wsle(); io___23.ciunit = *nout; s_wsfe(&io___23); e_wsfe(); } io___24.ciunit = *nout; s_wsfe(&io___24); do_fio(&c__1, srnamc_1.srnamt, (ftnlen)32); do_fio(&c__1, uplo, (ftnlen)1); do_fio(&c__1, cform, (ftnlen)1); do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer)); e_wsfe(); ++nerrs; goto L100; } for (inorm = 1; inorm <= 4; ++inorm) { /* Check all four norms: 'M', '1', 'I', 'F' */ *(unsigned char *)norm = *(unsigned char *)&norms[ inorm - 1]; normarf = slansf_(norm, cform, uplo, &n, &arf[1], & work[1]); norma = slansy_(norm, uplo, &n, &a[a_offset], lda, & work[1]); result[0] = (norma - normarf) / norma / eps; ++nrun; if (result[0] >= *thresh) { if (nfail == 0 && nerrs == 0) { io___30.ciunit = *nout; s_wsle(&io___30); e_wsle(); io___31.ciunit = *nout; s_wsfe(&io___31); e_wsfe(); } io___32.ciunit = *nout; s_wsfe(&io___32); do_fio(&c__1, "SLANSF", (ftnlen)6); do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer)) ; do_fio(&c__1, (char *)&iit, (ftnlen)sizeof( integer)); do_fio(&c__1, uplo, (ftnlen)1); do_fio(&c__1, cform, (ftnlen)1); do_fio(&c__1, norm, (ftnlen)1); do_fio(&c__1, (char *)&result[0], (ftnlen)sizeof( real)); e_wsfe(); ++nfail; } /* L90: */ } L100: ; } /* L110: */ } /* L120: */ } /* L130: */ } /* Print a summary of the results. */ if (nfail == 0) { io___33.ciunit = *nout; s_wsfe(&io___33); do_fio(&c__1, "SLANSF", (ftnlen)6); do_fio(&c__1, (char *)&nrun, (ftnlen)sizeof(integer)); e_wsfe(); } else { io___34.ciunit = *nout; s_wsfe(&io___34); do_fio(&c__1, "SLANSF", (ftnlen)6); do_fio(&c__1, (char *)&nfail, (ftnlen)sizeof(integer)); do_fio(&c__1, (char *)&nrun, (ftnlen)sizeof(integer)); e_wsfe(); } if (nerrs != 0) { io___35.ciunit = *nout; s_wsfe(&io___35); do_fio(&c__1, (char *)&nerrs, (ftnlen)sizeof(integer)); do_fio(&c__1, "SLANSF", (ftnlen)6); e_wsfe(); } return 0; /* End of SDRVRF1 */ } /* sdrvrf1_ */
/* Subroutine */ int sstt22_(integer *n, integer *m, integer *kband, real *ad, real *ae, real *sd, real *se, real *u, integer *ldu, real *work, integer *ldwork, real *result) { /* System generated locals */ integer u_dim1, u_offset, work_dim1, work_offset, i__1, i__2, i__3; real r__1, r__2, r__3, r__4, r__5; /* Local variables */ integer i__, j, k; real ulp, aukj, unfl; extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, integer *, real *, real *, integer *, real *, integer *, real *, real *, integer *); real anorm, wnorm; extern doublereal slamch_(char *), slange_(char *, integer *, integer *, real *, integer *, real *), slansy_(char *, char *, integer *, real *, integer *, real *); /* -- LAPACK test routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SSTT22 checks a set of M eigenvalues and eigenvectors, */ /* A U = U S */ /* where A is symmetric tridiagonal, the columns of U are orthogonal, */ /* and S is diagonal (if KBAND=0) or symmetric tridiagonal (if KBAND=1). */ /* Two tests are performed: */ /* RESULT(1) = | U' A U - S | / ( |A| m ulp ) */ /* RESULT(2) = | I - U'U | / ( m ulp ) */ /* Arguments */ /* ========= */ /* N (input) INTEGER */ /* The size of the matrix. If it is zero, SSTT22 does nothing. */ /* It must be at least zero. */ /* M (input) INTEGER */ /* The number of eigenpairs to check. If it is zero, SSTT22 */ /* does nothing. It must be at least zero. */ /* KBAND (input) INTEGER */ /* The bandwidth of the matrix S. It may only be zero or one. */ /* If zero, then S is diagonal, and SE is not referenced. If */ /* one, then S is symmetric tri-diagonal. */ /* AD (input) REAL array, dimension (N) */ /* The diagonal of the original (unfactored) matrix A. A is */ /* assumed to be symmetric tridiagonal. */ /* AE (input) REAL array, dimension (N) */ /* The off-diagonal of the original (unfactored) matrix A. A */ /* is assumed to be symmetric tridiagonal. AE(1) is ignored, */ /* AE(2) is the (1,2) and (2,1) element, etc. */ /* SD (input) REAL array, dimension (N) */ /* The diagonal of the (symmetric tri-) diagonal matrix S. */ /* SE (input) REAL array, dimension (N) */ /* The off-diagonal of the (symmetric tri-) diagonal matrix S. */ /* Not referenced if KBSND=0. If KBAND=1, then AE(1) is */ /* ignored, SE(2) is the (1,2) and (2,1) element, etc. */ /* U (input) REAL array, dimension (LDU, N) */ /* The orthogonal matrix in the decomposition. */ /* LDU (input) INTEGER */ /* The leading dimension of U. LDU must be at least N. */ /* WORK (workspace) REAL array, dimension (LDWORK, M+1) */ /* LDWORK (input) INTEGER */ /* The leading dimension of WORK. LDWORK must be at least */ /* max(1,M). */ /* RESULT (output) REAL array, dimension (2) */ /* The values computed by the two tests described above. The */ /* values are currently limited to 1/ulp, to avoid overflow. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Parameter adjustments */ --ad; --ae; --sd; --se; u_dim1 = *ldu; u_offset = 1 + u_dim1; u -= u_offset; work_dim1 = *ldwork; work_offset = 1 + work_dim1; work -= work_offset; --result; /* Function Body */ result[1] = 0.f; result[2] = 0.f; if (*n <= 0 || *m <= 0) { return 0; } unfl = slamch_("Safe minimum"); ulp = slamch_("Epsilon"); /* Do Test 1 */ /* Compute the 1-norm of A. */ if (*n > 1) { anorm = dabs(ad[1]) + dabs(ae[1]); i__1 = *n - 1; for (j = 2; j <= i__1; ++j) { /* Computing MAX */ r__4 = anorm, r__5 = (r__1 = ad[j], dabs(r__1)) + (r__2 = ae[j], dabs(r__2)) + (r__3 = ae[j - 1], dabs(r__3)); anorm = dmax(r__4,r__5); /* L10: */ } /* Computing MAX */ r__3 = anorm, r__4 = (r__1 = ad[*n], dabs(r__1)) + (r__2 = ae[*n - 1], dabs(r__2)); anorm = dmax(r__3,r__4); } else { anorm = dabs(ad[1]); } anorm = dmax(anorm,unfl); /* Norm of U'AU - S */ i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *m; for (j = 1; j <= i__2; ++j) { work[i__ + j * work_dim1] = 0.f; i__3 = *n; for (k = 1; k <= i__3; ++k) { aukj = ad[k] * u[k + j * u_dim1]; if (k != *n) { aukj += ae[k] * u[k + 1 + j * u_dim1]; } if (k != 1) { aukj += ae[k - 1] * u[k - 1 + j * u_dim1]; } work[i__ + j * work_dim1] += u[k + i__ * u_dim1] * aukj; /* L20: */ } /* L30: */ } work[i__ + i__ * work_dim1] -= sd[i__]; if (*kband == 1) { if (i__ != 1) { work[i__ + (i__ - 1) * work_dim1] -= se[i__ - 1]; } if (i__ != *n) { work[i__ + (i__ + 1) * work_dim1] -= se[i__]; } } /* L40: */ } wnorm = slansy_("1", "L", m, &work[work_offset], m, &work[(*m + 1) * work_dim1 + 1]); if (anorm > wnorm) { result[1] = wnorm / anorm / (*m * ulp); } else { if (anorm < 1.f) { /* Computing MIN */ r__1 = wnorm, r__2 = *m * anorm; result[1] = dmin(r__1,r__2) / anorm / (*m * ulp); } else { /* Computing MIN */ r__1 = wnorm / anorm, r__2 = (real) (*m); result[1] = dmin(r__1,r__2) / (*m * ulp); } } /* Do Test 2 */ /* Compute U'U - I */ sgemm_("T", "N", m, m, n, &c_b12, &u[u_offset], ldu, &u[u_offset], ldu, & c_b13, &work[work_offset], m); i__1 = *m; for (j = 1; j <= i__1; ++j) { work[j + j * work_dim1] += -1.f; /* L50: */ } /* Computing MIN */ r__1 = (real) (*m), r__2 = slange_("1", m, m, &work[work_offset], m, & work[(*m + 1) * work_dim1 + 1]); result[2] = dmin(r__1,r__2) / (*m * ulp); return 0; /* End of SSTT22 */ } /* sstt22_ */
/* Subroutine */ int slqt02_(integer *m, integer *n, integer *k, real *a, real *af, real *q, real *l, integer *lda, real *tau, real *work, integer *lwork, real *rwork, real *result) { /* System generated locals */ integer a_dim1, a_offset, af_dim1, af_offset, l_dim1, l_offset, q_dim1, q_offset, i__1; /* Builtin functions Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen); /* Local variables */ static integer info; static real resid; extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, integer *, real *, real *, integer *, real *, integer *, real *, real *, integer *); static real anorm; extern /* Subroutine */ int ssyrk_(char *, char *, integer *, integer *, real *, real *, integer *, real *, real *, integer *); extern doublereal slamch_(char *), slange_(char *, integer *, integer *, real *, integer *, real *); extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, integer *, real *, integer *), slaset_(char *, integer *, integer *, real *, real *, real *, integer *), sorglq_( integer *, integer *, integer *, real *, integer *, real *, real * , integer *, integer *); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); static real eps; #define q_ref(a_1,a_2) q[(a_2)*q_dim1 + a_1] #define af_ref(a_1,a_2) af[(a_2)*af_dim1 + a_1] /* -- LAPACK test routine (version 3.0) -- Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and Rice University September 30, 1994 Purpose ======= SLQT02 tests SORGLQ, which generates an m-by-n matrix Q with orthonornmal rows that is defined as the product of k elementary reflectors. Given the LQ factorization of an m-by-n matrix A, SLQT02 generates the orthogonal matrix Q defined by the factorization of the first k rows of A; it compares L(1:k,1:m) with A(1:k,1:n)*Q(1:m,1:n)', and checks that the rows of Q are orthonormal. Arguments ========= M (input) INTEGER The number of rows of the matrix Q to be generated. M >= 0. N (input) INTEGER The number of columns of the matrix Q to be generated. N >= M >= 0. K (input) INTEGER The number of elementary reflectors whose product defines the matrix Q. M >= K >= 0. A (input) REAL array, dimension (LDA,N) The m-by-n matrix A which was factorized by SLQT01. AF (input) REAL array, dimension (LDA,N) Details of the LQ factorization of A, as returned by SGELQF. See SGELQF for further details. Q (workspace) REAL array, dimension (LDA,N) L (workspace) REAL array, dimension (LDA,M) LDA (input) INTEGER The leading dimension of the arrays A, AF, Q and L. LDA >= N. TAU (input) REAL array, dimension (M) The scalar factors of the elementary reflectors corresponding to the LQ factorization in AF. WORK (workspace) REAL array, dimension (LWORK) LWORK (input) INTEGER The dimension of the array WORK. RWORK (workspace) REAL array, dimension (M) RESULT (output) REAL array, dimension (2) The test ratios: RESULT(1) = norm( L - A*Q' ) / ( N * norm(A) * EPS ) RESULT(2) = norm( I - Q*Q' ) / ( N * EPS ) ===================================================================== Parameter adjustments */ l_dim1 = *lda; l_offset = 1 + l_dim1 * 1; l -= l_offset; q_dim1 = *lda; q_offset = 1 + q_dim1 * 1; q -= q_offset; af_dim1 = *lda; af_offset = 1 + af_dim1 * 1; af -= af_offset; a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; --tau; --work; --rwork; --result; /* Function Body */ eps = slamch_("Epsilon"); /* Copy the first k rows of the factorization to the array Q */ slaset_("Full", m, n, &c_b4, &c_b4, &q[q_offset], lda); i__1 = *n - 1; slacpy_("Upper", k, &i__1, &af_ref(1, 2), lda, &q_ref(1, 2), lda); /* Generate the first n columns of the matrix Q */ s_copy(srnamc_1.srnamt, "SORGLQ", (ftnlen)6, (ftnlen)6); sorglq_(m, n, k, &q[q_offset], lda, &tau[1], &work[1], lwork, &info); /* Copy L(1:k,1:m) */ slaset_("Full", k, m, &c_b9, &c_b9, &l[l_offset], lda); slacpy_("Lower", k, m, &af[af_offset], lda, &l[l_offset], lda); /* Compute L(1:k,1:m) - A(1:k,1:n) * Q(1:m,1:n)' */ sgemm_("No transpose", "Transpose", k, m, n, &c_b14, &a[a_offset], lda, & q[q_offset], lda, &c_b15, &l[l_offset], lda); /* Compute norm( L - A*Q' ) / ( N * norm(A) * EPS ) . */ anorm = slange_("1", k, n, &a[a_offset], lda, &rwork[1]); resid = slange_("1", k, m, &l[l_offset], lda, &rwork[1]); if (anorm > 0.f) { result[1] = resid / (real) max(1,*n) / anorm / eps; } else { result[1] = 0.f; } /* Compute I - Q*Q' */ slaset_("Full", m, m, &c_b9, &c_b15, &l[l_offset], lda); ssyrk_("Upper", "No transpose", m, n, &c_b14, &q[q_offset], lda, &c_b15, & l[l_offset], lda); /* Compute norm( I - Q*Q' ) / ( N * EPS ) . */ resid = slansy_("1", "Upper", m, &l[l_offset], lda, &rwork[1]); result[2] = resid / (real) max(1,*n) / eps; return 0; /* End of SLQT02 */ } /* slqt02_ */
/* Subroutine */ int sgqrts_(integer *n, integer *m, integer *p, real *a, real *af, real *q, real *r__, integer *lda, real *taua, real *b, real *bf, real *z__, real *t, real *bwk, integer *ldb, real *taub, real * work, integer *lwork, real *rwork, real *result) { /* System generated locals */ integer a_dim1, a_offset, af_dim1, af_offset, r_dim1, r_offset, q_dim1, q_offset, b_dim1, b_offset, bf_dim1, bf_offset, t_dim1, t_offset, z_dim1, z_offset, bwk_dim1, bwk_offset, i__1, i__2; real r__1; /* Local variables */ static integer info; static real unfl, resid; extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, integer *, real *, real *, integer *, real *, integer *, real *, real *, integer *); static real anorm, bnorm; extern /* Subroutine */ int ssyrk_(char *, char *, integer *, integer *, real *, real *, integer *, real *, real *, integer *); extern doublereal slamch_(char *), slange_(char *, integer *, integer *, real *, integer *, real *); extern /* Subroutine */ int sggqrf_(integer *, integer *, integer *, real *, integer *, real *, real *, integer *, real *, real *, integer * , integer *), slacpy_(char *, integer *, integer *, real *, integer *, real *, integer *), slaset_(char *, integer *, integer *, real *, real *, real *, integer *); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); extern /* Subroutine */ int sorgqr_(integer *, integer *, integer *, real *, integer *, real *, real *, integer *, integer *), sorgrq_( integer *, integer *, integer *, real *, integer *, real *, real * , integer *, integer *); static real ulp; #define q_ref(a_1,a_2) q[(a_2)*q_dim1 + a_1] #define t_ref(a_1,a_2) t[(a_2)*t_dim1 + a_1] #define z___ref(a_1,a_2) z__[(a_2)*z_dim1 + a_1] #define af_ref(a_1,a_2) af[(a_2)*af_dim1 + a_1] #define bf_ref(a_1,a_2) bf[(a_2)*bf_dim1 + a_1] /* -- LAPACK test routine (version 3.0) -- Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and Rice University September 30, 1994 Purpose ======= SGQRTS tests SGGQRF, which computes the GQR factorization of an N-by-M matrix A and a N-by-P matrix B: A = Q*R and B = Q*T*Z. Arguments ========= N (input) INTEGER The number of rows of the matrices A and B. N >= 0. M (input) INTEGER The number of columns of the matrix A. M >= 0. P (input) INTEGER The number of columns of the matrix B. P >= 0. A (input) REAL array, dimension (LDA,M) The N-by-M matrix A. AF (output) REAL array, dimension (LDA,N) Details of the GQR factorization of A and B, as returned by SGGQRF, see SGGQRF for further details. Q (output) REAL array, dimension (LDA,N) The M-by-M orthogonal matrix Q. R (workspace) REAL array, dimension (LDA,MAX(M,N)) LDA (input) INTEGER The leading dimension of the arrays A, AF, R and Q. LDA >= max(M,N). TAUA (output) REAL array, dimension (min(M,N)) The scalar factors of the elementary reflectors, as returned by SGGQRF. B (input) REAL array, dimension (LDB,P) On entry, the N-by-P matrix A. BF (output) REAL array, dimension (LDB,N) Details of the GQR factorization of A and B, as returned by SGGQRF, see SGGQRF for further details. Z (output) REAL array, dimension (LDB,P) The P-by-P orthogonal matrix Z. T (workspace) REAL array, dimension (LDB,max(P,N)) BWK (workspace) REAL array, dimension (LDB,N) LDB (input) INTEGER The leading dimension of the arrays B, BF, Z and T. LDB >= max(P,N). TAUB (output) REAL array, dimension (min(P,N)) The scalar factors of the elementary reflectors, as returned by SGGRQF. WORK (workspace) REAL array, dimension (LWORK) LWORK (input) INTEGER The dimension of the array WORK, LWORK >= max(N,M,P)**2. RWORK (workspace) REAL array, dimension (max(N,M,P)) RESULT (output) REAL array, dimension (4) The test ratios: RESULT(1) = norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP) RESULT(2) = norm( T*Z - Q'*B ) / (MAX(P,N)*norm(B)*ULP) RESULT(3) = norm( I - Q'*Q ) / ( M*ULP ) RESULT(4) = norm( I - Z'*Z ) / ( P*ULP ) ===================================================================== Parameter adjustments */ r_dim1 = *lda; r_offset = 1 + r_dim1 * 1; r__ -= r_offset; q_dim1 = *lda; q_offset = 1 + q_dim1 * 1; q -= q_offset; af_dim1 = *lda; af_offset = 1 + af_dim1 * 1; af -= af_offset; a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; --taua; bwk_dim1 = *ldb; bwk_offset = 1 + bwk_dim1 * 1; bwk -= bwk_offset; t_dim1 = *ldb; t_offset = 1 + t_dim1 * 1; t -= t_offset; z_dim1 = *ldb; z_offset = 1 + z_dim1 * 1; z__ -= z_offset; bf_dim1 = *ldb; bf_offset = 1 + bf_dim1 * 1; bf -= bf_offset; b_dim1 = *ldb; b_offset = 1 + b_dim1 * 1; b -= b_offset; --taub; --work; --rwork; --result; /* Function Body */ ulp = slamch_("Precision"); unfl = slamch_("Safe minimum"); /* Copy the matrix A to the array AF. */ slacpy_("Full", n, m, &a[a_offset], lda, &af[af_offset], lda); slacpy_("Full", n, p, &b[b_offset], ldb, &bf[bf_offset], ldb); /* Computing MAX */ r__1 = slange_("1", n, m, &a[a_offset], lda, &rwork[1]); anorm = dmax(r__1,unfl); /* Computing MAX */ r__1 = slange_("1", n, p, &b[b_offset], ldb, &rwork[1]); bnorm = dmax(r__1,unfl); /* Factorize the matrices A and B in the arrays AF and BF. */ sggqrf_(n, m, p, &af[af_offset], lda, &taua[1], &bf[bf_offset], ldb, & taub[1], &work[1], lwork, &info); /* Generate the N-by-N matrix Q */ slaset_("Full", n, n, &c_b9, &c_b9, &q[q_offset], lda); i__1 = *n - 1; slacpy_("Lower", &i__1, m, &af_ref(2, 1), lda, &q_ref(2, 1), lda); i__1 = min(*n,*m); sorgqr_(n, n, &i__1, &q[q_offset], lda, &taua[1], &work[1], lwork, &info); /* Generate the P-by-P matrix Z */ slaset_("Full", p, p, &c_b9, &c_b9, &z__[z_offset], ldb); if (*n <= *p) { if (*n > 0 && *n < *p) { i__1 = *p - *n; slacpy_("Full", n, &i__1, &bf[bf_offset], ldb, &z___ref(*p - *n + 1, 1), ldb); } if (*n > 1) { i__1 = *n - 1; i__2 = *n - 1; slacpy_("Lower", &i__1, &i__2, &bf_ref(2, *p - *n + 1), ldb, & z___ref(*p - *n + 2, *p - *n + 1), ldb); } } else { if (*p > 1) { i__1 = *p - 1; i__2 = *p - 1; slacpy_("Lower", &i__1, &i__2, &bf_ref(*n - *p + 2, 1), ldb, & z___ref(2, 1), ldb); } } i__1 = min(*n,*p); sorgrq_(p, p, &i__1, &z__[z_offset], ldb, &taub[1], &work[1], lwork, & info); /* Copy R */ slaset_("Full", n, m, &c_b19, &c_b19, &r__[r_offset], lda); slacpy_("Upper", n, m, &af[af_offset], lda, &r__[r_offset], lda); /* Copy T */ slaset_("Full", n, p, &c_b19, &c_b19, &t[t_offset], ldb); if (*n <= *p) { slacpy_("Upper", n, n, &bf_ref(1, *p - *n + 1), ldb, &t_ref(1, *p - * n + 1), ldb); } else { i__1 = *n - *p; slacpy_("Full", &i__1, p, &bf[bf_offset], ldb, &t[t_offset], ldb); slacpy_("Upper", p, p, &bf_ref(*n - *p + 1, 1), ldb, &t_ref(*n - *p + 1, 1), ldb); } /* Compute R - Q'*A */ sgemm_("Transpose", "No transpose", n, m, n, &c_b30, &q[q_offset], lda, & a[a_offset], lda, &c_b31, &r__[r_offset], lda); /* Compute norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP ) . */ resid = slange_("1", n, m, &r__[r_offset], lda, &rwork[1]); if (anorm > 0.f) { /* Computing MAX */ i__1 = max(1,*m); result[1] = resid / (real) max(i__1,*n) / anorm / ulp; } else { result[1] = 0.f; } /* Compute T*Z - Q'*B */ sgemm_("No Transpose", "No transpose", n, p, p, &c_b31, &t[t_offset], ldb, &z__[z_offset], ldb, &c_b19, &bwk[bwk_offset], ldb); sgemm_("Transpose", "No transpose", n, p, n, &c_b30, &q[q_offset], lda, & b[b_offset], ldb, &c_b31, &bwk[bwk_offset], ldb); /* Compute norm( T*Z - Q'*B ) / ( MAX(P,N)*norm(A)*ULP ) . */ resid = slange_("1", n, p, &bwk[bwk_offset], ldb, &rwork[1]); if (bnorm > 0.f) { /* Computing MAX */ i__1 = max(1,*p); result[2] = resid / (real) max(i__1,*n) / bnorm / ulp; } else { result[2] = 0.f; } /* Compute I - Q'*Q */ slaset_("Full", n, n, &c_b19, &c_b31, &r__[r_offset], lda); ssyrk_("Upper", "Transpose", n, n, &c_b30, &q[q_offset], lda, &c_b31, & r__[r_offset], lda); /* Compute norm( I - Q'*Q ) / ( N * ULP ) . */ resid = slansy_("1", "Upper", n, &r__[r_offset], lda, &rwork[1]); result[3] = resid / (real) max(1,*n) / ulp; /* Compute I - Z'*Z */ slaset_("Full", p, p, &c_b19, &c_b31, &t[t_offset], ldb); ssyrk_("Upper", "Transpose", p, p, &c_b30, &z__[z_offset], ldb, &c_b31, & t[t_offset], ldb); /* Compute norm( I - Z'*Z ) / ( P*ULP ) . */ resid = slansy_("1", "Upper", p, &t[t_offset], ldb, &rwork[1]); result[4] = resid / (real) max(1,*p) / ulp; return 0; /* End of SGQRTS */ } /* sgqrts_ */
/* Subroutine */ int sposvx_(char *fact, char *uplo, integer *n, integer * nrhs, real *a, integer *lda, real *af, integer *ldaf, char *equed, real *s, real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, real *berr, real *work, integer *iwork, integer *info) { /* -- LAPACK driver routine (version 2.0) -- Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and Rice University September 30, 1994 Purpose ======= SPOSVX uses the Cholesky factorization A = U**T*U or A = L*L**T to compute the solution to a real system of linear equations A * X = B, where A is an N-by-N symmetric positive definite matrix 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**T* U, if UPLO = 'U', or A = L * L**T, if UPLO = 'L', where U is an upper triangular matrix and L is a lower triangular matrix. 3. 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, steps 4-6 are skipped. 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, AF contains the factored form of A. If EQUED = 'Y', the matrix A has been equilibrated with scaling factors given by S. A and AF will not be modified. = 'N': The matrix A will be copied to AF and factored. = 'E': The matrix A will be equilibrated if necessary, then copied to AF 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. A (input/output) REAL array, dimension (LDA,N) On entry, the symmetric matrix A, except if FACT = 'F' and EQUED = 'Y', then A must contain the equilibrated matrix diag(S)*A*diag(S). If UPLO = 'U', the leading N-by-N upper triangular part of A contains the upper triangular part of the matrix A, and the strictly lower triangular part of A is not referenced. If UPLO = 'L', the leading N-by-N lower triangular part of A contains the lower triangular part of the matrix A, and the strictly upper triangular part of A is not referenced. 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). LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,N). AF (input or output) REAL array, dimension (LDAF,N) If FACT = 'F', then AF is an input argument and on entry contains the triangular factor U or L from the Cholesky factorization A = U**T*U or A = L*L**T, in the same storage format as A. If EQUED .ne. 'N', then AF is the factored form of the equilibrated matrix diag(S)*A*diag(S). If FACT = 'N', then AF is an output argument and on exit returns the triangular factor U or L from the Cholesky factorization A = U**T*U or A = L*L**T of the original matrix A. If FACT = 'E', then AF is an output argument and on exit returns the triangular factor U or L from the Cholesky factorization A = U**T*U or A = L*L**T of the equilibrated matrix A (see the description of A for the form of the equilibrated matrix). LDAF (input) INTEGER The leading dimension of the array AF. LDAF >= max(1,N). 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) REAL 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) REAL array, dimension (LDX,NRHS) If INFO = 0, 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, and the solution and error bounds are not computed. 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) REAL array, dimension (3*N) IWORK (workspace) INTEGER 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 and error bounds could not be computed. = N+1: RCOND is less than machine precision. The factorization has been completed, but the matrix is singular to working precision, and the solution and error bounds have not been computed. ===================================================================== Parameter adjustments Function Body */ /* System generated locals */ integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1, x_offset, i__1, i__2; real r__1, r__2; /* Local variables */ static real amax, smin, smax; static integer i, j; extern logical lsame_(char *, char *); static real scond, anorm; static logical equil, rcequ; extern doublereal slamch_(char *); static logical nofact; extern /* Subroutine */ int xerbla_(char *, integer *); static real bignum; static integer infequ; extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, integer *, real *, integer *), spocon_(char *, integer *, real *, integer *, real *, real *, real *, integer *, integer *); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); static real smlnum; extern /* Subroutine */ int slaqsy_(char *, integer *, real *, integer *, real *, real *, real *, char *), spoequ_(integer * , real *, integer *, real *, real *, real *, integer *), sporfs_( char *, integer *, integer *, real *, integer *, real *, integer * , real *, integer *, real *, integer *, real *, real *, real *, integer *, integer *), spotrf_(char *, integer *, real *, integer *, integer *), spotrs_(char *, integer *, integer *, real *, integer *, real *, integer *, integer *); #define S(I) s[(I)-1] #define FERR(I) ferr[(I)-1] #define BERR(I) berr[(I)-1] #define WORK(I) work[(I)-1] #define IWORK(I) iwork[(I)-1] #define A(I,J) a[(I)-1 + ((J)-1)* ( *lda)] #define AF(I,J) af[(I)-1 + ((J)-1)* ( *ldaf)] #define B(I,J) b[(I)-1 + ((J)-1)* ( *ldb)] #define X(I,J) x[(I)-1 + ((J)-1)* ( *ldx)] *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 (*lda < max(1,*n)) { *info = -6; } else if (*ldaf < max(1,*n)) { *info = -8; } else if (lsame_(fact, "F") && ! (rcequ || lsame_(equed, "N"))) { *info = -9; } else { if (rcequ) { smin = bignum; smax = 0.f; i__1 = *n; for (j = 1; j <= *n; ++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); /* L10: */ } if (smin <= 0.f) { *info = -10; } else if (*n > 0) { scond = dmax(smin,smlnum) / dmin(smax,bignum); } else { scond = 1.f; } } if (*info == 0) { if (*ldb < max(1,*n)) { *info = -12; } else if (*ldx < max(1,*n)) { *info = -14; } } } if (*info != 0) { i__1 = -(*info); xerbla_("SPOSVX", &i__1); return 0; } if (equil) { /* Compute row and column scalings to equilibrate the matrix A. */ spoequ_(n, &A(1,1), lda, &S(1), &scond, &amax, &infequ); if (infequ == 0) { /* Equilibrate the matrix. */ slaqsy_(uplo, n, &A(1,1), lda, &S(1), &scond, &amax, equed); rcequ = lsame_(equed, "Y"); } } /* Scale the right hand side. */ if (rcequ) { i__1 = *nrhs; for (j = 1; j <= *nrhs; ++j) { i__2 = *n; for (i = 1; i <= *n; ++i) { B(i,j) = S(i) * B(i,j); /* L20: */ } /* L30: */ } } if (nofact || equil) { /* Compute the Cholesky factorization A = U'*U or A = L*L'. */ slacpy_(uplo, n, n, &A(1,1), lda, &AF(1,1), ldaf); spotrf_(uplo, n, &AF(1,1), ldaf, info); /* Return if INFO is non-zero. */ if (*info != 0) { if (*info > 0) { *rcond = 0.f; } return 0; } } /* Compute the norm of the matrix A. */ anorm = slansy_("1", uplo, n, &A(1,1), lda, &WORK(1)); /* Compute the reciprocal of the condition number of A. */ spocon_(uplo, n, &AF(1,1), ldaf, &anorm, rcond, &WORK(1), &IWORK(1), info); /* Return if the matrix is singular to working precision. */ if (*rcond < slamch_("Epsilon")) { *info = *n + 1; return 0; } /* Compute the solution matrix X. */ slacpy_("Full", n, nrhs, &B(1,1), ldb, &X(1,1), ldx); spotrs_(uplo, n, nrhs, &AF(1,1), ldaf, &X(1,1), ldx, info); /* Use iterative refinement to improve the computed solution and compute error bounds and backward error estimates for it. */ sporfs_(uplo, n, nrhs, &A(1,1), lda, &AF(1,1), ldaf, &B(1,1), ldb, &X(1,1), ldx, &FERR(1), &BERR(1), &WORK(1), & IWORK(1), info); /* Transform the solution matrix X to a solution of the original system. */ if (rcequ) { i__1 = *nrhs; for (j = 1; j <= *nrhs; ++j) { i__2 = *n; for (i = 1; i <= *n; ++i) { X(i,j) = S(i) * X(i,j); /* L40: */ } /* L50: */ } i__1 = *nrhs; for (j = 1; j <= *nrhs; ++j) { FERR(j) /= scond; /* L60: */ } } return 0; /* End of SPOSVX */ } /* sposvx_ */
/* Subroutine */ int sposvx_(char *fact, char *uplo, integer *n, integer * nrhs, real *a, integer *lda, real *af, integer *ldaf, char *equed, real *s, real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, real *berr, real *work, integer *iwork, integer *info, ftnlen fact_len, ftnlen uplo_len, ftnlen equed_len) { /* System generated locals */ integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1, x_offset, i__1, i__2; real r__1, r__2; /* Local variables */ static integer i__, j; static real amax, smin, smax; extern logical lsame_(char *, char *, ftnlen, ftnlen); static real scond, anorm; static logical equil, rcequ; extern doublereal slamch_(char *, ftnlen); static logical nofact; extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen); static real bignum; static integer infequ; extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, integer *, real *, integer *, ftnlen), spocon_(char *, integer *, real *, integer *, real *, real *, real *, integer *, integer *, ftnlen); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *, ftnlen, ftnlen); static real smlnum; extern /* Subroutine */ int slaqsy_(char *, integer *, real *, integer *, real *, real *, real *, char *, ftnlen, ftnlen), spoequ_(integer * , real *, integer *, real *, real *, real *, integer *), sporfs_( char *, integer *, integer *, real *, integer *, real *, integer * , real *, integer *, real *, integer *, real *, real *, real *, integer *, integer *, ftnlen), spotrf_(char *, integer *, real *, integer *, integer *, ftnlen), spotrs_(char *, integer *, integer *, real *, integer *, real *, integer *, integer *, ftnlen); /* -- LAPACK driver routine (version 3.0) -- */ /* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */ /* Courant Institute, Argonne National Lab, and Rice University */ /* June 30, 1999 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SPOSVX uses the Cholesky factorization A = U**T*U or A = L*L**T to */ /* compute the solution to a real system of linear equations */ /* A * X = B, */ /* where A is an N-by-N symmetric positive definite matrix 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**T* U, if UPLO = 'U', or */ /* A = L * L**T, if UPLO = 'L', */ /* where U is an upper triangular matrix and L is a lower triangular */ /* matrix. */ /* 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, AF contains the factored form of A. */ /* If EQUED = 'Y', the matrix A has been equilibrated */ /* with scaling factors given by S. A and AF will not */ /* be modified. */ /* = 'N': The matrix A will be copied to AF and factored. */ /* = 'E': The matrix A will be equilibrated if necessary, then */ /* copied to AF 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. */ /* A (input/output) REAL array, dimension (LDA,N) */ /* On entry, the symmetric matrix A, except if FACT = 'F' and */ /* EQUED = 'Y', then A must contain the equilibrated matrix */ /* diag(S)*A*diag(S). If UPLO = 'U', the leading */ /* N-by-N upper triangular part of A contains the upper */ /* triangular part of the matrix A, and the strictly lower */ /* triangular part of A is not referenced. If UPLO = 'L', the */ /* leading N-by-N lower triangular part of A contains the lower */ /* triangular part of the matrix A, and the strictly upper */ /* triangular part of A is not referenced. 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). */ /* LDA (input) INTEGER */ /* The leading dimension of the array A. LDA >= max(1,N). */ /* AF (input or output) REAL array, dimension (LDAF,N) */ /* If FACT = 'F', then AF is an input argument and on entry */ /* contains the triangular factor U or L from the Cholesky */ /* factorization A = U**T*U or A = L*L**T, in the same storage */ /* format as A. If EQUED .ne. 'N', then AF is the factored form */ /* of the equilibrated matrix diag(S)*A*diag(S). */ /* If FACT = 'N', then AF is an output argument and on exit */ /* returns the triangular factor U or L from the Cholesky */ /* factorization A = U**T*U or A = L*L**T of the original */ /* matrix A. */ /* If FACT = 'E', then AF is an output argument and on exit */ /* returns the triangular factor U or L from the Cholesky */ /* factorization A = U**T*U or A = L*L**T of the equilibrated */ /* matrix A (see the description of A for the form of the */ /* equilibrated matrix). */ /* LDAF (input) INTEGER */ /* The leading dimension of the array AF. LDAF >= max(1,N). */ /* 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) REAL 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) REAL 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) REAL array, dimension (3*N) */ /* IWORK (workspace) INTEGER 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. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; af_dim1 = *ldaf; af_offset = 1 + af_dim1; af -= af_offset; --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; --iwork; /* Function Body */ *info = 0; nofact = lsame_(fact, "N", (ftnlen)1, (ftnlen)1); equil = lsame_(fact, "E", (ftnlen)1, (ftnlen)1); if (nofact || equil) { *(unsigned char *)equed = 'N'; rcequ = FALSE_; } else { rcequ = lsame_(equed, "Y", (ftnlen)1, (ftnlen)1); smlnum = slamch_("Safe minimum", (ftnlen)12); bignum = 1.f / smlnum; } /* Test the input parameters. */ if (! nofact && ! equil && ! lsame_(fact, "F", (ftnlen)1, (ftnlen)1)) { *info = -1; } else if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (ftnlen)1, (ftnlen)1)) { *info = -2; } else if (*n < 0) { *info = -3; } else if (*nrhs < 0) { *info = -4; } else if (*lda < max(1,*n)) { *info = -6; } else if (*ldaf < max(1,*n)) { *info = -8; } else if (lsame_(fact, "F", (ftnlen)1, (ftnlen)1) && ! (rcequ || lsame_( equed, "N", (ftnlen)1, (ftnlen)1))) { *info = -9; } 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); /* L10: */ } if (smin <= 0.f) { *info = -10; } else if (*n > 0) { scond = dmax(smin,smlnum) / dmin(smax,bignum); } else { scond = 1.f; } } if (*info == 0) { if (*ldb < max(1,*n)) { *info = -12; } else if (*ldx < max(1,*n)) { *info = -14; } } } if (*info != 0) { i__1 = -(*info); xerbla_("SPOSVX", &i__1, (ftnlen)6); return 0; } if (equil) { /* Compute row and column scalings to equilibrate the matrix A. */ spoequ_(n, &a[a_offset], lda, &s[1], &scond, &amax, &infequ); if (infequ == 0) { /* Equilibrate the matrix. */ slaqsy_(uplo, n, &a[a_offset], lda, &s[1], &scond, &amax, equed, ( ftnlen)1, (ftnlen)1); rcequ = lsame_(equed, "Y", (ftnlen)1, (ftnlen)1); } } /* 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__) { b[i__ + j * b_dim1] = s[i__] * b[i__ + j * b_dim1]; /* L20: */ } /* L30: */ } } if (nofact || equil) { /* Compute the Cholesky factorization A = U'*U or A = L*L'. */ slacpy_(uplo, n, n, &a[a_offset], lda, &af[af_offset], ldaf, (ftnlen) 1); spotrf_(uplo, n, &af[af_offset], ldaf, info, (ftnlen)1); /* Return if INFO is non-zero. */ if (*info != 0) { if (*info > 0) { *rcond = 0.f; } return 0; } } /* Compute the norm of the matrix A. */ anorm = slansy_("1", uplo, n, &a[a_offset], lda, &work[1], (ftnlen)1, ( ftnlen)1); /* Compute the reciprocal of the condition number of A. */ spocon_(uplo, n, &af[af_offset], ldaf, &anorm, rcond, &work[1], &iwork[1], info, (ftnlen)1); /* Set INFO = N+1 if the matrix is singular to working precision. */ if (*rcond < slamch_("Epsilon", (ftnlen)7)) { *info = *n + 1; } /* Compute the solution matrix X. */ slacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx, (ftnlen)4); spotrs_(uplo, n, nrhs, &af[af_offset], ldaf, &x[x_offset], ldx, info, ( ftnlen)1); /* Use iterative refinement to improve the computed solution and */ /* compute error bounds and backward error estimates for it. */ sporfs_(uplo, n, nrhs, &a[a_offset], lda, &af[af_offset], ldaf, &b[ b_offset], ldb, &x[x_offset], ldx, &ferr[1], &berr[1], &work[1], & iwork[1], info, (ftnlen)1); /* 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__) { x[i__ + j * x_dim1] = s[i__] * x[i__ + j * x_dim1]; /* L40: */ } /* L50: */ } i__1 = *nrhs; for (j = 1; j <= i__1; ++j) { ferr[j] /= scond; /* L60: */ } } return 0; /* End of SPOSVX */ } /* sposvx_ */
/* Subroutine */ int sstt21_(integer *n, integer *kband, real *ad, real *ae, real *sd, real *se, real *u, integer *ldu, real *work, real *result) { /* System generated locals */ integer u_dim1, u_offset, i__1; real r__1, r__2, r__3; /* Local variables */ static real unfl; extern /* Subroutine */ int ssyr_(char *, integer *, real *, real *, integer *, real *, integer *); static real temp1, temp2; static integer j; extern /* Subroutine */ int ssyr2_(char *, integer *, real *, real *, integer *, real *, integer *, real *, integer *), sgemm_( char *, char *, integer *, integer *, integer *, real *, real *, integer *, real *, integer *, real *, real *, integer *); static real anorm, wnorm; extern doublereal slamch_(char *), slange_(char *, integer *, integer *, real *, integer *, real *); extern /* Subroutine */ int slaset_(char *, integer *, integer *, real *, real *, real *, integer *); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); static real ulp; #define u_ref(a_1,a_2) u[(a_2)*u_dim1 + a_1] /* -- LAPACK test routine (version 3.0) -- Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and Rice University September 30, 1994 Purpose ======= SSTT21 checks a decomposition of the form A = U S U' where ' means transpose, A is symmetric tridiagonal, U is orthogonal, and S is diagonal (if KBAND=0) or symmetric tridiagonal (if KBAND=1). Two tests are performed: RESULT(1) = | A - U S U' | / ( |A| n ulp ) RESULT(2) = | I - UU' | / ( n ulp ) Arguments ========= N (input) INTEGER The size of the matrix. If it is zero, SSTT21 does nothing. It must be at least zero. KBAND (input) INTEGER The bandwidth of the matrix S. It may only be zero or one. If zero, then S is diagonal, and SE is not referenced. If one, then S is symmetric tri-diagonal. AD (input) REAL array, dimension (N) The diagonal of the original (unfactored) matrix A. A is assumed to be symmetric tridiagonal. AE (input) REAL array, dimension (N-1) The off-diagonal of the original (unfactored) matrix A. A is assumed to be symmetric tridiagonal. AE(1) is the (1,2) and (2,1) element, AE(2) is the (2,3) and (3,2) element, etc. SD (input) REAL array, dimension (N) The diagonal of the (symmetric tri-) diagonal matrix S. SE (input) REAL array, dimension (N-1) The off-diagonal of the (symmetric tri-) diagonal matrix S. Not referenced if KBSND=0. If KBAND=1, then AE(1) is the (1,2) and (2,1) element, SE(2) is the (2,3) and (3,2) element, etc. U (input) REAL array, dimension (LDU, N) The orthogonal matrix in the decomposition. LDU (input) INTEGER The leading dimension of U. LDU must be at least N. WORK (workspace) REAL array, dimension (N*(N+1)) RESULT (output) REAL array, dimension (2) The values computed by the two tests described above. The values are currently limited to 1/ulp, to avoid overflow. RESULT(1) is always modified. ===================================================================== 1) Constants Parameter adjustments */ --ad; --ae; --sd; --se; u_dim1 = *ldu; u_offset = 1 + u_dim1 * 1; u -= u_offset; --work; --result; /* Function Body */ result[1] = 0.f; result[2] = 0.f; if (*n <= 0) { return 0; } unfl = slamch_("Safe minimum"); ulp = slamch_("Precision"); /* Do Test 1 Copy A & Compute its 1-Norm: */ slaset_("Full", n, n, &c_b5, &c_b5, &work[1], n); anorm = 0.f; temp1 = 0.f; i__1 = *n - 1; for (j = 1; j <= i__1; ++j) { work[(*n + 1) * (j - 1) + 1] = ad[j]; work[(*n + 1) * (j - 1) + 2] = ae[j]; temp2 = (r__1 = ae[j], dabs(r__1)); /* Computing MAX */ r__2 = anorm, r__3 = (r__1 = ad[j], dabs(r__1)) + temp1 + temp2; anorm = dmax(r__2,r__3); temp1 = temp2; /* L10: */ } /* Computing 2nd power */ i__1 = *n; work[i__1 * i__1] = ad[*n]; /* Computing MAX */ r__2 = anorm, r__3 = (r__1 = ad[*n], dabs(r__1)) + temp1, r__2 = max(r__2, r__3); anorm = dmax(r__2,unfl); /* Norm of A - USU' */ i__1 = *n; for (j = 1; j <= i__1; ++j) { r__1 = -sd[j]; ssyr_("L", n, &r__1, &u_ref(1, j), &c__1, &work[1], n); /* L20: */ } if (*n > 1 && *kband == 1) { i__1 = *n - 1; for (j = 1; j <= i__1; ++j) { r__1 = -se[j]; ssyr2_("L", n, &r__1, &u_ref(1, j), &c__1, &u_ref(1, j + 1), & c__1, &work[1], n); /* L30: */ } } /* Computing 2nd power */ i__1 = *n; wnorm = slansy_("1", "L", n, &work[1], n, &work[i__1 * i__1 + 1]); if (anorm > wnorm) { result[1] = wnorm / anorm / (*n * ulp); } else { if (anorm < 1.f) { /* Computing MIN */ r__1 = wnorm, r__2 = *n * anorm; result[1] = dmin(r__1,r__2) / anorm / (*n * ulp); } else { /* Computing MIN */ r__1 = wnorm / anorm, r__2 = (real) (*n); result[1] = dmin(r__1,r__2) / (*n * ulp); } } /* Do Test 2 Compute UU' - I */ sgemm_("N", "C", n, n, n, &c_b19, &u[u_offset], ldu, &u[u_offset], ldu, & c_b5, &work[1], n); i__1 = *n; for (j = 1; j <= i__1; ++j) { work[(*n + 1) * (j - 1) + 1] += -1.f; /* L40: */ } /* Computing MIN Computing 2nd power */ i__1 = *n; r__1 = (real) (*n), r__2 = slange_("1", n, n, &work[1], n, &work[i__1 * i__1 + 1]); result[2] = dmin(r__1,r__2) / (*n * ulp); return 0; /* End of SSTT21 */ } /* sstt21_ */
/* Subroutine */ int ssyevr_(char *jobz, char *range, char *uplo, integer *n, real *a, integer *lda, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, real *z__, integer *ldz, integer * isuppz, real *work, integer *lwork, integer *iwork, integer *liwork, integer *info) { /* System generated locals */ integer a_dim1, a_offset, z_dim1, z_offset, i__1, i__2; real r__1, r__2; /* Builtin functions */ double sqrt(doublereal); /* Local variables */ integer i__, j, nb, jj; real eps, vll, vuu, tmp1; integer indd, inde; real anrm; integer imax; real rmin, rmax; logical test; integer inddd, indee; real sigma; extern logical lsame_(char *, char *); integer iinfo; extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *); char order[1]; integer indwk, lwmin; logical lower; extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, integer *), sswap_(integer *, real *, integer *, real *, integer * ); logical wantz, alleig, indeig; integer iscale, ieeeok, indibl, indifl; logical valeig; extern doublereal slamch_(char *); real safmin; extern integer ilaenv_(integer *, char *, char *, integer *, integer *, integer *, integer *); extern /* Subroutine */ int xerbla_(char *, integer *); real abstll, bignum; integer indtau, indisp, indiwo, indwkn, liwmin; logical tryrac; extern /* Subroutine */ int sstein_(integer *, real *, real *, integer *, real *, integer *, integer *, real *, integer *, real *, integer * , integer *, integer *), ssterf_(integer *, real *, real *, integer *); integer llwrkn, llwork, nsplit; real smlnum; extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); extern /* Subroutine */ int sstebz_(char *, char *, integer *, real *, real *, integer *, integer *, real *, real *, real *, integer *, integer *, real *, integer *, integer *, real *, integer *, integer *), sstemr_(char *, char *, integer *, real *, real *, real *, real *, integer *, integer *, integer *, real *, real *, integer *, integer *, integer *, logical *, real * , integer *, integer *, integer *, integer *); integer lwkopt; logical lquery; extern /* Subroutine */ int sormtr_(char *, char *, char *, integer *, integer *, real *, integer *, real *, real *, integer *, real *, integer *, integer *), ssytrd_(char *, integer *, real *, integer *, real *, real *, real *, real *, integer *, integer *); /* -- LAPACK driver routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SSYEVR computes selected eigenvalues and, optionally, eigenvectors */ /* of a real symmetric matrix A. Eigenvalues and eigenvectors can be */ /* selected by specifying either a range of values or a range of */ /* indices for the desired eigenvalues. */ /* SSYEVR first reduces the matrix A to tridiagonal form T with a call */ /* to SSYTRD. Then, whenever possible, SSYEVR calls SSTEMR to compute */ /* the eigenspectrum using Relatively Robust Representations. SSTEMR */ /* computes eigenvalues by the dqds algorithm, while orthogonal */ /* eigenvectors are computed from various "good" L D L^T representations */ /* (also known as Relatively Robust Representations). Gram-Schmidt */ /* orthogonalization is avoided as far as possible. More specifically, */ /* the various steps of the algorithm are as follows. */ /* For each unreduced block (submatrix) of T, */ /* (a) Compute T - sigma I = L D L^T, so that L and D */ /* define all the wanted eigenvalues to high relative accuracy. */ /* This means that small relative changes in the entries of D and L */ /* cause only small relative changes in the eigenvalues and */ /* eigenvectors. The standard (unfactored) representation of the */ /* tridiagonal matrix T does not have this property in general. */ /* (b) Compute the eigenvalues to suitable accuracy. */ /* If the eigenvectors are desired, the algorithm attains full */ /* accuracy of the computed eigenvalues only right before */ /* the corresponding vectors have to be computed, see steps c) and d). */ /* (c) For each cluster of close eigenvalues, select a new */ /* shift close to the cluster, find a new factorization, and refine */ /* the shifted eigenvalues to suitable accuracy. */ /* (d) For each eigenvalue with a large enough relative separation compute */ /* the corresponding eigenvector by forming a rank revealing twisted */ /* factorization. Go back to (c) for any clusters that remain. */ /* The desired accuracy of the output can be specified by the input */ /* parameter ABSTOL. */ /* For more details, see SSTEMR's documentation and: */ /* - Inderjit S. Dhillon and Beresford N. Parlett: "Multiple representations */ /* to compute orthogonal eigenvectors of symmetric tridiagonal matrices," */ /* Linear Algebra and its Applications, 387(1), pp. 1-28, August 2004. */ /* - Inderjit Dhillon and Beresford Parlett: "Orthogonal Eigenvectors and */ /* Relative Gaps," SIAM Journal on Matrix Analysis and Applications, Vol. 25, */ /* 2004. Also LAPACK Working Note 154. */ /* - Inderjit Dhillon: "A new O(n^2) algorithm for the symmetric */ /* tridiagonal eigenvalue/eigenvector problem", */ /* Computer Science Division Technical Report No. UCB/CSD-97-971, */ /* UC Berkeley, May 1997. */ /* Note 1 : SSYEVR calls SSTEMR when the full spectrum is requested */ /* on machines which conform to the ieee-754 floating point standard. */ /* SSYEVR calls SSTEBZ and SSTEIN on non-ieee machines and */ /* when partial spectrum requests are made. */ /* Normal execution of SSTEMR may create NaNs and infinities and */ /* hence may abort due to a floating point exception in environments */ /* which do not handle NaNs and infinities in the ieee standard default */ /* manner. */ /* Arguments */ /* ========= */ /* JOBZ (input) CHARACTER*1 */ /* = 'N': Compute eigenvalues only; */ /* = 'V': Compute eigenvalues and eigenvectors. */ /* RANGE (input) CHARACTER*1 */ /* = 'A': all eigenvalues will be found. */ /* = 'V': all eigenvalues in the half-open interval (VL,VU] */ /* will be found. */ /* = 'I': the IL-th through IU-th eigenvalues will be found. */ /* ********* For RANGE = 'V' or 'I' and IU - IL < N - 1, SSTEBZ and */ /* ********* SSTEIN are called */ /* 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. */ /* A (input/output) REAL array, dimension (LDA, N) */ /* On entry, the symmetric matrix A. If UPLO = 'U', the */ /* leading N-by-N upper triangular part of A contains the */ /* upper triangular part of the matrix A. If UPLO = 'L', */ /* the leading N-by-N lower triangular part of A contains */ /* the lower triangular part of the matrix A. */ /* On exit, the lower triangle (if UPLO='L') or the upper */ /* triangle (if UPLO='U') of A, including the diagonal, is */ /* destroyed. */ /* LDA (input) INTEGER */ /* The leading dimension of the array A. LDA >= max(1,N). */ /* VL (input) REAL */ /* VU (input) REAL */ /* If RANGE='V', the lower and upper bounds of the interval to */ /* be searched for eigenvalues. VL < VU. */ /* Not referenced if RANGE = 'A' or 'I'. */ /* IL (input) INTEGER */ /* IU (input) INTEGER */ /* If RANGE='I', the indices (in ascending order) of the */ /* smallest and largest eigenvalues to be returned. */ /* 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */ /* Not referenced if RANGE = 'A' or 'V'. */ /* ABSTOL (input) REAL */ /* The absolute error tolerance for the eigenvalues. */ /* An approximate eigenvalue is accepted as converged */ /* when it is determined to lie in an interval [a,b] */ /* of width less than or equal to */ /* ABSTOL + EPS * max( |a|,|b| ) , */ /* where EPS is the machine precision. If ABSTOL is less than */ /* or equal to zero, then EPS*|T| will be used in its place, */ /* where |T| is the 1-norm of the tridiagonal matrix obtained */ /* by reducing A to tridiagonal form. */ /* See "Computing Small Singular Values of Bidiagonal Matrices */ /* with Guaranteed High Relative Accuracy," by Demmel and */ /* Kahan, LAPACK Working Note #3. */ /* If high relative accuracy is important, set ABSTOL to */ /* SLAMCH( 'Safe minimum' ). Doing so will guarantee that */ /* eigenvalues are computed to high relative accuracy when */ /* possible in future releases. The current code does not */ /* make any guarantees about high relative accuracy, but */ /* future releases will. See J. Barlow and J. Demmel, */ /* "Computing Accurate Eigensystems of Scaled Diagonally */ /* Dominant Matrices", LAPACK Working Note #7, for a discussion */ /* of which matrices define their eigenvalues to high relative */ /* accuracy. */ /* M (output) INTEGER */ /* The total number of eigenvalues found. 0 <= M <= N. */ /* If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1. */ /* W (output) REAL array, dimension (N) */ /* The first M elements contain the selected eigenvalues in */ /* ascending order. */ /* Z (output) REAL array, dimension (LDZ, max(1,M)) */ /* If JOBZ = 'V', then if INFO = 0, the first M columns of Z */ /* contain the orthonormal eigenvectors of the matrix A */ /* corresponding to the selected eigenvalues, with the i-th */ /* column of Z holding the eigenvector associated with W(i). */ /* If JOBZ = 'N', then Z is not referenced. */ /* Note: the user must ensure that at least max(1,M) columns are */ /* supplied in the array Z; if RANGE = 'V', the exact value of M */ /* is not known in advance and an upper bound must be used. */ /* Supplying N columns is always safe. */ /* LDZ (input) INTEGER */ /* The leading dimension of the array Z. LDZ >= 1, and if */ /* JOBZ = 'V', LDZ >= max(1,N). */ /* ISUPPZ (output) INTEGER array, dimension ( 2*max(1,M) ) */ /* The support of the eigenvectors in Z, i.e., the indices */ /* indicating the nonzero elements in Z. The i-th eigenvector */ /* is nonzero only in elements ISUPPZ( 2*i-1 ) through */ /* ISUPPZ( 2*i ). */ /* ********* Implemented only for RANGE = 'A' or 'I' and IU - IL = N - 1 */ /* WORK (workspace/output) REAL array, dimension (MAX(1,LWORK)) */ /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ /* LWORK (input) INTEGER */ /* The dimension of the array WORK. LWORK >= max(1,26*N). */ /* For optimal efficiency, LWORK >= (NB+6)*N, */ /* where NB is the max of the blocksize for SSYTRD and SORMTR */ /* returned by ILAENV. */ /* If LWORK = -1, then a workspace query is assumed; the routine */ /* only calculates the optimal sizes of the WORK and IWORK */ /* arrays, returns these values as the first entries of the WORK */ /* and IWORK arrays, and no error message related to LWORK or */ /* LIWORK is issued by XERBLA. */ /* IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK)) */ /* On exit, if INFO = 0, IWORK(1) returns the optimal LWORK. */ /* LIWORK (input) INTEGER */ /* The dimension of the array IWORK. LIWORK >= max(1,10*N). */ /* If LIWORK = -1, then a workspace query is assumed; the */ /* routine only calculates the optimal sizes of the WORK and */ /* IWORK arrays, returns these values as the first entries of */ /* the WORK and IWORK arrays, and no error message related to */ /* LWORK or LIWORK is issued by XERBLA. */ /* INFO (output) INTEGER */ /* = 0: successful exit */ /* < 0: if INFO = -i, the i-th argument had an illegal value */ /* > 0: Internal error */ /* Further Details */ /* =============== */ /* Based on contributions by */ /* Inderjit Dhillon, IBM Almaden, USA */ /* Osni Marques, LBNL/NERSC, USA */ /* Ken Stanley, Computer Science Division, University of */ /* California at Berkeley, USA */ /* Jason Riedy, Computer Science Division, University of */ /* California at Berkeley, USA */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Test the input parameters. */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; --w; z_dim1 = *ldz; z_offset = 1 + z_dim1; z__ -= z_offset; --isuppz; --work; --iwork; /* Function Body */ ieeeok = ilaenv_(&c__10, "SSYEVR", "N", &c__1, &c__2, &c__3, &c__4); lower = lsame_(uplo, "L"); wantz = lsame_(jobz, "V"); alleig = lsame_(range, "A"); valeig = lsame_(range, "V"); indeig = lsame_(range, "I"); lquery = *lwork == -1 || *liwork == -1; /* Computing MAX */ i__1 = 1, i__2 = *n * 26; lwmin = max(i__1,i__2); /* Computing MAX */ i__1 = 1, i__2 = *n * 10; liwmin = max(i__1,i__2); *info = 0; if (! (wantz || lsame_(jobz, "N"))) { *info = -1; } else if (! (alleig || valeig || indeig)) { *info = -2; } else if (! (lower || lsame_(uplo, "U"))) { *info = -3; } else if (*n < 0) { *info = -4; } else if (*lda < max(1,*n)) { *info = -6; } else { if (valeig) { if (*n > 0 && *vu <= *vl) { *info = -8; } } else if (indeig) { if (*il < 1 || *il > max(1,*n)) { *info = -9; } else if (*iu < min(*n,*il) || *iu > *n) { *info = -10; } } } if (*info == 0) { if (*ldz < 1 || wantz && *ldz < *n) { *info = -15; } } if (*info == 0) { nb = ilaenv_(&c__1, "SSYTRD", uplo, n, &c_n1, &c_n1, &c_n1); /* Computing MAX */ i__1 = nb, i__2 = ilaenv_(&c__1, "SORMTR", uplo, n, &c_n1, &c_n1, & c_n1); nb = max(i__1,i__2); /* Computing MAX */ i__1 = (nb + 1) * *n; lwkopt = max(i__1,lwmin); work[1] = (real) lwkopt; iwork[1] = liwmin; if (*lwork < lwmin && ! lquery) { *info = -18; } else if (*liwork < liwmin && ! lquery) { *info = -20; } } if (*info != 0) { i__1 = -(*info); xerbla_("SSYEVR", &i__1); return 0; } else if (lquery) { return 0; } /* Quick return if possible */ *m = 0; if (*n == 0) { work[1] = 1.f; return 0; } if (*n == 1) { work[1] = 26.f; if (alleig || indeig) { *m = 1; w[1] = a[a_dim1 + 1]; } else { if (*vl < a[a_dim1 + 1] && *vu >= a[a_dim1 + 1]) { *m = 1; w[1] = a[a_dim1 + 1]; } } if (wantz) { z__[z_dim1 + 1] = 1.f; } return 0; } /* Get machine constants. */ safmin = slamch_("Safe minimum"); eps = slamch_("Precision"); smlnum = safmin / eps; bignum = 1.f / smlnum; rmin = sqrt(smlnum); /* Computing MIN */ r__1 = sqrt(bignum), r__2 = 1.f / sqrt(sqrt(safmin)); rmax = dmin(r__1,r__2); /* Scale matrix to allowable range, if necessary. */ iscale = 0; abstll = *abstol; if (valeig) { vll = *vl; vuu = *vu; } anrm = slansy_("M", uplo, n, &a[a_offset], lda, &work[1]); if (anrm > 0.f && anrm < rmin) { iscale = 1; sigma = rmin / anrm; } else if (anrm > rmax) { iscale = 1; sigma = rmax / anrm; } if (iscale == 1) { if (lower) { i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = *n - j + 1; sscal_(&i__2, &sigma, &a[j + j * a_dim1], &c__1); /* L10: */ } } else { i__1 = *n; for (j = 1; j <= i__1; ++j) { sscal_(&j, &sigma, &a[j * a_dim1 + 1], &c__1); /* L20: */ } } if (*abstol > 0.f) { abstll = *abstol * sigma; } if (valeig) { vll = *vl * sigma; vuu = *vu * sigma; } } /* Initialize indices into workspaces. Note: The IWORK indices are */ /* used only if SSTERF or SSTEMR fail. */ /* WORK(INDTAU:INDTAU+N-1) stores the scalar factors of the */ /* elementary reflectors used in SSYTRD. */ indtau = 1; /* WORK(INDD:INDD+N-1) stores the tridiagonal's diagonal entries. */ indd = indtau + *n; /* WORK(INDE:INDE+N-1) stores the off-diagonal entries of the */ /* tridiagonal matrix from SSYTRD. */ inde = indd + *n; /* WORK(INDDD:INDDD+N-1) is a copy of the diagonal entries over */ /* -written by SSTEMR (the SSTERF path copies the diagonal to W). */ inddd = inde + *n; /* WORK(INDEE:INDEE+N-1) is a copy of the off-diagonal entries over */ /* -written while computing the eigenvalues in SSTERF and SSTEMR. */ indee = inddd + *n; /* INDWK is the starting offset of the left-over workspace, and */ /* LLWORK is the remaining workspace size. */ indwk = indee + *n; llwork = *lwork - indwk + 1; /* IWORK(INDIBL:INDIBL+M-1) corresponds to IBLOCK in SSTEBZ and */ /* stores the block indices of each of the M<=N eigenvalues. */ indibl = 1; /* IWORK(INDISP:INDISP+NSPLIT-1) corresponds to ISPLIT in SSTEBZ and */ /* stores the starting and finishing indices of each block. */ indisp = indibl + *n; /* IWORK(INDIFL:INDIFL+N-1) stores the indices of eigenvectors */ /* that corresponding to eigenvectors that fail to converge in */ /* SSTEIN. This information is discarded; if any fail, the driver */ /* returns INFO > 0. */ indifl = indisp + *n; /* INDIWO is the offset of the remaining integer workspace. */ indiwo = indisp + *n; /* Call SSYTRD to reduce symmetric matrix to tridiagonal form. */ ssytrd_(uplo, n, &a[a_offset], lda, &work[indd], &work[inde], &work[ indtau], &work[indwk], &llwork, &iinfo); /* If all eigenvalues are desired */ /* then call SSTERF or SSTEMR and SORMTR. */ test = FALSE_; if (indeig) { if (*il == 1 && *iu == *n) { test = TRUE_; } } if ((alleig || test) && ieeeok == 1) { if (! wantz) { scopy_(n, &work[indd], &c__1, &w[1], &c__1); i__1 = *n - 1; scopy_(&i__1, &work[inde], &c__1, &work[indee], &c__1); ssterf_(n, &w[1], &work[indee], info); } else { i__1 = *n - 1; scopy_(&i__1, &work[inde], &c__1, &work[indee], &c__1); scopy_(n, &work[indd], &c__1, &work[inddd], &c__1); if (*abstol <= *n * 2.f * eps) { tryrac = TRUE_; } else { tryrac = FALSE_; } sstemr_(jobz, "A", n, &work[inddd], &work[indee], vl, vu, il, iu, m, &w[1], &z__[z_offset], ldz, n, &isuppz[1], &tryrac, & work[indwk], lwork, &iwork[1], liwork, info); /* Apply orthogonal matrix used in reduction to tridiagonal */ /* form to eigenvectors returned by SSTEIN. */ if (wantz && *info == 0) { indwkn = inde; llwrkn = *lwork - indwkn + 1; sormtr_("L", uplo, "N", n, m, &a[a_offset], lda, &work[indtau] , &z__[z_offset], ldz, &work[indwkn], &llwrkn, &iinfo); } } if (*info == 0) { /* Everything worked. Skip SSTEBZ/SSTEIN. IWORK(:) are */ /* undefined. */ *m = *n; goto L30; } *info = 0; } /* Otherwise, call SSTEBZ and, if eigenvectors are desired, SSTEIN. */ /* Also call SSTEBZ and SSTEIN if SSTEMR fails. */ if (wantz) { *(unsigned char *)order = 'B'; } else { *(unsigned char *)order = 'E'; } sstebz_(range, order, n, &vll, &vuu, il, iu, &abstll, &work[indd], &work[ inde], m, &nsplit, &w[1], &iwork[indibl], &iwork[indisp], &work[ indwk], &iwork[indiwo], info); if (wantz) { sstein_(n, &work[indd], &work[inde], m, &w[1], &iwork[indibl], &iwork[ indisp], &z__[z_offset], ldz, &work[indwk], &iwork[indiwo], & iwork[indifl], info); /* Apply orthogonal matrix used in reduction to tridiagonal */ /* form to eigenvectors returned by SSTEIN. */ indwkn = inde; llwrkn = *lwork - indwkn + 1; sormtr_("L", uplo, "N", n, m, &a[a_offset], lda, &work[indtau], &z__[ z_offset], ldz, &work[indwkn], &llwrkn, &iinfo); } /* If matrix was scaled, then rescale eigenvalues appropriately. */ /* Jump here if SSTEMR/SSTEIN succeeded. */ L30: if (iscale == 1) { if (*info == 0) { imax = *m; } else { imax = *info - 1; } r__1 = 1.f / sigma; sscal_(&imax, &r__1, &w[1], &c__1); } /* If eigenvalues are not in order, then sort them, along with */ /* eigenvectors. Note: We do not sort the IFAIL portion of IWORK. */ /* It may not be initialized (if SSTEMR/SSTEIN succeeded), and we do */ /* not return this detailed information to the user. */ if (wantz) { i__1 = *m - 1; for (j = 1; j <= i__1; ++j) { i__ = 0; tmp1 = w[j]; i__2 = *m; for (jj = j + 1; jj <= i__2; ++jj) { if (w[jj] < tmp1) { i__ = jj; tmp1 = w[jj]; } /* L40: */ } if (i__ != 0) { w[i__] = w[j]; w[j] = tmp1; sswap_(n, &z__[i__ * z_dim1 + 1], &c__1, &z__[j * z_dim1 + 1], &c__1); } /* L50: */ } } /* Set WORK(1) to optimal workspace size. */ work[1] = (real) lwkopt; iwork[1] = liwmin; return 0; /* End of SSYEVR */ } /* ssyevr_ */
/* Subroutine */ int sgqrts_(integer *n, integer *m, integer *p, real *a, real *af, real *q, real *r__, integer *lda, real *taua, real *b, real *bf, real *z__, real *t, real *bwk, integer *ldb, real *taub, real * work, integer *lwork, real *rwork, real *result) { /* System generated locals */ integer a_dim1, a_offset, af_dim1, af_offset, r_dim1, r_offset, q_dim1, q_offset, b_dim1, b_offset, bf_dim1, bf_offset, t_dim1, t_offset, z_dim1, z_offset, bwk_dim1, bwk_offset, i__1, i__2; real r__1; /* Local variables */ real ulp; integer info; real unfl, resid; extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, integer *, real *, real *, integer *, real *, integer *, real *, real *, integer *); real anorm, bnorm; extern /* Subroutine */ int ssyrk_(char *, char *, integer *, integer *, real *, real *, integer *, real *, real *, integer *); extern doublereal slamch_(char *), slange_(char *, integer *, integer *, real *, integer *, real *); extern /* Subroutine */ int sggqrf_(integer *, integer *, integer *, real *, integer *, real *, real *, integer *, real *, real *, integer * , integer *), slacpy_(char *, integer *, integer *, real *, integer *, real *, integer *), slaset_(char *, integer *, integer *, real *, real *, real *, integer *); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); extern /* Subroutine */ int sorgqr_(integer *, integer *, integer *, real *, integer *, real *, real *, integer *, integer *), sorgrq_( integer *, integer *, integer *, real *, integer *, real *, real * , integer *, integer *); /* -- LAPACK test routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SGQRTS tests SGGQRF, which computes the GQR factorization of an */ /* N-by-M matrix A and a N-by-P matrix B: A = Q*R and B = Q*T*Z. */ /* Arguments */ /* ========= */ /* N (input) INTEGER */ /* The number of rows of the matrices A and B. N >= 0. */ /* M (input) INTEGER */ /* The number of columns of the matrix A. M >= 0. */ /* P (input) INTEGER */ /* The number of columns of the matrix B. P >= 0. */ /* A (input) REAL array, dimension (LDA,M) */ /* The N-by-M matrix A. */ /* AF (output) REAL array, dimension (LDA,N) */ /* Details of the GQR factorization of A and B, as returned */ /* by SGGQRF, see SGGQRF for further details. */ /* Q (output) REAL array, dimension (LDA,N) */ /* The M-by-M orthogonal matrix Q. */ /* R (workspace) REAL array, dimension (LDA,MAX(M,N)) */ /* LDA (input) INTEGER */ /* The leading dimension of the arrays A, AF, R and Q. */ /* LDA >= max(M,N). */ /* TAUA (output) REAL array, dimension (min(M,N)) */ /* The scalar factors of the elementary reflectors, as returned */ /* by SGGQRF. */ /* B (input) REAL array, dimension (LDB,P) */ /* On entry, the N-by-P matrix A. */ /* BF (output) REAL array, dimension (LDB,N) */ /* Details of the GQR factorization of A and B, as returned */ /* by SGGQRF, see SGGQRF for further details. */ /* Z (output) REAL array, dimension (LDB,P) */ /* The P-by-P orthogonal matrix Z. */ /* T (workspace) REAL array, dimension (LDB,max(P,N)) */ /* BWK (workspace) REAL array, dimension (LDB,N) */ /* LDB (input) INTEGER */ /* The leading dimension of the arrays B, BF, Z and T. */ /* LDB >= max(P,N). */ /* TAUB (output) REAL array, dimension (min(P,N)) */ /* The scalar factors of the elementary reflectors, as returned */ /* by SGGRQF. */ /* WORK (workspace) REAL array, dimension (LWORK) */ /* LWORK (input) INTEGER */ /* The dimension of the array WORK, LWORK >= max(N,M,P)**2. */ /* RWORK (workspace) REAL array, dimension (max(N,M,P)) */ /* RESULT (output) REAL array, dimension (4) */ /* The test ratios: */ /* RESULT(1) = norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP) */ /* RESULT(2) = norm( T*Z - Q'*B ) / (MAX(P,N)*norm(B)*ULP) */ /* RESULT(3) = norm( I - Q'*Q ) / ( M*ULP ) */ /* RESULT(4) = norm( I - Z'*Z ) / ( P*ULP ) */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Parameter adjustments */ r_dim1 = *lda; r_offset = 1 + r_dim1; r__ -= r_offset; q_dim1 = *lda; q_offset = 1 + q_dim1; q -= q_offset; af_dim1 = *lda; af_offset = 1 + af_dim1; af -= af_offset; a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; --taua; bwk_dim1 = *ldb; bwk_offset = 1 + bwk_dim1; bwk -= bwk_offset; t_dim1 = *ldb; t_offset = 1 + t_dim1; t -= t_offset; z_dim1 = *ldb; z_offset = 1 + z_dim1; z__ -= z_offset; bf_dim1 = *ldb; bf_offset = 1 + bf_dim1; bf -= bf_offset; b_dim1 = *ldb; b_offset = 1 + b_dim1; b -= b_offset; --taub; --work; --rwork; --result; /* Function Body */ ulp = slamch_("Precision"); unfl = slamch_("Safe minimum"); /* Copy the matrix A to the array AF. */ slacpy_("Full", n, m, &a[a_offset], lda, &af[af_offset], lda); slacpy_("Full", n, p, &b[b_offset], ldb, &bf[bf_offset], ldb); /* Computing MAX */ r__1 = slange_("1", n, m, &a[a_offset], lda, &rwork[1]); anorm = dmax(r__1,unfl); /* Computing MAX */ r__1 = slange_("1", n, p, &b[b_offset], ldb, &rwork[1]); bnorm = dmax(r__1,unfl); /* Factorize the matrices A and B in the arrays AF and BF. */ sggqrf_(n, m, p, &af[af_offset], lda, &taua[1], &bf[bf_offset], ldb, & taub[1], &work[1], lwork, &info); /* Generate the N-by-N matrix Q */ slaset_("Full", n, n, &c_b9, &c_b9, &q[q_offset], lda); i__1 = *n - 1; slacpy_("Lower", &i__1, m, &af[af_dim1 + 2], lda, &q[q_dim1 + 2], lda); i__1 = min(*n,*m); sorgqr_(n, n, &i__1, &q[q_offset], lda, &taua[1], &work[1], lwork, &info); /* Generate the P-by-P matrix Z */ slaset_("Full", p, p, &c_b9, &c_b9, &z__[z_offset], ldb); if (*n <= *p) { if (*n > 0 && *n < *p) { i__1 = *p - *n; slacpy_("Full", n, &i__1, &bf[bf_offset], ldb, &z__[*p - *n + 1 + z_dim1], ldb); } if (*n > 1) { i__1 = *n - 1; i__2 = *n - 1; slacpy_("Lower", &i__1, &i__2, &bf[(*p - *n + 1) * bf_dim1 + 2], ldb, &z__[*p - *n + 2 + (*p - *n + 1) * z_dim1], ldb); } } else { if (*p > 1) { i__1 = *p - 1; i__2 = *p - 1; slacpy_("Lower", &i__1, &i__2, &bf[*n - *p + 2 + bf_dim1], ldb, & z__[z_dim1 + 2], ldb); } } i__1 = min(*n,*p); sorgrq_(p, p, &i__1, &z__[z_offset], ldb, &taub[1], &work[1], lwork, & info); /* Copy R */ slaset_("Full", n, m, &c_b19, &c_b19, &r__[r_offset], lda); slacpy_("Upper", n, m, &af[af_offset], lda, &r__[r_offset], lda); /* Copy T */ slaset_("Full", n, p, &c_b19, &c_b19, &t[t_offset], ldb); if (*n <= *p) { slacpy_("Upper", n, n, &bf[(*p - *n + 1) * bf_dim1 + 1], ldb, &t[(*p - *n + 1) * t_dim1 + 1], ldb); } else { i__1 = *n - *p; slacpy_("Full", &i__1, p, &bf[bf_offset], ldb, &t[t_offset], ldb); slacpy_("Upper", p, p, &bf[*n - *p + 1 + bf_dim1], ldb, &t[*n - *p + 1 + t_dim1], ldb); } /* Compute R - Q'*A */ sgemm_("Transpose", "No transpose", n, m, n, &c_b30, &q[q_offset], lda, & a[a_offset], lda, &c_b31, &r__[r_offset], lda); /* Compute norm( R - Q'*A ) / ( MAX(M,N)*norm(A)*ULP ) . */ resid = slange_("1", n, m, &r__[r_offset], lda, &rwork[1]); if (anorm > 0.f) { /* Computing MAX */ i__1 = max(1,*m); result[1] = resid / (real) max(i__1,*n) / anorm / ulp; } else { result[1] = 0.f; } /* Compute T*Z - Q'*B */ sgemm_("No Transpose", "No transpose", n, p, p, &c_b31, &t[t_offset], ldb, &z__[z_offset], ldb, &c_b19, &bwk[bwk_offset], ldb); sgemm_("Transpose", "No transpose", n, p, n, &c_b30, &q[q_offset], lda, & b[b_offset], ldb, &c_b31, &bwk[bwk_offset], ldb); /* Compute norm( T*Z - Q'*B ) / ( MAX(P,N)*norm(A)*ULP ) . */ resid = slange_("1", n, p, &bwk[bwk_offset], ldb, &rwork[1]); if (bnorm > 0.f) { /* Computing MAX */ i__1 = max(1,*p); result[2] = resid / (real) max(i__1,*n) / bnorm / ulp; } else { result[2] = 0.f; } /* Compute I - Q'*Q */ slaset_("Full", n, n, &c_b19, &c_b31, &r__[r_offset], lda); ssyrk_("Upper", "Transpose", n, n, &c_b30, &q[q_offset], lda, &c_b31, & r__[r_offset], lda); /* Compute norm( I - Q'*Q ) / ( N * ULP ) . */ resid = slansy_("1", "Upper", n, &r__[r_offset], lda, &rwork[1]); result[3] = resid / (real) max(1,*n) / ulp; /* Compute I - Z'*Z */ slaset_("Full", p, p, &c_b19, &c_b31, &t[t_offset], ldb); ssyrk_("Upper", "Transpose", p, p, &c_b30, &z__[z_offset], ldb, &c_b31, & t[t_offset], ldb); /* Compute norm( I - Z'*Z ) / ( P*ULP ) . */ resid = slansy_("1", "Upper", p, &t[t_offset], ldb, &rwork[1]); result[4] = resid / (real) max(1,*p) / ulp; return 0; /* End of SGQRTS */ } /* sgqrts_ */
/* Subroutine */ int ssyevd_(char *jobz, char *uplo, integer *n, real *a, integer *lda, real *w, real *work, integer *lwork, integer *iwork, integer *liwork, 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 June 30, 1999 Purpose ======= SSYEVD computes all eigenvalues and, optionally, eigenvectors of a real symmetric matrix A. If eigenvectors are desired, it uses a divide and conquer algorithm. The divide and conquer algorithm makes very mild assumptions about floating point arithmetic. It will work on machines with a guard digit in add/subtract, or on those binary machines without guard digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2. It could conceivably fail on hexadecimal or decimal machines without guard digits, but we know of none. Because of large use of BLAS of level 3, SSYEVD needs N**2 more workspace than SSYEVX. Arguments ========= JOBZ (input) CHARACTER*1 = 'N': Compute eigenvalues only; = 'V': Compute eigenvalues and eigenvectors. 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. A (input/output) REAL array, dimension (LDA, N) On entry, the symmetric matrix A. If UPLO = 'U', the leading N-by-N upper triangular part of A contains the upper triangular part of the matrix A. If UPLO = 'L', the leading N-by-N lower triangular part of A contains the lower triangular part of the matrix A. On exit, if JOBZ = 'V', then if INFO = 0, A contains the orthonormal eigenvectors of the matrix A. If JOBZ = 'N', then on exit the lower triangle (if UPLO='L') or the upper triangle (if UPLO='U') of A, including the diagonal, is destroyed. LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,N). W (output) REAL array, dimension (N) If INFO = 0, the eigenvalues in ascending order. WORK (workspace/output) REAL array, dimension (LWORK) On exit, if INFO = 0, WORK(1) returns the optimal LWORK. LWORK (input) INTEGER The dimension of the array WORK. If N <= 1, LWORK must be at least 1. If JOBZ = 'N' and N > 1, LWORK must be at least 2*N+1. If JOBZ = 'V' and N > 1, LWORK must be at least 1 + 6*N + 2*N**2. If LWORK = -1, then a workspace query is assumed; the routine only calculates the optimal size of the WORK array, returns this value as the first entry of the WORK array, and no error message related to LWORK is issued by XERBLA. IWORK (workspace/output) INTEGER array, dimension (LIWORK) On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK. LIWORK (input) INTEGER The dimension of the array IWORK. If N <= 1, LIWORK must be at least 1. If JOBZ = 'N' and N > 1, LIWORK must be at least 1. If JOBZ = 'V' and N > 1, LIWORK must be at least 3 + 5*N. If LIWORK = -1, then a workspace query is assumed; the routine only calculates the optimal size of the IWORK array, returns this value as the first entry of the IWORK array, and no error message related to LIWORK is issued by XERBLA. INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value > 0: if INFO = i, the algorithm failed to converge; i off-diagonal elements of an intermediate tridiagonal form did not converge to zero. Further Details =============== Based on contributions by Jeff Rutter, Computer Science Division, University of California at Berkeley, USA Modified by Francoise Tisseur, University of Tennessee. ===================================================================== Test the input parameters. Parameter adjustments */ /* Table of constant values */ static integer c__0 = 0; static real c_b12 = 1.f; static integer c__1 = 1; /* System generated locals */ integer a_dim1, a_offset, i__1, i__2, i__3; real r__1; /* Builtin functions */ double sqrt(doublereal); /* Local variables */ static integer inde; static real anrm, rmin, rmax; static integer lopt; static real sigma; extern logical lsame_(char *, char *); static integer iinfo; extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *); static integer lwmin, liopt; static logical lower, wantz; static integer indwk2, llwrk2, iscale; extern doublereal slamch_(char *); static real safmin; extern /* Subroutine */ int xerbla_(char *, integer *); static real bignum; extern /* Subroutine */ int slascl_(char *, integer *, integer *, real *, real *, integer *, integer *, real *, integer *, integer *); static integer indtau; extern /* Subroutine */ int sstedc_(char *, integer *, real *, real *, real *, integer *, real *, integer *, integer *, integer *, integer *), slacpy_(char *, integer *, integer *, real *, integer *, real *, integer *); static integer indwrk, liwmin; extern /* Subroutine */ int ssterf_(integer *, real *, real *, integer *); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); static integer llwork; static real smlnum; static logical lquery; extern /* Subroutine */ int sormtr_(char *, char *, char *, integer *, integer *, real *, integer *, real *, real *, integer *, real *, integer *, integer *), ssytrd_(char *, integer *, real *, integer *, real *, real *, real *, real *, integer *, integer *); static real eps; #define a_ref(a_1,a_2) a[(a_2)*a_dim1 + a_1] a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; --w; --work; --iwork; /* Function Body */ wantz = lsame_(jobz, "V"); lower = lsame_(uplo, "L"); lquery = *lwork == -1 || *liwork == -1; *info = 0; if (*n <= 1) { liwmin = 1; lwmin = 1; lopt = lwmin; liopt = liwmin; } else { if (wantz) { liwmin = *n * 5 + 3; /* Computing 2nd power */ i__1 = *n; lwmin = *n * 6 + 1 + (i__1 * i__1 << 1); } else { liwmin = 1; lwmin = (*n << 1) + 1; } lopt = lwmin; liopt = liwmin; } if (! (wantz || lsame_(jobz, "N"))) { *info = -1; } else if (! (lower || lsame_(uplo, "U"))) { *info = -2; } else if (*n < 0) { *info = -3; } else if (*lda < max(1,*n)) { *info = -5; } else if (*lwork < lwmin && ! lquery) { *info = -8; } else if (*liwork < liwmin && ! lquery) { *info = -10; } if (*info == 0) { work[1] = (real) lopt; iwork[1] = liopt; } if (*info != 0) { i__1 = -(*info); xerbla_("SSYEVD", &i__1); return 0; } else if (lquery) { return 0; } /* Quick return if possible */ if (*n == 0) { return 0; } if (*n == 1) { w[1] = a_ref(1, 1); if (wantz) { a_ref(1, 1) = 1.f; } return 0; } /* Get machine constants. */ safmin = slamch_("Safe minimum"); eps = slamch_("Precision"); smlnum = safmin / eps; bignum = 1.f / smlnum; rmin = sqrt(smlnum); rmax = sqrt(bignum); /* Scale matrix to allowable range, if necessary. */ anrm = slansy_("M", uplo, n, &a[a_offset], lda, &work[1]); iscale = 0; if (anrm > 0.f && anrm < rmin) { iscale = 1; sigma = rmin / anrm; } else if (anrm > rmax) { iscale = 1; sigma = rmax / anrm; } if (iscale == 1) { slascl_(uplo, &c__0, &c__0, &c_b12, &sigma, n, n, &a[a_offset], lda, info); } /* Call SSYTRD to reduce symmetric matrix to tridiagonal form. */ inde = 1; indtau = inde + *n; indwrk = indtau + *n; llwork = *lwork - indwrk + 1; indwk2 = indwrk + *n * *n; llwrk2 = *lwork - indwk2 + 1; ssytrd_(uplo, n, &a[a_offset], lda, &w[1], &work[inde], &work[indtau], & work[indwrk], &llwork, &iinfo); lopt = (*n << 1) + work[indwrk]; /* For eigenvalues only, call SSTERF. For eigenvectors, first call SSTEDC to generate the eigenvector matrix, WORK(INDWRK), of the tridiagonal matrix, then call SORMTR to multiply it by the Householder transformations stored in A. */ if (! wantz) { ssterf_(n, &w[1], &work[inde], info); } else { sstedc_("I", n, &w[1], &work[inde], &work[indwrk], n, &work[indwk2], & llwrk2, &iwork[1], liwork, info); sormtr_("L", uplo, "N", n, n, &a[a_offset], lda, &work[indtau], &work[ indwrk], n, &work[indwk2], &llwrk2, &iinfo); slacpy_("A", n, n, &work[indwrk], n, &a[a_offset], lda); /* Computing MAX Computing 2nd power */ i__3 = *n; i__1 = lopt, i__2 = *n * 6 + 1 + (i__3 * i__3 << 1); lopt = max(i__1,i__2); } /* If matrix was scaled, then rescale eigenvalues appropriately. */ if (iscale == 1) { r__1 = 1.f / sigma; sscal_(n, &r__1, &w[1], &c__1); } work[1] = (real) lopt; iwork[1] = liopt; return 0; /* End of SSYEVD */ } /* ssyevd_ */
/* Subroutine */ int sgsvts_(integer *m, integer *p, integer *n, real *a, real *af, integer *lda, real *b, real *bf, integer *ldb, real *u, integer *ldu, real *v, integer *ldv, real *q, integer *ldq, real * alpha, real *beta, real *r__, integer *ldr, integer *iwork, real * work, integer *lwork, real *rwork, real *result) { /* System generated locals */ integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, bf_dim1, bf_offset, q_dim1, q_offset, r_dim1, r_offset, u_dim1, u_offset, v_dim1, v_offset, i__1, i__2; real r__1; /* Local variables */ integer i__, j, k, l; real ulp; integer info; real unfl, temp, resid; extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, integer *, real *, real *, integer *, real *, integer *, real *, real *, integer *); real anorm, bnorm; extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, integer *), ssyrk_(char *, char *, integer *, integer *, real *, real *, integer *, real *, real *, integer *); extern doublereal slamch_(char *), slange_(char *, integer *, integer *, real *, integer *, real *); extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, integer *, real *, integer *), slaset_(char *, integer *, integer *, real *, real *, real *, integer *), sggsvd_( char *, char *, char *, integer *, integer *, integer *, integer * , integer *, real *, integer *, real *, integer *, real *, real *, real *, integer *, real *, integer *, real *, integer *, real *, integer *, integer *); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); real ulpinv; /* -- LAPACK test routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SGSVTS tests SGGSVD, which computes the GSVD of an M-by-N matrix A */ /* and a P-by-N matrix B: */ /* U'*A*Q = D1*R and V'*B*Q = D2*R. */ /* Arguments */ /* ========= */ /* M (input) INTEGER */ /* The number of rows of the matrix A. M >= 0. */ /* P (input) INTEGER */ /* The number of rows of the matrix B. P >= 0. */ /* N (input) INTEGER */ /* The number of columns of the matrices A and B. N >= 0. */ /* A (input) REAL array, dimension (LDA,M) */ /* The M-by-N matrix A. */ /* AF (output) REAL array, dimension (LDA,N) */ /* Details of the GSVD of A and B, as returned by SGGSVD, */ /* see SGGSVD for further details. */ /* LDA (input) INTEGER */ /* The leading dimension of the arrays A and AF. */ /* LDA >= max( 1,M ). */ /* B (input) REAL array, dimension (LDB,P) */ /* On entry, the P-by-N matrix B. */ /* BF (output) REAL array, dimension (LDB,N) */ /* Details of the GSVD of A and B, as returned by SGGSVD, */ /* see SGGSVD for further details. */ /* LDB (input) INTEGER */ /* The leading dimension of the arrays B and BF. */ /* LDB >= max(1,P). */ /* U (output) REAL array, dimension(LDU,M) */ /* The M by M orthogonal matrix U. */ /* LDU (input) INTEGER */ /* The leading dimension of the array U. LDU >= max(1,M). */ /* V (output) REAL array, dimension(LDV,M) */ /* The P by P orthogonal matrix V. */ /* LDV (input) INTEGER */ /* The leading dimension of the array V. LDV >= max(1,P). */ /* Q (output) REAL array, dimension(LDQ,N) */ /* The N by N orthogonal matrix Q. */ /* LDQ (input) INTEGER */ /* The leading dimension of the array Q. LDQ >= max(1,N). */ /* ALPHA (output) REAL array, dimension (N) */ /* BETA (output) REAL array, dimension (N) */ /* The generalized singular value pairs of A and B, the */ /* ``diagonal'' matrices D1 and D2 are constructed from */ /* ALPHA and BETA, see subroutine SGGSVD for details. */ /* R (output) REAL array, dimension(LDQ,N) */ /* The upper triangular matrix R. */ /* LDR (input) INTEGER */ /* The leading dimension of the array R. LDR >= max(1,N). */ /* IWORK (workspace) INTEGER array, dimension (N) */ /* WORK (workspace) REAL array, dimension (LWORK) */ /* LWORK (input) INTEGER */ /* The dimension of the array WORK, */ /* LWORK >= max(M,P,N)*max(M,P,N). */ /* RWORK (workspace) REAL array, dimension (max(M,P,N)) */ /* RESULT (output) REAL array, dimension (6) */ /* The test ratios: */ /* RESULT(1) = norm( U'*A*Q - D1*R ) / ( MAX(M,N)*norm(A)*ULP) */ /* RESULT(2) = norm( V'*B*Q - D2*R ) / ( MAX(P,N)*norm(B)*ULP) */ /* RESULT(3) = norm( I - U'*U ) / ( M*ULP ) */ /* RESULT(4) = norm( I - V'*V ) / ( P*ULP ) */ /* RESULT(5) = norm( I - Q'*Q ) / ( N*ULP ) */ /* RESULT(6) = 0 if ALPHA is in decreasing order; */ /* = ULPINV otherwise. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Parameter adjustments */ af_dim1 = *lda; af_offset = 1 + af_dim1; af -= af_offset; a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; bf_dim1 = *ldb; bf_offset = 1 + bf_dim1; bf -= bf_offset; b_dim1 = *ldb; b_offset = 1 + b_dim1; b -= b_offset; u_dim1 = *ldu; u_offset = 1 + u_dim1; u -= u_offset; v_dim1 = *ldv; v_offset = 1 + v_dim1; v -= v_offset; q_dim1 = *ldq; q_offset = 1 + q_dim1; q -= q_offset; --alpha; --beta; r_dim1 = *ldr; r_offset = 1 + r_dim1; r__ -= r_offset; --iwork; --work; --rwork; --result; /* Function Body */ ulp = slamch_("Precision"); ulpinv = 1.f / ulp; unfl = slamch_("Safe minimum"); /* Copy the matrix A to the array AF. */ slacpy_("Full", m, n, &a[a_offset], lda, &af[af_offset], lda); slacpy_("Full", p, n, &b[b_offset], ldb, &bf[bf_offset], ldb); /* Computing MAX */ r__1 = slange_("1", m, n, &a[a_offset], lda, &rwork[1]); anorm = dmax(r__1,unfl); /* Computing MAX */ r__1 = slange_("1", p, n, &b[b_offset], ldb, &rwork[1]); bnorm = dmax(r__1,unfl); /* Factorize the matrices A and B in the arrays AF and BF. */ sggsvd_("U", "V", "Q", m, n, p, &k, &l, &af[af_offset], lda, &bf[ bf_offset], ldb, &alpha[1], &beta[1], &u[u_offset], ldu, &v[ v_offset], ldv, &q[q_offset], ldq, &work[1], &iwork[1], &info); /* Copy R */ /* Computing MIN */ i__2 = k + l; i__1 = min(i__2,*m); for (i__ = 1; i__ <= i__1; ++i__) { i__2 = k + l; for (j = i__; j <= i__2; ++j) { r__[i__ + j * r_dim1] = af[i__ + (*n - k - l + j) * af_dim1]; /* L10: */ } /* L20: */ } if (*m - k - l < 0) { i__1 = k + l; for (i__ = *m + 1; i__ <= i__1; ++i__) { i__2 = k + l; for (j = i__; j <= i__2; ++j) { r__[i__ + j * r_dim1] = bf[i__ - k + (*n - k - l + j) * bf_dim1]; /* L30: */ } /* L40: */ } } /* Compute A:= U'*A*Q - D1*R */ sgemm_("No transpose", "No transpose", m, n, n, &c_b17, &a[a_offset], lda, &q[q_offset], ldq, &c_b18, &work[1], lda) ; sgemm_("Transpose", "No transpose", m, n, m, &c_b17, &u[u_offset], ldu, & work[1], lda, &c_b18, &a[a_offset], lda); i__1 = k; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = k + l; for (j = i__; j <= i__2; ++j) { a[i__ + (*n - k - l + j) * a_dim1] -= r__[i__ + j * r_dim1]; /* L50: */ } /* L60: */ } /* Computing MIN */ i__2 = k + l; i__1 = min(i__2,*m); for (i__ = k + 1; i__ <= i__1; ++i__) { i__2 = k + l; for (j = i__; j <= i__2; ++j) { a[i__ + (*n - k - l + j) * a_dim1] -= alpha[i__] * r__[i__ + j * r_dim1]; /* L70: */ } /* L80: */ } /* Compute norm( U'*A*Q - D1*R ) / ( MAX(1,M,N)*norm(A)*ULP ) . */ resid = slange_("1", m, n, &a[a_offset], lda, &rwork[1]); if (anorm > 0.f) { /* Computing MAX */ i__1 = max(1,*m); result[1] = resid / (real) max(i__1,*n) / anorm / ulp; } else { result[1] = 0.f; } /* Compute B := V'*B*Q - D2*R */ sgemm_("No transpose", "No transpose", p, n, n, &c_b17, &b[b_offset], ldb, &q[q_offset], ldq, &c_b18, &work[1], ldb) ; sgemm_("Transpose", "No transpose", p, n, p, &c_b17, &v[v_offset], ldv, & work[1], ldb, &c_b18, &b[b_offset], ldb); i__1 = l; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = l; for (j = i__; j <= i__2; ++j) { b[i__ + (*n - l + j) * b_dim1] -= beta[k + i__] * r__[k + i__ + ( k + j) * r_dim1]; /* L90: */ } /* L100: */ } /* Compute norm( V'*B*Q - D2*R ) / ( MAX(P,N)*norm(B)*ULP ) . */ resid = slange_("1", p, n, &b[b_offset], ldb, &rwork[1]); if (bnorm > 0.f) { /* Computing MAX */ i__1 = max(1,*p); result[2] = resid / (real) max(i__1,*n) / bnorm / ulp; } else { result[2] = 0.f; } /* Compute I - U'*U */ slaset_("Full", m, m, &c_b18, &c_b17, &work[1], ldq); ssyrk_("Upper", "Transpose", m, m, &c_b44, &u[u_offset], ldu, &c_b17, & work[1], ldu); /* Compute norm( I - U'*U ) / ( M * ULP ) . */ resid = slansy_("1", "Upper", m, &work[1], ldu, &rwork[1]); result[3] = resid / (real) max(1,*m) / ulp; /* Compute I - V'*V */ slaset_("Full", p, p, &c_b18, &c_b17, &work[1], ldv); ssyrk_("Upper", "Transpose", p, p, &c_b44, &v[v_offset], ldv, &c_b17, & work[1], ldv); /* Compute norm( I - V'*V ) / ( P * ULP ) . */ resid = slansy_("1", "Upper", p, &work[1], ldv, &rwork[1]); result[4] = resid / (real) max(1,*p) / ulp; /* Compute I - Q'*Q */ slaset_("Full", n, n, &c_b18, &c_b17, &work[1], ldq); ssyrk_("Upper", "Transpose", n, n, &c_b44, &q[q_offset], ldq, &c_b17, & work[1], ldq); /* Compute norm( I - Q'*Q ) / ( N * ULP ) . */ resid = slansy_("1", "Upper", n, &work[1], ldq, &rwork[1]); result[5] = resid / (real) max(1,*n) / ulp; /* Check sorting */ scopy_(n, &alpha[1], &c__1, &work[1], &c__1); /* Computing MIN */ i__2 = k + l; i__1 = min(i__2,*m); for (i__ = k + 1; i__ <= i__1; ++i__) { j = iwork[i__]; if (i__ != j) { temp = work[i__]; work[i__] = work[j]; work[j] = temp; } /* L110: */ } result[6] = 0.f; /* Computing MIN */ i__2 = k + l; i__1 = min(i__2,*m) - 1; for (i__ = k + 1; i__ <= i__1; ++i__) { if (work[i__] < work[i__ + 1]) { result[6] = ulpinv; } /* L120: */ } return 0; /* End of SGSVTS */ } /* sgsvts_ */
/* Subroutine */ int schksy_(logical *dotype, integer *nn, integer *nval, integer *nnb, integer *nbval, integer *nns, integer *nsval, real * thresh, logical *tsterr, integer *nmax, real *a, real *afac, real * ainv, real *b, real *x, real *xact, real *work, real *rwork, integer * iwork, integer *nout) { /* Initialized data */ static integer iseedy[4] = { 1988,1989,1990,1991 }; static char uplos[1*2] = "U" "L"; /* Format strings */ static char fmt_9999[] = "(\002 UPLO = '\002,a1,\002', N =\002,i5,\002, " "NB =\002,i4,\002, type \002,i2,\002, test \002,i2,\002, ratio " "=\002,g12.5)"; static char fmt_9998[] = "(\002 UPLO = '\002,a1,\002', N =\002,i5,\002, " "NRHS=\002,i3,\002, type \002,i2,\002, test(\002,i2,\002) =\002,g" "12.5)"; static char fmt_9997[] = "(\002 UPLO = '\002,a1,\002', N =\002,i5,\002" ",\002,10x,\002 type \002,i2,\002, test(\002,i2,\002) =\002,g12.5)" ; /* System generated locals */ integer i__1, i__2, i__3, i__4; /* Builtin functions */ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen); integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void); /* Local variables */ integer i__, j, k, n, i1, i2, nb, in, kl, ku, nt, lda, inb, ioff, mode, imat, info; char path[3], dist[1]; integer irhs, nrhs; char uplo[1], type__[1]; integer nrun; extern /* Subroutine */ int alahd_(integer *, char *); integer nfail, iseed[4]; real rcond; extern /* Subroutine */ int sget04_(integer *, integer *, real *, integer *, real *, integer *, real *, real *); integer nimat; extern doublereal sget06_(real *, real *); real anorm; extern /* Subroutine */ int spot02_(char *, integer *, integer *, real *, integer *, real *, integer *, real *, integer *, real *, real *); integer iuplo, izero, nerrs; extern /* Subroutine */ int spot03_(char *, integer *, real *, integer *, real *, integer *, real *, integer *, real *, real *, real *), spot05_(char *, integer *, integer *, real *, integer *, real *, integer *, real *, integer *, real *, integer *, real *, real *, real *); integer lwork; logical zerot; extern /* Subroutine */ int ssyt01_(char *, integer *, real *, integer *, real *, integer *, integer *, real *, integer *, real *, real *); char xtype[1]; extern /* Subroutine */ int slatb4_(char *, integer *, integer *, integer *, char *, integer *, integer *, real *, integer *, real *, char * ), alaerh_(char *, char *, integer *, integer *, char *, integer *, integer *, integer *, integer *, integer *, integer *, integer *, integer *, integer *); real rcondc; extern /* Subroutine */ int alasum_(char *, integer *, integer *, integer *, integer *); real cndnum; logical trfcon; extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, integer *, real *, integer *), slarhs_(char *, char *, char *, char *, integer *, integer *, integer *, integer *, integer *, real *, integer *, real *, integer *, real *, integer * , integer *, integer *), xlaenv_( integer *, integer *), slatms_(integer *, integer *, char *, integer *, char *, real *, integer *, real *, real *, integer *, integer *, char *, real *, integer *, real *, integer *); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); real result[8]; extern /* Subroutine */ int ssycon_(char *, integer *, real *, integer *, integer *, real *, real *, real *, integer *, integer *), serrsy_(char *, integer *), ssyrfs_(char *, integer *, integer *, real *, integer *, real *, integer *, integer *, real * , integer *, real *, integer *, real *, real *, real *, integer *, integer *), ssytrf_(char *, integer *, real *, integer *, integer *, real *, integer *, integer *), ssytri_(char *, integer *, real *, integer *, integer *, real *, integer *), ssytrs_(char *, integer *, integer *, real *, integer *, integer *, real *, integer *, integer *); /* Fortran I/O blocks */ static cilist io___39 = { 0, 0, 0, fmt_9999, 0 }; static cilist io___42 = { 0, 0, 0, fmt_9998, 0 }; static cilist io___44 = { 0, 0, 0, fmt_9997, 0 }; /* -- LAPACK test routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SCHKSY tests SSYTRF, -TRI, -TRS, -RFS, and -CON. */ /* Arguments */ /* ========= */ /* DOTYPE (input) LOGICAL array, dimension (NTYPES) */ /* The matrix types to be used for testing. Matrices of type j */ /* (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) = */ /* .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used. */ /* NN (input) INTEGER */ /* The number of values of N contained in the vector NVAL. */ /* NVAL (input) INTEGER array, dimension (NN) */ /* The values of the matrix dimension N. */ /* NNB (input) INTEGER */ /* The number of values of NB contained in the vector NBVAL. */ /* NBVAL (input) INTEGER array, dimension (NBVAL) */ /* The values of the blocksize NB. */ /* NNS (input) INTEGER */ /* The number of values of NRHS contained in the vector NSVAL. */ /* NSVAL (input) INTEGER array, dimension (NNS) */ /* The values of the number of right hand sides NRHS. */ /* THRESH (input) REAL */ /* The threshold value for the test ratios. A result is */ /* included in the output file if RESULT >= THRESH. To have */ /* every test ratio printed, use THRESH = 0. */ /* TSTERR (input) LOGICAL */ /* Flag that indicates whether error exits are to be tested. */ /* NMAX (input) INTEGER */ /* The maximum value permitted for N, used in dimensioning the */ /* work arrays. */ /* A (workspace) REAL array, dimension (NMAX*NMAX) */ /* AFAC (workspace) REAL array, dimension (NMAX*NMAX) */ /* AINV (workspace) REAL array, dimension (NMAX*NMAX) */ /* B (workspace) REAL array, dimension (NMAX*NSMAX) */ /* where NSMAX is the largest entry in NSVAL. */ /* X (workspace) REAL array, dimension (NMAX*NSMAX) */ /* XACT (workspace) REAL array, dimension (NMAX*NSMAX) */ /* WORK (workspace) REAL array, dimension */ /* (NMAX*max(3,NSMAX)) */ /* RWORK (workspace) REAL array, dimension */ /* (max(NMAX,2*NSMAX)) */ /* IWORK (workspace) INTEGER array, dimension (2*NMAX) */ /* NOUT (input) INTEGER */ /* The unit number for output. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. Local Arrays .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Scalars in Common .. */ /* .. */ /* .. Common blocks .. */ /* .. */ /* .. Data statements .. */ /* Parameter adjustments */ --iwork; --rwork; --work; --xact; --x; --b; --ainv; --afac; --a; --nsval; --nbval; --nval; --dotype; /* Function Body */ /* .. */ /* .. Executable Statements .. */ /* Initialize constants and the random number seed. */ s_copy(path, "Single precision", (ftnlen)1, (ftnlen)16); s_copy(path + 1, "SY", (ftnlen)2, (ftnlen)2); nrun = 0; nfail = 0; nerrs = 0; for (i__ = 1; i__ <= 4; ++i__) { iseed[i__ - 1] = iseedy[i__ - 1]; /* L10: */ } /* Test the error exits */ if (*tsterr) { serrsy_(path, nout); } infoc_1.infot = 0; xlaenv_(&c__2, &c__2); /* Do for each value of N in NVAL */ i__1 = *nn; for (in = 1; in <= i__1; ++in) { n = nval[in]; lda = max(n,1); *(unsigned char *)xtype = 'N'; nimat = 10; if (n <= 0) { nimat = 1; } izero = 0; i__2 = nimat; for (imat = 1; imat <= i__2; ++imat) { /* Do the tests only if DOTYPE( IMAT ) is true. */ if (! dotype[imat]) { goto L170; } /* Skip types 3, 4, 5, or 6 if the matrix size is too small. */ zerot = imat >= 3 && imat <= 6; if (zerot && n < imat - 2) { goto L170; } /* Do first for UPLO = 'U', then for UPLO = 'L' */ for (iuplo = 1; iuplo <= 2; ++iuplo) { *(unsigned char *)uplo = *(unsigned char *)&uplos[iuplo - 1]; /* Set up parameters with SLATB4 and generate a test matrix */ /* with SLATMS. */ slatb4_(path, &imat, &n, &n, type__, &kl, &ku, &anorm, &mode, &cndnum, dist); s_copy(srnamc_1.srnamt, "SLATMS", (ftnlen)32, (ftnlen)6); slatms_(&n, &n, dist, iseed, type__, &rwork[1], &mode, & cndnum, &anorm, &kl, &ku, uplo, &a[1], &lda, &work[1], &info); /* Check error code from SLATMS. */ if (info != 0) { alaerh_(path, "SLATMS", &info, &c__0, uplo, &n, &n, &c_n1, &c_n1, &c_n1, &imat, &nfail, &nerrs, nout); goto L160; } /* For types 3-6, zero one or more rows and columns of */ /* the matrix to test that INFO is returned correctly. */ if (zerot) { if (imat == 3) { izero = 1; } else if (imat == 4) { izero = n; } else { izero = n / 2 + 1; } if (imat < 6) { /* Set row and column IZERO to zero. */ if (iuplo == 1) { ioff = (izero - 1) * lda; i__3 = izero - 1; for (i__ = 1; i__ <= i__3; ++i__) { a[ioff + i__] = 0.f; /* L20: */ } ioff += izero; i__3 = n; for (i__ = izero; i__ <= i__3; ++i__) { a[ioff] = 0.f; ioff += lda; /* L30: */ } } else { ioff = izero; i__3 = izero - 1; for (i__ = 1; i__ <= i__3; ++i__) { a[ioff] = 0.f; ioff += lda; /* L40: */ } ioff -= izero; i__3 = n; for (i__ = izero; i__ <= i__3; ++i__) { a[ioff + i__] = 0.f; /* L50: */ } } } else { ioff = 0; if (iuplo == 1) { /* Set the first IZERO rows and columns to zero. */ i__3 = n; for (j = 1; j <= i__3; ++j) { i2 = min(j,izero); i__4 = i2; for (i__ = 1; i__ <= i__4; ++i__) { a[ioff + i__] = 0.f; /* L60: */ } ioff += lda; /* L70: */ } } else { /* Set the last IZERO rows and columns to zero. */ i__3 = n; for (j = 1; j <= i__3; ++j) { i1 = max(j,izero); i__4 = n; for (i__ = i1; i__ <= i__4; ++i__) { a[ioff + i__] = 0.f; /* L80: */ } ioff += lda; /* L90: */ } } } } else { izero = 0; } /* Do for each value of NB in NBVAL */ i__3 = *nnb; for (inb = 1; inb <= i__3; ++inb) { nb = nbval[inb]; xlaenv_(&c__1, &nb); /* Compute the L*D*L' or U*D*U' factorization of the */ /* matrix. */ slacpy_(uplo, &n, &n, &a[1], &lda, &afac[1], &lda); lwork = max(2,nb) * lda; s_copy(srnamc_1.srnamt, "SSYTRF", (ftnlen)32, (ftnlen)6); ssytrf_(uplo, &n, &afac[1], &lda, &iwork[1], &ainv[1], & lwork, &info); /* Adjust the expected value of INFO to account for */ /* pivoting. */ k = izero; if (k > 0) { L100: if (iwork[k] < 0) { if (iwork[k] != -k) { k = -iwork[k]; goto L100; } } else if (iwork[k] != k) { k = iwork[k]; goto L100; } } /* Check error code from SSYTRF. */ if (info != k) { alaerh_(path, "SSYTRF", &info, &k, uplo, &n, &n, & c_n1, &c_n1, &nb, &imat, &nfail, &nerrs, nout); } if (info != 0) { trfcon = TRUE_; } else { trfcon = FALSE_; } /* + TEST 1 */ /* Reconstruct matrix from factors and compute residual. */ ssyt01_(uplo, &n, &a[1], &lda, &afac[1], &lda, &iwork[1], &ainv[1], &lda, &rwork[1], result); nt = 1; /* + TEST 2 */ /* Form the inverse and compute the residual. */ if (inb == 1 && ! trfcon) { slacpy_(uplo, &n, &n, &afac[1], &lda, &ainv[1], &lda); s_copy(srnamc_1.srnamt, "SSYTRI", (ftnlen)32, (ftnlen) 6); ssytri_(uplo, &n, &ainv[1], &lda, &iwork[1], &work[1], &info); /* Check error code from SSYTRI. */ if (info != 0) { alaerh_(path, "SSYTRI", &info, &c_n1, uplo, &n, & n, &c_n1, &c_n1, &c_n1, &imat, &nfail, & nerrs, nout); } spot03_(uplo, &n, &a[1], &lda, &ainv[1], &lda, &work[ 1], &lda, &rwork[1], &rcondc, &result[1]); nt = 2; } /* Print information about the tests that did not pass */ /* the threshold. */ i__4 = nt; for (k = 1; k <= i__4; ++k) { if (result[k - 1] >= *thresh) { if (nfail == 0 && nerrs == 0) { alahd_(nout, path); } io___39.ciunit = *nout; s_wsfe(&io___39); do_fio(&c__1, uplo, (ftnlen)1); do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer)) ; do_fio(&c__1, (char *)&nb, (ftnlen)sizeof(integer) ); do_fio(&c__1, (char *)&imat, (ftnlen)sizeof( integer)); do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer)) ; do_fio(&c__1, (char *)&result[k - 1], (ftnlen) sizeof(real)); e_wsfe(); ++nfail; } /* L110: */ } nrun += nt; /* Skip the other tests if this is not the first block */ /* size. */ if (inb > 1) { goto L150; } /* Do only the condition estimate if INFO is not 0. */ if (trfcon) { rcondc = 0.f; goto L140; } i__4 = *nns; for (irhs = 1; irhs <= i__4; ++irhs) { nrhs = nsval[irhs]; /* + TEST 3 */ /* Solve and compute residual for A * X = B. */ s_copy(srnamc_1.srnamt, "SLARHS", (ftnlen)32, (ftnlen) 6); slarhs_(path, xtype, uplo, " ", &n, &n, &kl, &ku, & nrhs, &a[1], &lda, &xact[1], &lda, &b[1], & lda, iseed, &info); slacpy_("Full", &n, &nrhs, &b[1], &lda, &x[1], &lda); s_copy(srnamc_1.srnamt, "SSYTRS", (ftnlen)32, (ftnlen) 6); ssytrs_(uplo, &n, &nrhs, &afac[1], &lda, &iwork[1], & x[1], &lda, &info); /* Check error code from SSYTRS. */ if (info != 0) { alaerh_(path, "SSYTRS", &info, &c__0, uplo, &n, & n, &c_n1, &c_n1, &nrhs, &imat, &nfail, & nerrs, nout); } slacpy_("Full", &n, &nrhs, &b[1], &lda, &work[1], & lda); spot02_(uplo, &n, &nrhs, &a[1], &lda, &x[1], &lda, & work[1], &lda, &rwork[1], &result[2]); /* + TEST 4 */ /* Check solution from generated exact solution. */ sget04_(&n, &nrhs, &x[1], &lda, &xact[1], &lda, & rcondc, &result[3]); /* + TESTS 5, 6, and 7 */ /* Use iterative refinement to improve the solution. */ s_copy(srnamc_1.srnamt, "SSYRFS", (ftnlen)32, (ftnlen) 6); ssyrfs_(uplo, &n, &nrhs, &a[1], &lda, &afac[1], &lda, &iwork[1], &b[1], &lda, &x[1], &lda, &rwork[1] , &rwork[nrhs + 1], &work[1], &iwork[n + 1], & info); /* Check error code from SSYRFS. */ if (info != 0) { alaerh_(path, "SSYRFS", &info, &c__0, uplo, &n, & n, &c_n1, &c_n1, &nrhs, &imat, &nfail, & nerrs, nout); } sget04_(&n, &nrhs, &x[1], &lda, &xact[1], &lda, & rcondc, &result[4]); spot05_(uplo, &n, &nrhs, &a[1], &lda, &b[1], &lda, &x[ 1], &lda, &xact[1], &lda, &rwork[1], &rwork[ nrhs + 1], &result[5]); /* Print information about the tests that did not pass */ /* the threshold. */ for (k = 3; k <= 7; ++k) { if (result[k - 1] >= *thresh) { if (nfail == 0 && nerrs == 0) { alahd_(nout, path); } io___42.ciunit = *nout; s_wsfe(&io___42); do_fio(&c__1, uplo, (ftnlen)1); do_fio(&c__1, (char *)&n, (ftnlen)sizeof( integer)); do_fio(&c__1, (char *)&nrhs, (ftnlen)sizeof( integer)); do_fio(&c__1, (char *)&imat, (ftnlen)sizeof( integer)); do_fio(&c__1, (char *)&k, (ftnlen)sizeof( integer)); do_fio(&c__1, (char *)&result[k - 1], (ftnlen) sizeof(real)); e_wsfe(); ++nfail; } /* L120: */ } nrun += 5; /* L130: */ } /* + TEST 8 */ /* Get an estimate of RCOND = 1/CNDNUM. */ L140: anorm = slansy_("1", uplo, &n, &a[1], &lda, &rwork[1]); s_copy(srnamc_1.srnamt, "SSYCON", (ftnlen)32, (ftnlen)6); ssycon_(uplo, &n, &afac[1], &lda, &iwork[1], &anorm, & rcond, &work[1], &iwork[n + 1], &info); /* Check error code from SSYCON. */ if (info != 0) { alaerh_(path, "SSYCON", &info, &c__0, uplo, &n, &n, & c_n1, &c_n1, &c_n1, &imat, &nfail, &nerrs, nout); } result[7] = sget06_(&rcond, &rcondc); /* Print information about the tests that did not pass */ /* the threshold. */ if (result[7] >= *thresh) { if (nfail == 0 && nerrs == 0) { alahd_(nout, path); } io___44.ciunit = *nout; s_wsfe(&io___44); do_fio(&c__1, uplo, (ftnlen)1); do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer)); do_fio(&c__1, (char *)&imat, (ftnlen)sizeof(integer)); do_fio(&c__1, (char *)&c__8, (ftnlen)sizeof(integer)); do_fio(&c__1, (char *)&result[7], (ftnlen)sizeof(real) ); e_wsfe(); ++nfail; } ++nrun; L150: ; } L160: ; } L170: ; } /* L180: */ } /* Print a summary of the results. */ alasum_(path, nout, &nfail, &nrun, &nerrs); return 0; /* End of SCHKSY */ } /* schksy_ */
/* Subroutine */ int ssyevx_(char *jobz, char *range, char *uplo, integer *n, real *a, integer *lda, real *vl, real *vu, integer *il, integer *iu, real *abstol, integer *m, real *w, real *z__, integer *ldz, real * work, integer *lwork, integer *iwork, integer *ifail, integer *info) { /* System generated locals */ integer a_dim1, a_offset, z_dim1, z_offset, i__1, i__2; real r__1, r__2; /* Local variables */ integer i__, j, nb, jj; real eps, vll, vuu, tmp1; integer indd, inde; real anrm; integer imax; real rmin, rmax; logical test; integer itmp1, indee; real sigma; integer iinfo; char order[1]; logical lower; logical wantz, alleig, indeig; integer iscale, indibl; logical valeig; real safmin; real abstll, bignum; integer indtau, indisp, indiwo, indwkn; integer indwrk, lwkmin; integer llwrkn, llwork, nsplit; real smlnum; integer lwkopt; logical lquery; /* -- LAPACK driver routine (version 3.2) -- */ /* November 2006 */ /* Purpose */ /* ======= */ /* SSYEVX computes selected eigenvalues and, optionally, eigenvectors */ /* of a real symmetric matrix A. Eigenvalues and eigenvectors can be */ /* selected by specifying either a range of values or a range of indices */ /* for the desired eigenvalues. */ /* Arguments */ /* ========= */ /* JOBZ (input) CHARACTER*1 */ /* = 'N': Compute eigenvalues only; */ /* = 'V': Compute eigenvalues and eigenvectors. */ /* RANGE (input) CHARACTER*1 */ /* = 'A': all eigenvalues will be found. */ /* = 'V': all eigenvalues in the half-open interval (VL,VU] */ /* will be found. */ /* = 'I': the IL-th through IU-th eigenvalues will be found. */ /* 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. */ /* A (input/output) REAL array, dimension (LDA, N) */ /* On entry, the symmetric matrix A. If UPLO = 'U', the */ /* leading N-by-N upper triangular part of A contains the */ /* upper triangular part of the matrix A. If UPLO = 'L', */ /* the leading N-by-N lower triangular part of A contains */ /* the lower triangular part of the matrix A. */ /* On exit, the lower triangle (if UPLO='L') or the upper */ /* triangle (if UPLO='U') of A, including the diagonal, is */ /* destroyed. */ /* LDA (input) INTEGER */ /* The leading dimension of the array A. LDA >= max(1,N). */ /* VL (input) REAL */ /* VU (input) REAL */ /* If RANGE='V', the lower and upper bounds of the interval to */ /* be searched for eigenvalues. VL < VU. */ /* Not referenced if RANGE = 'A' or 'I'. */ /* IL (input) INTEGER */ /* IU (input) INTEGER */ /* If RANGE='I', the indices (in ascending order) of the */ /* smallest and largest eigenvalues to be returned. */ /* 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0. */ /* Not referenced if RANGE = 'A' or 'V'. */ /* ABSTOL (input) REAL */ /* The absolute error tolerance for the eigenvalues. */ /* An approximate eigenvalue is accepted as converged */ /* when it is determined to lie in an interval [a,b] */ /* of width less than or equal to */ /* ABSTOL + EPS * max( |a|,|b| ) , */ /* where EPS is the machine precision. If ABSTOL is less than */ /* or equal to zero, then EPS*|T| will be used in its place, */ /* where |T| is the 1-norm of the tridiagonal matrix obtained */ /* by reducing A to tridiagonal form. */ /* Eigenvalues will be computed most accurately when ABSTOL is */ /* set to twice the underflow threshold 2*SLAMCH('S'), not zero. */ /* If this routine returns with INFO>0, indicating that some */ /* eigenvectors did not converge, try setting ABSTOL to */ /* 2*SLAMCH('S'). */ /* See "Computing Small Singular Values of Bidiagonal Matrices */ /* with Guaranteed High Relative Accuracy," by Demmel and */ /* Kahan, LAPACK Working Note #3. */ /* M (output) INTEGER */ /* The total number of eigenvalues found. 0 <= M <= N. */ /* If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1. */ /* W (output) REAL array, dimension (N) */ /* On normal exit, the first M elements contain the selected */ /* eigenvalues in ascending order. */ /* Z (output) REAL array, dimension (LDZ, max(1,M)) */ /* If JOBZ = 'V', then if INFO = 0, the first M columns of Z */ /* contain the orthonormal eigenvectors of the matrix A */ /* corresponding to the selected eigenvalues, with the i-th */ /* column of Z holding the eigenvector associated with W(i). */ /* If an eigenvector fails to converge, then that column of Z */ /* contains the latest approximation to the eigenvector, and the */ /* index of the eigenvector is returned in IFAIL. */ /* If JOBZ = 'N', then Z is not referenced. */ /* Note: the user must ensure that at least max(1,M) columns are */ /* supplied in the array Z; if RANGE = 'V', the exact value of M */ /* is not known in advance and an upper bound must be used. */ /* LDZ (input) INTEGER */ /* The leading dimension of the array Z. LDZ >= 1, and if */ /* JOBZ = 'V', LDZ >= max(1,N). */ /* WORK (workspace/output) REAL array, dimension (MAX(1,LWORK)) */ /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ /* LWORK (input) INTEGER */ /* The length of the array WORK. LWORK >= 1, when N <= 1; */ /* otherwise 8*N. */ /* For optimal efficiency, LWORK >= (NB+3)*N, */ /* where NB is the max of the blocksize for SSYTRD and SORMTR */ /* returned by ILAENV. */ /* If LWORK = -1, then a workspace query is assumed; the routine */ /* only calculates the optimal size of the WORK array, returns */ /* this value as the first entry of the WORK array, and no error */ /* message related to LWORK is issued by XERBLA. */ /* IWORK (workspace) INTEGER array, dimension (5*N) */ /* IFAIL (output) INTEGER array, dimension (N) */ /* If JOBZ = 'V', then if INFO = 0, the first M elements of */ /* IFAIL are zero. If INFO > 0, then IFAIL contains the */ /* indices of the eigenvectors that failed to converge. */ /* If JOBZ = 'N', then IFAIL is not referenced. */ /* INFO (output) INTEGER */ /* = 0: successful exit */ /* < 0: if INFO = -i, the i-th argument had an illegal value */ /* > 0: if INFO = i, then i eigenvectors failed to converge. */ /* Their indices are stored in array IFAIL. */ /* ===================================================================== */ /* Test the input parameters. */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; --w; z_dim1 = *ldz; z_offset = 1 + z_dim1; z__ -= z_offset; --work; --iwork; --ifail; /* Function Body */ lower = lsame_(uplo, "L"); wantz = lsame_(jobz, "V"); alleig = lsame_(range, "A"); valeig = lsame_(range, "V"); indeig = lsame_(range, "I"); lquery = *lwork == -1; *info = 0; if (! (wantz || lsame_(jobz, "N"))) { *info = -1; } else if (! (alleig || valeig || indeig)) { *info = -2; } else if (! (lower || lsame_(uplo, "U"))) { *info = -3; } else if (*n < 0) { *info = -4; } else if (*lda < max(1,*n)) { *info = -6; } else { if (valeig) { if (*n > 0 && *vu <= *vl) { *info = -8; } } else if (indeig) { if (*il < 1 || *il > max(1,*n)) { *info = -9; } else if (*iu < min(*n,*il) || *iu > *n) { *info = -10; } } } if (*info == 0) { if (*ldz < 1 || wantz && *ldz < *n) { *info = -15; } } if (*info == 0) { if (*n <= 1) { lwkmin = 1; work[1] = (real) lwkmin; } else { lwkmin = *n << 3; nb = ilaenv_(&c__1, "SSYTRD", uplo, n, &c_n1, &c_n1, &c_n1); /* Computing MAX */ i__1 = nb, i__2 = ilaenv_(&c__1, "SORMTR", uplo, n, &c_n1, &c_n1, &c_n1); nb = max(i__1,i__2); /* Computing MAX */ i__1 = lwkmin, i__2 = (nb + 3) * *n; lwkopt = max(i__1,i__2); work[1] = (real) lwkopt; } if (*lwork < lwkmin && ! lquery) { *info = -17; } } if (*info != 0) { i__1 = -(*info); xerbla_("SSYEVX", &i__1); return 0; } else if (lquery) { return 0; } /* Quick return if possible */ *m = 0; if (*n == 0) { return 0; } if (*n == 1) { if (alleig || indeig) { *m = 1; w[1] = a[a_dim1 + 1]; } else { if (*vl < a[a_dim1 + 1] && *vu >= a[a_dim1 + 1]) { *m = 1; w[1] = a[a_dim1 + 1]; } } if (wantz) { z__[z_dim1 + 1] = 1.f; } return 0; } /* Get machine constants. */ safmin = slamch_("Safe minimum"); eps = slamch_("Precision"); smlnum = safmin / eps; bignum = 1.f / smlnum; rmin = sqrt(smlnum); /* Computing MIN */ r__1 = sqrt(bignum), r__2 = 1.f / sqrt(sqrt(safmin)); rmax = dmin(r__1,r__2); /* Scale matrix to allowable range, if necessary. */ iscale = 0; abstll = *abstol; if (valeig) { vll = *vl; vuu = *vu; } anrm = slansy_("M", uplo, n, &a[a_offset], lda, &work[1]); if (anrm > 0.f && anrm < rmin) { iscale = 1; sigma = rmin / anrm; } else if (anrm > rmax) { iscale = 1; sigma = rmax / anrm; } if (iscale == 1) { if (lower) { i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = *n - j + 1; sscal_(&i__2, &sigma, &a[j + j * a_dim1], &c__1); } } else { i__1 = *n; for (j = 1; j <= i__1; ++j) { sscal_(&j, &sigma, &a[j * a_dim1 + 1], &c__1); } } if (*abstol > 0.f) { abstll = *abstol * sigma; } if (valeig) { vll = *vl * sigma; vuu = *vu * sigma; } } /* Call SSYTRD to reduce symmetric matrix to tridiagonal form. */ indtau = 1; inde = indtau + *n; indd = inde + *n; indwrk = indd + *n; llwork = *lwork - indwrk + 1; ssytrd_(uplo, n, &a[a_offset], lda, &work[indd], &work[inde], &work[ indtau], &work[indwrk], &llwork, &iinfo); /* If all eigenvalues are desired and ABSTOL is less than or equal to */ /* zero, then call SSTERF or SORGTR and SSTEQR. If this fails for */ /* some eigenvalue, then try SSTEBZ. */ test = FALSE_; if (indeig) { if (*il == 1 && *iu == *n) { test = TRUE_; } } if ((alleig || test) && *abstol <= 0.f) { scopy_(n, &work[indd], &c__1, &w[1], &c__1); indee = indwrk + (*n << 1); if (! wantz) { i__1 = *n - 1; scopy_(&i__1, &work[inde], &c__1, &work[indee], &c__1); ssterf_(n, &w[1], &work[indee], info); } else { slacpy_("A", n, n, &a[a_offset], lda, &z__[z_offset], ldz); sorgtr_(uplo, n, &z__[z_offset], ldz, &work[indtau], &work[indwrk] , &llwork, &iinfo); i__1 = *n - 1; scopy_(&i__1, &work[inde], &c__1, &work[indee], &c__1); ssteqr_(jobz, n, &w[1], &work[indee], &z__[z_offset], ldz, &work[ indwrk], info); if (*info == 0) { i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { ifail[i__] = 0; } } } if (*info == 0) { *m = *n; goto L40; } *info = 0; } /* Otherwise, call SSTEBZ and, if eigenvectors are desired, SSTEIN. */ if (wantz) { *(unsigned char *)order = 'B'; } else { *(unsigned char *)order = 'E'; } indibl = 1; indisp = indibl + *n; indiwo = indisp + *n; sstebz_(range, order, n, &vll, &vuu, il, iu, &abstll, &work[indd], &work[ inde], m, &nsplit, &w[1], &iwork[indibl], &iwork[indisp], &work[ indwrk], &iwork[indiwo], info); if (wantz) { sstein_(n, &work[indd], &work[inde], m, &w[1], &iwork[indibl], &iwork[ indisp], &z__[z_offset], ldz, &work[indwrk], &iwork[indiwo], & ifail[1], info); /* Apply orthogonal matrix used in reduction to tridiagonal */ /* form to eigenvectors returned by SSTEIN. */ indwkn = inde; llwrkn = *lwork - indwkn + 1; sormtr_("L", uplo, "N", n, m, &a[a_offset], lda, &work[indtau], &z__[ z_offset], ldz, &work[indwkn], &llwrkn, &iinfo); } /* If matrix was scaled, then rescale eigenvalues appropriately. */ L40: if (iscale == 1) { if (*info == 0) { imax = *m; } else { imax = *info - 1; } r__1 = 1.f / sigma; sscal_(&imax, &r__1, &w[1], &c__1); } /* If eigenvalues are not in order, then sort them, along with */ /* eigenvectors. */ if (wantz) { i__1 = *m - 1; for (j = 1; j <= i__1; ++j) { i__ = 0; tmp1 = w[j]; i__2 = *m; for (jj = j + 1; jj <= i__2; ++jj) { if (w[jj] < tmp1) { i__ = jj; tmp1 = w[jj]; } } if (i__ != 0) { itmp1 = iwork[indibl + i__ - 1]; w[i__] = w[j]; iwork[indibl + i__ - 1] = iwork[indibl + j - 1]; w[j] = tmp1; iwork[indibl + j - 1] = itmp1; sswap_(n, &z__[i__ * z_dim1 + 1], &c__1, &z__[j * z_dim1 + 1], &c__1); if (*info != 0) { itmp1 = ifail[i__]; ifail[i__] = ifail[j]; ifail[j] = itmp1; } } } } /* Set WORK(1) to optimal workspace size. */ work[1] = (real) lwkopt; return 0; /* End of SSYEVX */ } /* ssyevx_ */
/* Subroutine */ int sspt01_(char *uplo, integer *n, real *a, real *afac, integer *ipiv, real *c__, integer *ldc, real *rwork, real *resid) { /* System generated locals */ integer c_dim1, c_offset, i__1, i__2; /* Local variables */ integer i__, j, jc; real eps; integer info; extern logical lsame_(char *, char *); real anorm; extern doublereal slamch_(char *); extern /* Subroutine */ int slaset_(char *, integer *, integer *, real *, real *, real *, integer *); extern doublereal slansp_(char *, char *, integer *, real *, real *); extern /* Subroutine */ int slavsp_(char *, char *, char *, integer *, integer *, real *, integer *, real *, integer *, integer *); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); /* -- LAPACK test routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SSPT01 reconstructs a symmetric indefinite packed matrix A from its */ /* block L*D*L' or U*D*U' factorization and computes the residual */ /* norm( C - A ) / ( N * norm(A) * EPS ), */ /* where C is the reconstructed matrix and EPS is the machine epsilon. */ /* Arguments */ /* ========== */ /* UPLO (input) CHARACTER*1 */ /* Specifies whether the upper or lower triangular part of the */ /* symmetric matrix A is stored: */ /* = 'U': Upper triangular */ /* = 'L': Lower triangular */ /* N (input) INTEGER */ /* The number of rows and columns of the matrix A. N >= 0. */ /* A (input) REAL array, dimension (N*(N+1)/2) */ /* The original symmetric matrix A, stored as a packed */ /* triangular matrix. */ /* AFAC (input) REAL array, dimension (N*(N+1)/2) */ /* The factored form of the matrix A, stored as a packed */ /* triangular matrix. AFAC contains the block diagonal matrix D */ /* and the multipliers used to obtain the factor L or U from the */ /* block L*D*L' or U*D*U' factorization as computed by SSPTRF. */ /* IPIV (input) INTEGER array, dimension (N) */ /* The pivot indices from SSPTRF. */ /* C (workspace) REAL array, dimension (LDC,N) */ /* LDC (integer) INTEGER */ /* The leading dimension of the array C. LDC >= max(1,N). */ /* RWORK (workspace) REAL array, dimension (N) */ /* RESID (output) REAL */ /* If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS ) */ /* If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS ) */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Quick exit if N = 0. */ /* Parameter adjustments */ --a; --afac; --ipiv; c_dim1 = *ldc; c_offset = 1 + c_dim1; c__ -= c_offset; --rwork; /* Function Body */ if (*n <= 0) { *resid = 0.f; return 0; } /* Determine EPS and the norm of A. */ eps = slamch_("Epsilon"); anorm = slansp_("1", uplo, n, &a[1], &rwork[1]); /* Initialize C to the identity matrix. */ slaset_("Full", n, n, &c_b5, &c_b6, &c__[c_offset], ldc); /* Call SLAVSP to form the product D * U' (or D * L' ). */ slavsp_(uplo, "Transpose", "Non-unit", n, n, &afac[1], &ipiv[1], &c__[ c_offset], ldc, &info); /* Call SLAVSP again to multiply by U ( or L ). */ slavsp_(uplo, "No transpose", "Unit", n, n, &afac[1], &ipiv[1], &c__[ c_offset], ldc, &info); /* Compute the difference C - A . */ if (lsame_(uplo, "U")) { jc = 0; i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { c__[i__ + j * c_dim1] -= a[jc + i__]; /* L10: */ } jc += j; /* L20: */ } } else { jc = 1; i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = *n; for (i__ = j; i__ <= i__2; ++i__) { c__[i__ + j * c_dim1] -= a[jc + i__ - j]; /* L30: */ } jc = jc + *n - j + 1; /* L40: */ } } /* Compute norm( C - A ) / ( N * norm(A) * EPS ) */ *resid = slansy_("1", uplo, n, &c__[c_offset], ldc, &rwork[1]); if (anorm <= 0.f) { if (*resid != 0.f) { *resid = 1.f / eps; } } else { *resid = *resid / (real) (*n) / anorm / eps; } return 0; /* End of SSPT01 */ } /* sspt01_ */
/* Subroutine */ int sdrvsy_(logical *dotype, integer *nn, integer *nval, integer *nrhs, real *thresh, logical *tsterr, integer *nmax, real *a, real *afac, real *ainv, real *b, real *x, real *xact, real *work, real *rwork, integer *iwork, integer *nout) { /* Initialized data */ static integer iseedy[4] = { 1988,1989,1990,1991 }; static char uplos[1*2] = "U" "L"; static char facts[1*2] = "F" "N"; /* Format strings */ static char fmt_9999[] = "(1x,a,\002, UPLO='\002,a1,\002', N =\002,i5" ",\002, type \002,i2,\002, test \002,i2,\002, ratio =\002,g12.5)"; static char fmt_9998[] = "(1x,a,\002, FACT='\002,a1,\002', UPLO='\002," "a1,\002', N =\002,i5,\002, type \002,i2,\002, test \002,i2,\002," " ratio =\002,g12.5)"; /* System generated locals */ address a__1[2]; integer i__1, i__2, i__3, i__4, i__5[2]; char ch__1[2]; /* Local variables */ integer i__, j, k, n, i1, i2, k1, nb, in, kl, ku, nt, lda; char fact[1]; integer ioff, mode, imat, info; char path[3], dist[1], uplo[1], type__[1]; integer nrun, ifact, nfail, iseed[4], nbmin; real rcond; integer nimat; real anorm; integer iuplo, izero, nerrs; integer lwork; logical zerot; char xtype[1]; real rcondc; real cndnum, ainvnm; real result[6]; /* Fortran I/O blocks */ static cilist io___42 = { 0, 0, 0, fmt_9999, 0 }; static cilist io___45 = { 0, 0, 0, fmt_9998, 0 }; /* -- LAPACK test routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SDRVSY tests the driver routines SSYSV and -SVX. */ /* Arguments */ /* ========= */ /* DOTYPE (input) LOGICAL array, dimension (NTYPES) */ /* The matrix types to be used for testing. Matrices of type j */ /* (for 1 <= j <= NTYPES) are used for testing if DOTYPE(j) = */ /* .TRUE.; if DOTYPE(j) = .FALSE., then type j is not used. */ /* NN (input) INTEGER */ /* The number of values of N contained in the vector NVAL. */ /* NVAL (input) INTEGER array, dimension (NN) */ /* The values of the matrix dimension N. */ /* NRHS (input) INTEGER */ /* The number of right hand side vectors to be generated for */ /* each linear system. */ /* THRESH (input) REAL */ /* The threshold value for the test ratios. A result is */ /* included in the output file if RESULT >= THRESH. To have */ /* every test ratio printed, use THRESH = 0. */ /* TSTERR (input) LOGICAL */ /* Flag that indicates whether error exits are to be tested. */ /* NMAX (input) INTEGER */ /* The maximum value permitted for N, used in dimensioning the */ /* work arrays. */ /* A (workspace) REAL array, dimension (NMAX*NMAX) */ /* AFAC (workspace) REAL array, dimension (NMAX*NMAX) */ /* AINV (workspace) REAL array, dimension (NMAX*NMAX) */ /* B (workspace) REAL array, dimension (NMAX*NRHS) */ /* X (workspace) REAL array, dimension (NMAX*NRHS) */ /* XACT (workspace) REAL array, dimension (NMAX*NRHS) */ /* WORK (workspace) REAL array, dimension */ /* (NMAX*max(2,NRHS)) */ /* RWORK (workspace) REAL array, dimension (NMAX+2*NRHS) */ /* IWORK (workspace) INTEGER array, dimension (2*NMAX) */ /* NOUT (input) INTEGER */ /* The unit number for output. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. Local Arrays .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Scalars in Common .. */ /* .. */ /* .. Common blocks .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Data statements .. */ /* Parameter adjustments */ --iwork; --rwork; --work; --xact; --x; --b; --ainv; --afac; --a; --nval; --dotype; /* Function Body */ /* .. */ /* .. Executable Statements .. */ /* Initialize constants and the random number seed. */ s_copy(path, "Single precision", (ftnlen)1, (ftnlen)16); s_copy(path + 1, "SY", (ftnlen)2, (ftnlen)2); nrun = 0; nfail = 0; nerrs = 0; for (i__ = 1; i__ <= 4; ++i__) { iseed[i__ - 1] = iseedy[i__ - 1]; /* L10: */ } /* Computing MAX */ i__1 = *nmax << 1, i__2 = *nmax * *nrhs; lwork = max(i__1,i__2); /* Test the error exits */ if (*tsterr) { serrvx_(path, nout); } infoc_1.infot = 0; /* Set the block size and minimum block size for testing. */ nb = 1; nbmin = 2; xlaenv_(&c__1, &nb); xlaenv_(&c__2, &nbmin); /* Do for each value of N in NVAL */ i__1 = *nn; for (in = 1; in <= i__1; ++in) { n = nval[in]; lda = max(n,1); *(unsigned char *)xtype = 'N'; nimat = 10; if (n <= 0) { nimat = 1; } i__2 = nimat; for (imat = 1; imat <= i__2; ++imat) { /* Do the tests only if DOTYPE( IMAT ) is true. */ if (! dotype[imat]) { goto L170; } /* Skip types 3, 4, 5, or 6 if the matrix size is too small. */ zerot = imat >= 3 && imat <= 6; if (zerot && n < imat - 2) { goto L170; } /* Do first for UPLO = 'U', then for UPLO = 'L' */ for (iuplo = 1; iuplo <= 2; ++iuplo) { *(unsigned char *)uplo = *(unsigned char *)&uplos[iuplo - 1]; /* Set up parameters with SLATB4 and generate a test matrix */ /* with SLATMS. */ slatb4_(path, &imat, &n, &n, type__, &kl, &ku, &anorm, &mode, &cndnum, dist); s_copy(srnamc_1.srnamt, "SLATMS", (ftnlen)32, (ftnlen)6); slatms_(&n, &n, dist, iseed, type__, &rwork[1], &mode, & cndnum, &anorm, &kl, &ku, uplo, &a[1], &lda, &work[1], &info); /* Check error code from SLATMS. */ if (info != 0) { alaerh_(path, "SLATMS", &info, &c__0, uplo, &n, &n, &c_n1, &c_n1, &c_n1, &imat, &nfail, &nerrs, nout); goto L160; } /* For types 3-6, zero one or more rows and columns of the */ /* matrix to test that INFO is returned correctly. */ if (zerot) { if (imat == 3) { izero = 1; } else if (imat == 4) { izero = n; } else { izero = n / 2 + 1; } if (imat < 6) { /* Set row and column IZERO to zero. */ if (iuplo == 1) { ioff = (izero - 1) * lda; i__3 = izero - 1; for (i__ = 1; i__ <= i__3; ++i__) { a[ioff + i__] = 0.f; /* L20: */ } ioff += izero; i__3 = n; for (i__ = izero; i__ <= i__3; ++i__) { a[ioff] = 0.f; ioff += lda; /* L30: */ } } else { ioff = izero; i__3 = izero - 1; for (i__ = 1; i__ <= i__3; ++i__) { a[ioff] = 0.f; ioff += lda; /* L40: */ } ioff -= izero; i__3 = n; for (i__ = izero; i__ <= i__3; ++i__) { a[ioff + i__] = 0.f; /* L50: */ } } } else { ioff = 0; if (iuplo == 1) { /* Set the first IZERO rows and columns to zero. */ i__3 = n; for (j = 1; j <= i__3; ++j) { i2 = min(j,izero); i__4 = i2; for (i__ = 1; i__ <= i__4; ++i__) { a[ioff + i__] = 0.f; /* L60: */ } ioff += lda; /* L70: */ } } else { /* Set the last IZERO rows and columns to zero. */ i__3 = n; for (j = 1; j <= i__3; ++j) { i1 = max(j,izero); i__4 = n; for (i__ = i1; i__ <= i__4; ++i__) { a[ioff + i__] = 0.f; /* L80: */ } ioff += lda; /* L90: */ } } } } else { izero = 0; } for (ifact = 1; ifact <= 2; ++ifact) { /* Do first for FACT = 'F', then for other values. */ *(unsigned char *)fact = *(unsigned char *)&facts[ifact - 1]; /* Compute the condition number for comparison with */ /* the value returned by SSYSVX. */ if (zerot) { if (ifact == 1) { goto L150; } rcondc = 0.f; } else if (ifact == 1) { /* Compute the 1-norm of A. */ anorm = slansy_("1", uplo, &n, &a[1], &lda, &rwork[1]); /* Factor the matrix A. */ slacpy_(uplo, &n, &n, &a[1], &lda, &afac[1], &lda); ssytrf_(uplo, &n, &afac[1], &lda, &iwork[1], &work[1], &lwork, &info); /* Compute inv(A) and take its norm. */ slacpy_(uplo, &n, &n, &afac[1], &lda, &ainv[1], &lda); ssytri_(uplo, &n, &ainv[1], &lda, &iwork[1], &work[1], &info); ainvnm = slansy_("1", uplo, &n, &ainv[1], &lda, & rwork[1]); /* Compute the 1-norm condition number of A. */ if (anorm <= 0.f || ainvnm <= 0.f) { rcondc = 1.f; } else { rcondc = 1.f / anorm / ainvnm; } } /* Form an exact solution and set the right hand side. */ s_copy(srnamc_1.srnamt, "SLARHS", (ftnlen)32, (ftnlen)6); slarhs_(path, xtype, uplo, " ", &n, &n, &kl, &ku, nrhs, & a[1], &lda, &xact[1], &lda, &b[1], &lda, iseed, & info); *(unsigned char *)xtype = 'C'; /* --- Test SSYSV --- */ if (ifact == 2) { slacpy_(uplo, &n, &n, &a[1], &lda, &afac[1], &lda); slacpy_("Full", &n, nrhs, &b[1], &lda, &x[1], &lda); /* Factor the matrix and solve the system using SSYSV. */ s_copy(srnamc_1.srnamt, "SSYSV ", (ftnlen)32, (ftnlen) 6); ssysv_(uplo, &n, nrhs, &afac[1], &lda, &iwork[1], &x[ 1], &lda, &work[1], &lwork, &info); /* Adjust the expected value of INFO to account for */ /* pivoting. */ k = izero; if (k > 0) { L100: if (iwork[k] < 0) { if (iwork[k] != -k) { k = -iwork[k]; goto L100; } } else if (iwork[k] != k) { k = iwork[k]; goto L100; } } /* Check error code from SSYSV . */ if (info != k) { alaerh_(path, "SSYSV ", &info, &k, uplo, &n, &n, & c_n1, &c_n1, nrhs, &imat, &nfail, &nerrs, nout); goto L120; } else if (info != 0) { goto L120; } /* Reconstruct matrix from factors and compute */ /* residual. */ ssyt01_(uplo, &n, &a[1], &lda, &afac[1], &lda, &iwork[ 1], &ainv[1], &lda, &rwork[1], result); /* Compute residual of the computed solution. */ slacpy_("Full", &n, nrhs, &b[1], &lda, &work[1], &lda); spot02_(uplo, &n, nrhs, &a[1], &lda, &x[1], &lda, & work[1], &lda, &rwork[1], &result[1]); /* Check solution from generated exact solution. */ sget04_(&n, nrhs, &x[1], &lda, &xact[1], &lda, & rcondc, &result[2]); nt = 3; /* Print information about the tests that did not pass */ /* the threshold. */ i__3 = nt; for (k = 1; k <= i__3; ++k) { if (result[k - 1] >= *thresh) { if (nfail == 0 && nerrs == 0) { aladhd_(nout, path); } io___42.ciunit = *nout; s_wsfe(&io___42); do_fio(&c__1, "SSYSV ", (ftnlen)6); do_fio(&c__1, uplo, (ftnlen)1); do_fio(&c__1, (char *)&n, (ftnlen)sizeof( integer)); do_fio(&c__1, (char *)&imat, (ftnlen)sizeof( integer)); do_fio(&c__1, (char *)&k, (ftnlen)sizeof( integer)); do_fio(&c__1, (char *)&result[k - 1], (ftnlen) sizeof(real)); e_wsfe(); ++nfail; } /* L110: */ } nrun += nt; L120: ; } /* --- Test SSYSVX --- */ if (ifact == 2) { slaset_(uplo, &n, &n, &c_b49, &c_b49, &afac[1], &lda); } slaset_("Full", &n, nrhs, &c_b49, &c_b49, &x[1], &lda); /* Solve the system and compute the condition number and */ /* error bounds using SSYSVX. */ s_copy(srnamc_1.srnamt, "SSYSVX", (ftnlen)32, (ftnlen)6); ssysvx_(fact, uplo, &n, nrhs, &a[1], &lda, &afac[1], &lda, &iwork[1], &b[1], &lda, &x[1], &lda, &rcond, & rwork[1], &rwork[*nrhs + 1], &work[1], &lwork, & iwork[n + 1], &info); /* Adjust the expected value of INFO to account for */ /* pivoting. */ k = izero; if (k > 0) { L130: if (iwork[k] < 0) { if (iwork[k] != -k) { k = -iwork[k]; goto L130; } } else if (iwork[k] != k) { k = iwork[k]; goto L130; } } /* Check the error code from SSYSVX. */ if (info != k) { /* Writing concatenation */ i__5[0] = 1, a__1[0] = fact; i__5[1] = 1, a__1[1] = uplo; s_cat(ch__1, a__1, i__5, &c__2, (ftnlen)2); alaerh_(path, "SSYSVX", &info, &k, ch__1, &n, &n, & c_n1, &c_n1, nrhs, &imat, &nfail, &nerrs, nout); goto L150; } if (info == 0) { if (ifact >= 2) { /* Reconstruct matrix from factors and compute */ /* residual. */ ssyt01_(uplo, &n, &a[1], &lda, &afac[1], &lda, & iwork[1], &ainv[1], &lda, &rwork[(*nrhs << 1) + 1], result); k1 = 1; } else { k1 = 2; } /* Compute residual of the computed solution. */ slacpy_("Full", &n, nrhs, &b[1], &lda, &work[1], &lda); spot02_(uplo, &n, nrhs, &a[1], &lda, &x[1], &lda, & work[1], &lda, &rwork[(*nrhs << 1) + 1], & result[1]); /* Check solution from generated exact solution. */ sget04_(&n, nrhs, &x[1], &lda, &xact[1], &lda, & rcondc, &result[2]); /* Check the error bounds from iterative refinement. */ spot05_(uplo, &n, nrhs, &a[1], &lda, &b[1], &lda, &x[ 1], &lda, &xact[1], &lda, &rwork[1], &rwork[* nrhs + 1], &result[3]); } else { k1 = 6; } /* Compare RCOND from SSYSVX with the computed value */ /* in RCONDC. */ result[5] = sget06_(&rcond, &rcondc); /* Print information about the tests that did not pass */ /* the threshold. */ for (k = k1; k <= 6; ++k) { if (result[k - 1] >= *thresh) { if (nfail == 0 && nerrs == 0) { aladhd_(nout, path); } io___45.ciunit = *nout; s_wsfe(&io___45); do_fio(&c__1, "SSYSVX", (ftnlen)6); do_fio(&c__1, fact, (ftnlen)1); do_fio(&c__1, uplo, (ftnlen)1); do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer)) ; do_fio(&c__1, (char *)&imat, (ftnlen)sizeof( integer)); do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer)) ; do_fio(&c__1, (char *)&result[k - 1], (ftnlen) sizeof(real)); e_wsfe(); ++nfail; } /* L140: */ } nrun = nrun + 7 - k1; L150: ; } L160: ; } L170: ; } /* L180: */ } /* Print a summary of the results. */ alasvm_(path, nout, &nfail, &nrun, &nerrs); return 0; /* End of SDRVSY */ } /* sdrvsy_ */
/* Subroutine */ int ssysvx_(char *fact, char *uplo, integer *n, integer * nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, real *berr, real *work, integer *lwork, integer *iwork, integer * info) { /* System generated locals */ integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1, x_offset, i__1, i__2; /* Local variables */ integer nb; extern logical lsame_(char *, char *); real anorm; extern real slamch_(char *); logical nofact; extern /* Subroutine */ int xerbla_(char *, integer *); extern integer ilaenv_(integer *, char *, char *, integer *, integer *, integer *, integer *); extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, integer *, real *, integer *); extern real slansy_(char *, char *, integer *, real *, integer *, real *); extern /* Subroutine */ int ssycon_(char *, integer *, real *, integer *, integer *, real *, real *, real *, integer *, integer *); integer lwkopt; logical lquery; extern /* Subroutine */ int ssyrfs_(char *, integer *, integer *, real *, integer *, real *, integer *, integer *, real *, integer *, real * , integer *, real *, real *, real *, integer *, integer *) , ssytrf_(char *, integer *, real *, integer *, integer *, real *, integer *, integer *), ssytrs_(char *, integer *, integer *, real *, integer *, integer *, real *, integer *, integer *); /* -- LAPACK driver routine (version 3.4.1) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* April 2012 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Test the input parameters. */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; af_dim1 = *ldaf; af_offset = 1 + af_dim1; af -= af_offset; --ipiv; 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; --iwork; /* Function Body */ *info = 0; nofact = lsame_(fact, "N"); lquery = *lwork == -1; if (! nofact && ! 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 (*lda < max(1,*n)) { *info = -6; } else if (*ldaf < max(1,*n)) { *info = -8; } else if (*ldb < max(1,*n)) { *info = -11; } else if (*ldx < max(1,*n)) { *info = -13; } else /* if(complicated condition) */ { /* Computing MAX */ i__1 = 1; i__2 = *n * 3; // , expr subst if (*lwork < max(i__1,i__2) && ! lquery) { *info = -18; } } if (*info == 0) { /* Computing MAX */ i__1 = 1; i__2 = *n * 3; // , expr subst lwkopt = max(i__1,i__2); if (nofact) { nb = ilaenv_(&c__1, "SSYTRF", uplo, n, &c_n1, &c_n1, &c_n1); /* Computing MAX */ i__1 = lwkopt; i__2 = *n * nb; // , expr subst lwkopt = max(i__1,i__2); } work[1] = (real) lwkopt; } if (*info != 0) { i__1 = -(*info); xerbla_("SSYSVX", &i__1); return 0; } else if (lquery) { return 0; } if (nofact) { /* Compute the factorization A = U*D*U**T or A = L*D*L**T. */ slacpy_(uplo, n, n, &a[a_offset], lda, &af[af_offset], ldaf); ssytrf_(uplo, n, &af[af_offset], ldaf, &ipiv[1], &work[1], lwork, info); /* Return if INFO is non-zero. */ if (*info > 0) { *rcond = 0.f; return 0; } } /* Compute the norm of the matrix A. */ anorm = slansy_("I", uplo, n, &a[a_offset], lda, &work[1]); /* Compute the reciprocal of the condition number of A. */ ssycon_(uplo, n, &af[af_offset], ldaf, &ipiv[1], &anorm, rcond, &work[1], &iwork[1], info); /* Compute the solution vectors X. */ slacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx); ssytrs_(uplo, n, nrhs, &af[af_offset], ldaf, &ipiv[1], &x[x_offset], ldx, info); /* Use iterative refinement to improve the computed solutions and */ /* compute error bounds and backward error estimates for them. */ ssyrfs_(uplo, n, nrhs, &a[a_offset], lda, &af[af_offset], ldaf, &ipiv[1], &b[b_offset], ldb, &x[x_offset], ldx, &ferr[1], &berr[1], &work[1] , &iwork[1], info); /* Set INFO = N+1 if the matrix is singular to working precision. */ if (*rcond < slamch_("Epsilon")) { *info = *n + 1; } work[1] = (real) lwkopt; return 0; /* End of SSYSVX */ }
/* Subroutine */ int srqt02_(integer *m, integer *n, integer *k, real *a, real *af, real *q, real *r__, integer *lda, real *tau, real *work, integer *lwork, real *rwork, real *result) { /* System generated locals */ integer a_dim1, a_offset, af_dim1, af_offset, q_dim1, q_offset, r_dim1, r_offset, i__1, i__2; /* Builtin functions */ /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen); /* Local variables */ real eps; integer info; real resid; extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, integer *, real *, real *, integer *, real *, integer *, real *, real *, integer *); real anorm; extern /* Subroutine */ int ssyrk_(char *, char *, integer *, integer *, real *, real *, integer *, real *, real *, integer *); extern doublereal slamch_(char *), slange_(char *, integer *, integer *, real *, integer *, real *); extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, integer *, real *, integer *), slaset_(char *, integer *, integer *, real *, real *, real *, integer *); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); extern /* Subroutine */ int sorgrq_(integer *, integer *, integer *, real *, integer *, real *, real *, integer *, integer *); /* -- LAPACK test routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SRQT02 tests SORGRQ, which generates an m-by-n matrix Q with */ /* orthonornmal rows that is defined as the product of k elementary */ /* reflectors. */ /* Given the RQ factorization of an m-by-n matrix A, SRQT02 generates */ /* the orthogonal matrix Q defined by the factorization of the last k */ /* rows of A; it compares R(m-k+1:m,n-m+1:n) with */ /* A(m-k+1:m,1:n)*Q(n-m+1:n,1:n)', and checks that the rows of Q are */ /* orthonormal. */ /* Arguments */ /* ========= */ /* M (input) INTEGER */ /* The number of rows of the matrix Q to be generated. M >= 0. */ /* N (input) INTEGER */ /* The number of columns of the matrix Q to be generated. */ /* N >= M >= 0. */ /* K (input) INTEGER */ /* The number of elementary reflectors whose product defines the */ /* matrix Q. M >= K >= 0. */ /* A (input) REAL array, dimension (LDA,N) */ /* The m-by-n matrix A which was factorized by SRQT01. */ /* AF (input) REAL array, dimension (LDA,N) */ /* Details of the RQ factorization of A, as returned by SGERQF. */ /* See SGERQF for further details. */ /* Q (workspace) REAL array, dimension (LDA,N) */ /* R (workspace) REAL array, dimension (LDA,M) */ /* LDA (input) INTEGER */ /* The leading dimension of the arrays A, AF, Q and L. LDA >= N. */ /* TAU (input) REAL array, dimension (M) */ /* The scalar factors of the elementary reflectors corresponding */ /* to the RQ factorization in AF. */ /* WORK (workspace) REAL array, dimension (LWORK) */ /* LWORK (input) INTEGER */ /* The dimension of the array WORK. */ /* RWORK (workspace) REAL array, dimension (M) */ /* RESULT (output) REAL array, dimension (2) */ /* The test ratios: */ /* RESULT(1) = norm( R - A*Q' ) / ( N * norm(A) * EPS ) */ /* RESULT(2) = norm( I - Q*Q' ) / ( N * EPS ) */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Scalars in Common .. */ /* .. */ /* .. Common blocks .. */ /* .. */ /* .. Executable Statements .. */ /* Quick return if possible */ /* Parameter adjustments */ r_dim1 = *lda; r_offset = 1 + r_dim1; r__ -= r_offset; q_dim1 = *lda; q_offset = 1 + q_dim1; q -= q_offset; af_dim1 = *lda; af_offset = 1 + af_dim1; af -= af_offset; a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; --tau; --work; --rwork; --result; /* Function Body */ if (*m == 0 || *n == 0 || *k == 0) { result[1] = 0.f; result[2] = 0.f; return 0; } eps = slamch_("Epsilon"); /* Copy the last k rows of the factorization to the array Q */ slaset_("Full", m, n, &c_b4, &c_b4, &q[q_offset], lda); if (*k < *n) { i__1 = *n - *k; slacpy_("Full", k, &i__1, &af[*m - *k + 1 + af_dim1], lda, &q[*m - *k + 1 + q_dim1], lda); } if (*k > 1) { i__1 = *k - 1; i__2 = *k - 1; slacpy_("Lower", &i__1, &i__2, &af[*m - *k + 2 + (*n - *k + 1) * af_dim1], lda, &q[*m - *k + 2 + (*n - *k + 1) * q_dim1], lda); } /* Generate the last n rows of the matrix Q */ s_copy(srnamc_1.srnamt, "SORGRQ", (ftnlen)6, (ftnlen)6); sorgrq_(m, n, k, &q[q_offset], lda, &tau[*m - *k + 1], &work[1], lwork, & info); /* Copy R(m-k+1:m,n-m+1:n) */ slaset_("Full", k, m, &c_b10, &c_b10, &r__[*m - *k + 1 + (*n - *m + 1) * r_dim1], lda); slacpy_("Upper", k, k, &af[*m - *k + 1 + (*n - *k + 1) * af_dim1], lda, & r__[*m - *k + 1 + (*n - *k + 1) * r_dim1], lda); /* Compute R(m-k+1:m,n-m+1:n) - A(m-k+1:m,1:n) * Q(n-m+1:n,1:n)' */ sgemm_("No transpose", "Transpose", k, m, n, &c_b15, &a[*m - *k + 1 + a_dim1], lda, &q[q_offset], lda, &c_b16, &r__[*m - *k + 1 + (*n - *m + 1) * r_dim1], lda); /* Compute norm( R - A*Q' ) / ( N * norm(A) * EPS ) . */ anorm = slange_("1", k, n, &a[*m - *k + 1 + a_dim1], lda, &rwork[1]); resid = slange_("1", k, m, &r__[*m - *k + 1 + (*n - *m + 1) * r_dim1], lda, &rwork[1]); if (anorm > 0.f) { result[1] = resid / (real) max(1,*n) / anorm / eps; } else { result[1] = 0.f; } /* Compute I - Q*Q' */ slaset_("Full", m, m, &c_b10, &c_b16, &r__[r_offset], lda); ssyrk_("Upper", "No transpose", m, n, &c_b15, &q[q_offset], lda, &c_b16, & r__[r_offset], lda); /* Compute norm( I - Q*Q' ) / ( N * EPS ) . */ resid = slansy_("1", "Upper", m, &r__[r_offset], lda, &rwork[1]); result[2] = resid / (real) max(1,*n) / eps; return 0; /* End of SRQT02 */ } /* srqt02_ */
/* Subroutine */ int sort01_(char *rowcol, integer *m, integer *n, real *u, integer *ldu, real *work, integer *lwork, real *resid) { /* System generated locals */ integer u_dim1, u_offset, i__1, i__2; real r__1, r__2; /* Local variables */ integer i__, j, k; real eps, tmp; extern doublereal sdot_(integer *, real *, integer *, real *, integer *); integer mnmin; extern /* Subroutine */ int ssyrk_(char *, char *, integer *, integer *, real *, real *, integer *, real *, real *, integer *); extern doublereal slamch_(char *); extern /* Subroutine */ int slaset_(char *, integer *, integer *, real *, real *, real *, integer *); integer ldwork; extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); char transu[1]; /* -- LAPACK test routine (version 3.1) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SORT01 checks that the matrix U is orthogonal by computing the ratio */ /* RESID = norm( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R', */ /* or */ /* RESID = norm( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'. */ /* Alternatively, if there isn't sufficient workspace to form */ /* I - U*U' or I - U'*U, the ratio is computed as */ /* RESID = abs( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R', */ /* or */ /* RESID = abs( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'. */ /* where EPS is the machine precision. ROWCOL is used only if m = n; */ /* if m > n, ROWCOL is assumed to be 'C', and if m < n, ROWCOL is */ /* assumed to be 'R'. */ /* Arguments */ /* ========= */ /* ROWCOL (input) CHARACTER */ /* Specifies whether the rows or columns of U should be checked */ /* for orthogonality. Used only if M = N. */ /* = 'R': Check for orthogonal rows of U */ /* = 'C': Check for orthogonal columns of U */ /* M (input) INTEGER */ /* The number of rows of the matrix U. */ /* N (input) INTEGER */ /* The number of columns of the matrix U. */ /* U (input) REAL array, dimension (LDU,N) */ /* The orthogonal matrix U. U is checked for orthogonal columns */ /* if m > n or if m = n and ROWCOL = 'C'. U is checked for */ /* orthogonal rows if m < n or if m = n and ROWCOL = 'R'. */ /* LDU (input) INTEGER */ /* The leading dimension of the array U. LDU >= max(1,M). */ /* WORK (workspace) REAL array, dimension (LWORK) */ /* LWORK (input) INTEGER */ /* The length of the array WORK. For best performance, LWORK */ /* should be at least N*(N+1) if ROWCOL = 'C' or M*(M+1) if */ /* ROWCOL = 'R', but the test will be done even if LWORK is 0. */ /* RESID (output) REAL */ /* RESID = norm( I - U * U' ) / ( n * EPS ), if ROWCOL = 'R', or */ /* RESID = norm( I - U' * U ) / ( m * EPS ), if ROWCOL = 'C'. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Parameter adjustments */ u_dim1 = *ldu; u_offset = 1 + u_dim1; u -= u_offset; --work; /* Function Body */ *resid = 0.f; /* Quick return if possible */ if (*m <= 0 || *n <= 0) { return 0; } eps = slamch_("Precision"); if (*m < *n || *m == *n && lsame_(rowcol, "R")) { *(unsigned char *)transu = 'N'; k = *n; } else { *(unsigned char *)transu = 'T'; k = *m; } mnmin = min(*m,*n); if ((mnmin + 1) * mnmin <= *lwork) { ldwork = mnmin; } else { ldwork = 0; } if (ldwork > 0) { /* Compute I - U*U' or I - U'*U. */ slaset_("Upper", &mnmin, &mnmin, &c_b7, &c_b8, &work[1], &ldwork); ssyrk_("Upper", transu, &mnmin, &k, &c_b10, &u[u_offset], ldu, &c_b8, &work[1], &ldwork); /* Compute norm( I - U*U' ) / ( K * EPS ) . */ *resid = slansy_("1", "Upper", &mnmin, &work[1], &ldwork, &work[ ldwork * mnmin + 1]); *resid = *resid / (real) k / eps; } else if (*(unsigned char *)transu == 'T') { /* Find the maximum element in abs( I - U'*U ) / ( m * EPS ) */ i__1 = *n; for (j = 1; j <= i__1; ++j) { i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { if (i__ != j) { tmp = 0.f; } else { tmp = 1.f; } tmp -= sdot_(m, &u[i__ * u_dim1 + 1], &c__1, &u[j * u_dim1 + 1], &c__1); /* Computing MAX */ r__1 = *resid, r__2 = dabs(tmp); *resid = dmax(r__1,r__2); /* L10: */ } /* L20: */ } *resid = *resid / (real) (*m) / eps; } else { /* Find the maximum element in abs( I - U*U' ) / ( n * EPS ) */ i__1 = *m; for (j = 1; j <= i__1; ++j) { i__2 = j; for (i__ = 1; i__ <= i__2; ++i__) { if (i__ != j) { tmp = 0.f; } else { tmp = 1.f; } tmp -= sdot_(n, &u[j + u_dim1], ldu, &u[i__ + u_dim1], ldu); /* Computing MAX */ r__1 = *resid, r__2 = dabs(tmp); *resid = dmax(r__1,r__2); /* L30: */ } /* L40: */ } *resid = *resid / (real) (*n) / eps; } return 0; /* End of SORT01 */ } /* sort01_ */
/* Subroutine */ int ssyt22_(integer *itype, char *uplo, integer *n, integer * m, integer *kband, real *a, integer *lda, real *d__, real *e, real *u, integer *ldu, real *v, integer *ldv, real *tau, real *work, real * result) { /* System generated locals */ integer a_dim1, a_offset, u_dim1, u_offset, v_dim1, v_offset, i__1; real r__1, r__2; /* Local variables */ static real unfl; static integer j; extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, integer *, real *, real *, integer *, real *, integer *, real *, real *, integer *); static real anorm; extern /* Subroutine */ int sort01_(char *, integer *, integer *, real *, integer *, real *, integer *, real *); static real wnorm; extern /* Subroutine */ int ssymm_(char *, char *, integer *, integer *, real *, real *, integer *, real *, integer *, real *, real *, integer *); static integer jj, nn; extern doublereal slamch_(char *); static integer jj1, jj2; extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); static real ulp; static integer nnp1; /* -- LAPACK test routine (version 3.0) -- Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and Rice University February 29, 1992 Purpose ======= SSYT22 generally checks a decomposition of the form A U = U S where A is symmetric, the columns of U are orthonormal, and S is diagonal (if KBAND=0) or symmetric tridiagonal (if KBAND=1). If ITYPE=1, then U is represented as a dense matrix, otherwise the U is expressed as a product of Householder transformations, whose vectors are stored in the array "V" and whose scaling constants are in "TAU"; we shall use the letter "V" to refer to the product of Householder transformations (which should be equal to U). Specifically, if ITYPE=1, then: RESULT(1) = | U' A U - S | / ( |A| m ulp ) *and* RESULT(2) = | I - U'U | / ( m ulp ) Arguments ========= ITYPE INTEGER Specifies the type of tests to be performed. 1: U expressed as a dense orthogonal matrix: RESULT(1) = | A - U S U' | / ( |A| n ulp ) *and* RESULT(2) = | I - UU' | / ( n ulp ) UPLO CHARACTER If UPLO='U', the upper triangle of A will be used and the (strictly) lower triangle will not be referenced. If UPLO='L', the lower triangle of A will be used and the (strictly) upper triangle will not be referenced. Not modified. N INTEGER The size of the matrix. If it is zero, SSYT22 does nothing. It must be at least zero. Not modified. M INTEGER The number of columns of U. If it is zero, SSYT22 does nothing. It must be at least zero. Not modified. KBAND INTEGER The bandwidth of the matrix. It may only be zero or one. If zero, then S is diagonal, and E is not referenced. If one, then S is symmetric tri-diagonal. Not modified. A REAL array, dimension (LDA , N) The original (unfactored) matrix. It is assumed to be symmetric, and only the upper (UPLO='U') or only the lower (UPLO='L') will be referenced. Not modified. LDA INTEGER The leading dimension of A. It must be at least 1 and at least N. Not modified. D REAL array, dimension (N) The diagonal of the (symmetric tri-) diagonal matrix. Not modified. E REAL array, dimension (N) The off-diagonal of the (symmetric tri-) diagonal matrix. E(1) is ignored, E(2) is the (1,2) and (2,1) element, etc. Not referenced if KBAND=0. Not modified. U REAL array, dimension (LDU, N) If ITYPE=1 or 3, this contains the orthogonal matrix in the decomposition, expressed as a dense matrix. If ITYPE=2, then it is not referenced. Not modified. LDU INTEGER The leading dimension of U. LDU must be at least N and at least 1. Not modified. V REAL array, dimension (LDV, N) If ITYPE=2 or 3, the lower triangle of this array contains the Householder vectors used to describe the orthogonal matrix in the decomposition. If ITYPE=1, then it is not referenced. Not modified. LDV INTEGER The leading dimension of V. LDV must be at least N and at least 1. Not modified. TAU REAL array, dimension (N) If ITYPE >= 2, then TAU(j) is the scalar factor of v(j) v(j)' in the Householder transformation H(j) of the product U = H(1)...H(n-2) If ITYPE < 2, then TAU is not referenced. Not modified. WORK REAL array, dimension (2*N**2) Workspace. Modified. RESULT REAL array, dimension (2) The values computed by the two tests described above. The values are currently limited to 1/ulp, to avoid overflow. RESULT(1) is always modified. RESULT(2) is modified only if LDU is at least N. Modified. ===================================================================== Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; --d__; --e; u_dim1 = *ldu; u_offset = 1 + u_dim1 * 1; u -= u_offset; v_dim1 = *ldv; v_offset = 1 + v_dim1 * 1; v -= v_offset; --tau; --work; --result; /* Function Body */ result[1] = 0.f; result[2] = 0.f; if (*n <= 0 || *m <= 0) { return 0; } unfl = slamch_("Safe minimum"); ulp = slamch_("Precision"); /* Do Test 1 Norm of A: Computing MAX */ r__1 = slansy_("1", uplo, n, &a[a_offset], lda, &work[1]); anorm = dmax(r__1,unfl); /* Compute error matrix: ITYPE=1: error = U' A U - S */ ssymm_("L", uplo, n, m, &c_b6, &a[a_offset], lda, &u[u_offset], ldu, & c_b7, &work[1], n); nn = *n * *n; nnp1 = nn + 1; sgemm_("T", "N", m, m, n, &c_b6, &u[u_offset], ldu, &work[1], n, &c_b7, & work[nnp1], n); i__1 = *m; for (j = 1; j <= i__1; ++j) { jj = nn + (j - 1) * *n + j; work[jj] -= d__[j]; /* L10: */ } if (*kband == 1 && *n > 1) { i__1 = *m; for (j = 2; j <= i__1; ++j) { jj1 = nn + (j - 1) * *n + j - 1; jj2 = nn + (j - 2) * *n + j; work[jj1] -= e[j - 1]; work[jj2] -= e[j - 1]; /* L20: */ } } wnorm = slansy_("1", uplo, m, &work[nnp1], n, &work[1]); if (anorm > wnorm) { result[1] = wnorm / anorm / (*m * ulp); } else { if (anorm < 1.f) { /* Computing MIN */ r__1 = wnorm, r__2 = *m * anorm; result[1] = dmin(r__1,r__2) / anorm / (*m * ulp); } else { /* Computing MIN */ r__1 = wnorm / anorm, r__2 = (real) (*m); result[1] = dmin(r__1,r__2) / (*m * ulp); } } /* Do Test 2 Compute U'U - I */ if (*itype == 1) { i__1 = (*n << 1) * *n; sort01_("Columns", n, m, &u[u_offset], ldu, &work[1], &i__1, &result[ 2]); } return 0; /* End of SSYT22 */ } /* ssyt22_ */
/* Subroutine */ int ssysvx_(char *fact, char *uplo, integer *n, integer * nrhs, real *a, integer *lda, real *af, integer *ldaf, integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, real *rcond, real *ferr, real *berr, real *work, integer *lwork, integer *iwork, integer * info) { /* System generated locals */ integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, x_dim1, x_offset, i__1, i__2; /* Local variables */ integer nb; real anorm; logical nofact; integer lwkopt; logical lquery; /* -- LAPACK driver routine (version 3.2) -- */ /* November 2006 */ /* Purpose */ /* ======= */ /* SSYSVX uses the diagonal pivoting factorization to compute the */ /* solution to a real system of linear equations A * X = B, */ /* where A is an N-by-N symmetric matrix 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 = 'N', the diagonal pivoting method is used to factor A. */ /* The form of the factorization is */ /* A = U * D * U**T, if UPLO = 'U', or */ /* A = L * D * L**T, if UPLO = 'L', */ /* where U (or L) is a product of permutation and unit upper (lower) */ /* triangular matrices, and D is symmetric and block diagonal with */ /* 1-by-1 and 2-by-2 diagonal blocks. */ /* 2. If some D(i,i)=0, so that D is exactly singular, 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. */ /* 3. The system of equations is solved for X using the factored form */ /* of A. */ /* 4. Iterative refinement is applied to improve the computed solution */ /* matrix and calculate error bounds and backward error estimates */ /* for it. */ /* Arguments */ /* ========= */ /* FACT (input) CHARACTER*1 */ /* Specifies whether or not the factored form of A has been */ /* supplied on entry. */ /* = 'F': On entry, AF and IPIV contain the factored form of */ /* A. AF and IPIV will not be modified. */ /* = 'N': The matrix A will be copied to AF 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. */ /* A (input) REAL array, dimension (LDA,N) */ /* The symmetric matrix A. If UPLO = 'U', the leading N-by-N */ /* upper triangular part of A contains the upper triangular part */ /* of the matrix A, and the strictly lower triangular part of A */ /* is not referenced. If UPLO = 'L', the leading N-by-N lower */ /* triangular part of A contains the lower triangular part of */ /* the matrix A, and the strictly upper triangular part of A is */ /* not referenced. */ /* LDA (input) INTEGER */ /* The leading dimension of the array A. LDA >= max(1,N). */ /* AF (input or output) REAL array, dimension (LDAF,N) */ /* If FACT = 'F', then AF is an input argument and on entry */ /* contains the block diagonal matrix D and the multipliers used */ /* to obtain the factor U or L from the factorization */ /* A = U*D*U**T or A = L*D*L**T as computed by SSYTRF. */ /* If FACT = 'N', then AF is an output argument and on exit */ /* returns the block diagonal matrix D and the multipliers used */ /* to obtain the factor U or L from the factorization */ /* A = U*D*U**T or A = L*D*L**T. */ /* LDAF (input) INTEGER */ /* The leading dimension of the array AF. LDAF >= max(1,N). */ /* IPIV (input or output) INTEGER array, dimension (N) */ /* If FACT = 'F', then IPIV is an input argument and on entry */ /* contains details of the interchanges and the block structure */ /* of D, as determined by SSYTRF. */ /* If IPIV(k) > 0, then rows and columns k and IPIV(k) were */ /* interchanged and D(k,k) is a 1-by-1 diagonal block. */ /* If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and */ /* columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) */ /* is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) = */ /* IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were */ /* interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */ /* If FACT = 'N', then IPIV is an output argument and on exit */ /* contains details of the interchanges and the block structure */ /* of D, as determined by SSYTRF. */ /* B (input) REAL array, dimension (LDB,NRHS) */ /* The N-by-NRHS right hand side matrix B. */ /* LDB (input) INTEGER */ /* The leading dimension of the array B. LDB >= max(1,N). */ /* X (output) REAL array, dimension (LDX,NRHS) */ /* If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix 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. 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/output) REAL array, dimension (MAX(1,LWORK)) */ /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ /* LWORK (input) INTEGER */ /* The length of WORK. LWORK >= max(1,3*N), and for best */ /* performance, when FACT = 'N', LWORK >= max(1,3*N,N*NB), where */ /* NB is the optimal blocksize for SSYTRF. */ /* If LWORK = -1, then a workspace query is assumed; the routine */ /* only calculates the optimal size of the WORK array, returns */ /* this value as the first entry of the WORK array, and no error */ /* message related to LWORK is issued by XERBLA. */ /* IWORK (workspace) INTEGER 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: D(i,i) is exactly zero. The factorization */ /* has been completed but the factor D is exactly */ /* singular, so the solution and error bounds could */ /* not be computed. RCOND = 0 is returned. */ /* = N+1: D 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. */ /* ===================================================================== */ /* Test the input parameters. */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; af_dim1 = *ldaf; af_offset = 1 + af_dim1; af -= af_offset; --ipiv; 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; --iwork; /* Function Body */ *info = 0; nofact = lsame_(fact, "N"); lquery = *lwork == -1; if (! nofact && ! 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 (*lda < max(1,*n)) { *info = -6; } else if (*ldaf < max(1,*n)) { *info = -8; } else if (*ldb < max(1,*n)) { *info = -11; } else if (*ldx < max(1,*n)) { *info = -13; } else /* if(complicated condition) */ { /* Computing MAX */ i__1 = 1, i__2 = *n * 3; if (*lwork < max(i__1,i__2) && ! lquery) { *info = -18; } } if (*info == 0) { /* Computing MAX */ i__1 = 1, i__2 = *n * 3; lwkopt = max(i__1,i__2); if (nofact) { nb = ilaenv_(&c__1, "SSYTRF", uplo, n, &c_n1, &c_n1, &c_n1); /* Computing MAX */ i__1 = lwkopt, i__2 = *n * nb; lwkopt = max(i__1,i__2); } work[1] = (real) lwkopt; } if (*info != 0) { i__1 = -(*info); xerbla_("SSYSVX", &i__1); return 0; } else if (lquery) { return 0; } if (nofact) { /* Compute the factorization A = U*D*U' or A = L*D*L'. */ slacpy_(uplo, n, n, &a[a_offset], lda, &af[af_offset], ldaf); ssytrf_(uplo, n, &af[af_offset], ldaf, &ipiv[1], &work[1], lwork, info); /* Return if INFO is non-zero. */ if (*info > 0) { *rcond = 0.f; return 0; } } /* Compute the norm of the matrix A. */ anorm = slansy_("I", uplo, n, &a[a_offset], lda, &work[1]); /* Compute the reciprocal of the condition number of A. */ ssycon_(uplo, n, &af[af_offset], ldaf, &ipiv[1], &anorm, rcond, &work[1], &iwork[1], info); /* Compute the solution vectors X. */ slacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx); ssytrs_(uplo, n, nrhs, &af[af_offset], ldaf, &ipiv[1], &x[x_offset], ldx, info); /* Use iterative refinement to improve the computed solutions and */ /* compute error bounds and backward error estimates for them. */ ssyrfs_(uplo, n, nrhs, &a[a_offset], lda, &af[af_offset], ldaf, &ipiv[1], &b[b_offset], ldb, &x[x_offset], ldx, &ferr[1], &berr[1], &work[1] , &iwork[1], info); /* Set INFO = N+1 if the matrix is singular to working precision. */ if (*rcond < slamch_("Epsilon")) { *info = *n + 1; } work[1] = (real) lwkopt; return 0; /* End of SSYSVX */ } /* ssysvx_ */
/* Subroutine */ int ssgt01_(integer *itype, char *uplo, integer *n, integer * m, real *a, integer *lda, real *b, integer *ldb, real *z__, integer * ldz, real *d__, real *work, real *result) { /* System generated locals */ integer a_dim1, a_offset, b_dim1, b_offset, z_dim1, z_offset, i__1; /* Local variables */ static integer i__; extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *); static real anorm; extern /* Subroutine */ int ssymm_(char *, char *, integer *, integer *, real *, real *, integer *, real *, integer *, real *, real *, integer *); extern doublereal slamch_(char *), slange_(char *, integer *, integer *, real *, integer *, real *), slansy_(char *, char *, integer *, real *, integer *, real *); static real ulp; #define z___ref(a_1,a_2) z__[(a_2)*z_dim1 + a_1] /* -- LAPACK test routine (version 3.0) -- Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and Rice University June 30, 1999 modified August 1997, a new parameter M is added to the calling sequence. Purpose ======= SSGT01 checks a decomposition of the form A Z = B Z D or A B Z = Z D or B A Z = Z D where A is a symmetric matrix, B is symmetric positive definite, Z is orthogonal, and D is diagonal. One of the following test ratios is computed: ITYPE = 1: RESULT(1) = | A Z - B Z D | / ( |A| |Z| n ulp ) ITYPE = 2: RESULT(1) = | A B Z - Z D | / ( |A| |Z| n ulp ) ITYPE = 3: RESULT(1) = | B A Z - Z D | / ( |A| |Z| n ulp ) Arguments ========= ITYPE (input) INTEGER The form of the symmetric generalized eigenproblem. = 1: A*z = (lambda)*B*z = 2: A*B*z = (lambda)*z = 3: B*A*z = (lambda)*z UPLO (input) CHARACTER*1 Specifies whether the upper or lower triangular part of the symmetric matrices A and B is stored. = 'U': Upper triangular = 'L': Lower triangular N (input) INTEGER The order of the matrix A. N >= 0. M (input) INTEGER The number of eigenvalues found. 0 <= M <= N. A (input) REAL array, dimension (LDA, N) The original symmetric matrix A. LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,N). B (input) REAL array, dimension (LDB, N) The original symmetric positive definite matrix B. LDB (input) INTEGER The leading dimension of the array B. LDB >= max(1,N). Z (input) REAL array, dimension (LDZ, M) The computed eigenvectors of the generalized eigenproblem. LDZ (input) INTEGER The leading dimension of the array Z. LDZ >= max(1,N). D (input) REAL array, dimension (M) The computed eigenvalues of the generalized eigenproblem. WORK (workspace) REAL array, dimension (N*N) RESULT (output) REAL array, dimension (1) The test ratio as described above. ===================================================================== Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; b_dim1 = *ldb; b_offset = 1 + b_dim1 * 1; b -= b_offset; z_dim1 = *ldz; z_offset = 1 + z_dim1 * 1; z__ -= z_offset; --d__; --work; --result; /* Function Body */ result[1] = 0.f; if (*n <= 0) { return 0; } ulp = slamch_("Epsilon"); /* Compute product of 1-norms of A and Z. */ anorm = slansy_("1", uplo, n, &a[a_offset], lda, &work[1]) * slange_("1", n, m, &z__[z_offset], ldz, &work[1]); if (anorm == 0.f) { anorm = 1.f; } if (*itype == 1) { /* Norm of AZ - BZD */ ssymm_("Left", uplo, n, m, &c_b6, &a[a_offset], lda, &z__[z_offset], ldz, &c_b7, &work[1], n); i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { sscal_(n, &d__[i__], &z___ref(1, i__), &c__1); /* L10: */ } ssymm_("Left", uplo, n, m, &c_b6, &b[b_offset], ldb, &z__[z_offset], ldz, &c_b12, &work[1], n); result[1] = slange_("1", n, m, &work[1], n, &work[1]) / anorm / (*n * ulp); } else if (*itype == 2) { /* Norm of ABZ - ZD */ ssymm_("Left", uplo, n, m, &c_b6, &b[b_offset], ldb, &z__[z_offset], ldz, &c_b7, &work[1], n); i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { sscal_(n, &d__[i__], &z___ref(1, i__), &c__1); /* L20: */ } ssymm_("Left", uplo, n, m, &c_b6, &a[a_offset], lda, &work[1], n, & c_b12, &z__[z_offset], ldz); result[1] = slange_("1", n, m, &z__[z_offset], ldz, &work[1]) / anorm / (*n * ulp); } else if (*itype == 3) { /* Norm of BAZ - ZD */ ssymm_("Left", uplo, n, m, &c_b6, &a[a_offset], lda, &z__[z_offset], ldz, &c_b7, &work[1], n); i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { sscal_(n, &d__[i__], &z___ref(1, i__), &c__1); /* L30: */ } ssymm_("Left", uplo, n, m, &c_b6, &b[b_offset], ldb, &work[1], n, & c_b12, &z__[z_offset], ldz); result[1] = slange_("1", n, m, &z__[z_offset], ldz, &work[1]) / anorm / (*n * ulp); } return 0; /* End of SSGT01 */ } /* ssgt01_ */
/* Subroutine */ int ssyev_(char *jobz, char *uplo, integer *n, real *a, integer *lda, real *w, real *work, integer *lwork, integer *info) { /* System generated locals */ integer a_dim1, a_offset, i__1, i__2; real r__1; /* Builtin functions */ double sqrt(doublereal); /* Local variables */ integer nb; real eps; integer inde; real anrm; integer imax; real rmin, rmax, sigma; extern logical lsame_(char *, char *); integer iinfo; extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *); logical lower, wantz; integer iscale; extern doublereal slamch_(char *); real safmin; extern integer ilaenv_(integer *, char *, char *, integer *, integer *, integer *, integer *); extern /* Subroutine */ int xerbla_(char *, integer *); real bignum; extern /* Subroutine */ int slascl_(char *, integer *, integer *, real *, real *, integer *, integer *, real *, integer *, integer *); integer indtau, indwrk; extern /* Subroutine */ int ssterf_(integer *, real *, real *, integer *); extern doublereal slansy_(char *, char *, integer *, real *, integer *, real *); integer llwork; real smlnum; integer lwkopt; logical lquery; extern /* Subroutine */ int sorgtr_(char *, integer *, real *, integer *, real *, real *, integer *, integer *), ssteqr_(char *, integer *, real *, real *, real *, integer *, real *, integer *), ssytrd_(char *, integer *, real *, integer *, real *, real *, real *, real *, integer *, integer *); /* -- LAPACK driver routine (version 3.2) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* SSYEV computes all eigenvalues and, optionally, eigenvectors of a */ /* real symmetric matrix A. */ /* Arguments */ /* ========= */ /* JOBZ (input) CHARACTER*1 */ /* = 'N': Compute eigenvalues only; */ /* = 'V': Compute eigenvalues and eigenvectors. */ /* 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. */ /* A (input/output) REAL array, dimension (LDA, N) */ /* On entry, the symmetric matrix A. If UPLO = 'U', the */ /* leading N-by-N upper triangular part of A contains the */ /* upper triangular part of the matrix A. If UPLO = 'L', */ /* the leading N-by-N lower triangular part of A contains */ /* the lower triangular part of the matrix A. */ /* On exit, if JOBZ = 'V', then if INFO = 0, A contains the */ /* orthonormal eigenvectors of the matrix A. */ /* If JOBZ = 'N', then on exit the lower triangle (if UPLO='L') */ /* or the upper triangle (if UPLO='U') of A, including the */ /* diagonal, is destroyed. */ /* LDA (input) INTEGER */ /* The leading dimension of the array A. LDA >= max(1,N). */ /* W (output) REAL array, dimension (N) */ /* If INFO = 0, the eigenvalues in ascending order. */ /* WORK (workspace/output) REAL array, dimension (MAX(1,LWORK)) */ /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ /* LWORK (input) INTEGER */ /* The length of the array WORK. LWORK >= max(1,3*N-1). */ /* For optimal efficiency, LWORK >= (NB+2)*N, */ /* where NB is the blocksize for SSYTRD returned by ILAENV. */ /* If LWORK = -1, then a workspace query is assumed; the routine */ /* only calculates the optimal size of the WORK array, returns */ /* this value as the first entry of the WORK array, and no error */ /* message related to LWORK is issued by XERBLA. */ /* INFO (output) INTEGER */ /* = 0: successful exit */ /* < 0: if INFO = -i, the i-th argument had an illegal value */ /* > 0: if INFO = i, the algorithm failed to converge; i */ /* off-diagonal elements of an intermediate tridiagonal */ /* form did not converge to zero. */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Intrinsic Functions .. */ /* .. */ /* .. Executable Statements .. */ /* Test the input parameters. */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1; a -= a_offset; --w; --work; /* Function Body */ wantz = lsame_(jobz, "V"); lower = lsame_(uplo, "L"); lquery = *lwork == -1; *info = 0; if (! (wantz || lsame_(jobz, "N"))) { *info = -1; } else if (! (lower || lsame_(uplo, "U"))) { *info = -2; } else if (*n < 0) { *info = -3; } else if (*lda < max(1,*n)) { *info = -5; } if (*info == 0) { nb = ilaenv_(&c__1, "SSYTRD", uplo, n, &c_n1, &c_n1, &c_n1); /* Computing MAX */ i__1 = 1, i__2 = (nb + 2) * *n; lwkopt = max(i__1,i__2); work[1] = (real) lwkopt; /* Computing MAX */ i__1 = 1, i__2 = *n * 3 - 1; if (*lwork < max(i__1,i__2) && ! lquery) { *info = -8; } } if (*info != 0) { i__1 = -(*info); xerbla_("SSYEV ", &i__1); return 0; } else if (lquery) { return 0; } /* Quick return if possible */ if (*n == 0) { return 0; } if (*n == 1) { w[1] = a[a_dim1 + 1]; work[1] = 2.f; if (wantz) { a[a_dim1 + 1] = 1.f; } return 0; } /* Get machine constants. */ safmin = slamch_("Safe minimum"); eps = slamch_("Precision"); smlnum = safmin / eps; bignum = 1.f / smlnum; rmin = sqrt(smlnum); rmax = sqrt(bignum); /* Scale matrix to allowable range, if necessary. */ anrm = slansy_("M", uplo, n, &a[a_offset], lda, &work[1]); iscale = 0; if (anrm > 0.f && anrm < rmin) { iscale = 1; sigma = rmin / anrm; } else if (anrm > rmax) { iscale = 1; sigma = rmax / anrm; } if (iscale == 1) { slascl_(uplo, &c__0, &c__0, &c_b17, &sigma, n, n, &a[a_offset], lda, info); } /* Call SSYTRD to reduce symmetric matrix to tridiagonal form. */ inde = 1; indtau = inde + *n; indwrk = indtau + *n; llwork = *lwork - indwrk + 1; ssytrd_(uplo, n, &a[a_offset], lda, &w[1], &work[inde], &work[indtau], & work[indwrk], &llwork, &iinfo); /* For eigenvalues only, call SSTERF. For eigenvectors, first call */ /* SORGTR to generate the orthogonal matrix, then call SSTEQR. */ if (! wantz) { ssterf_(n, &w[1], &work[inde], info); } else { sorgtr_(uplo, n, &a[a_offset], lda, &work[indtau], &work[indwrk], & llwork, &iinfo); ssteqr_(jobz, n, &w[1], &work[inde], &a[a_offset], lda, &work[indtau], info); } /* If matrix was scaled, then rescale eigenvalues appropriately. */ if (iscale == 1) { if (*info == 0) { imax = *n; } else { imax = *info - 1; } r__1 = 1.f / sigma; sscal_(&imax, &r__1, &w[1], &c__1); } /* Set WORK(1) to optimal workspace size. */ work[1] = (real) lwkopt; return 0; /* End of SSYEV */ } /* ssyev_ */