void MatrixBlock::solve(double* rhs) { int one = 1; int info; dgttrs_("T", & this->block_size, & one, this->lower_diag, this->diag, this->upper_diag, this->U_upper_diag2, this->pivot_permutations, rhs, & this->block_size, & info); double values[2] = {0, 0}; // Gather reduced system on process 0, solve it, scatter it if(world.rank() == 0) { int reduced_size = 2*(world.size()-1); values[1] = rhs[this->block_size-1]; mpi::gather(world, values, 2, this->local_reduced_rhs, 0); dgttrs_("T", & reduced_size, & one, this->reduced_lower_diag, this->reduced_diag, this->reduced_upper_diag, this->reduced_U_upper_diag2, this->reduced_pivot_permutations, this->local_reduced_rhs + 1, //There's a leading zero of padding & reduced_size, & info); mpi::scatter(world, this->local_reduced_rhs, values, 2, 0); } else if (world.rank() == world.size()-1) { values[0] = rhs[0]; mpi::gather(world, values, 2, 0); mpi::scatter(world, values, 2, 0); } else { values[0] = rhs[0]; values[1] = rhs[this->block_size-1]; mpi::gather(world, values, 2, 0); mpi::scatter(world, values, 2, 0); } for(int i=0; i<this->block_size; i++) { if(world.rank() != world.size()-1) { rhs[i] -= values[1]*this->coupling_correction_lower[i]; } if(world.rank() != 0) { rhs[i] -= values[0]*this->coupling_correction_upper[i]; } } }
static long dgttrs(char C, long N, long NRHS, double *DL, double *D, double *DU, double *DU2, int *IPIV, double *B, long LDB) { extern void dgttrs_(const char *Cp, const long *Np, const long *NRHSp, double *DL, double *D, double *DU, double *DU2, int *IPIV, double *B, const long *LDBp, long *INFOp); long info; dgttrs_(&C, &N, &NRHS, DL, D, DU, DU2, IPIV, B, &LDB, &info); return info; }
void MatrixBlock::compute_coupling_corrections() { int one = 1; int info; if(world.rank() != world.size()-1) { std::fill_n(this->coupling_correction_lower, this->block_size, 0); this->coupling_correction_lower[block_size-1] = this->coupling_from_lower; dgttrs_("T", & this->block_size, & one, this->lower_diag, this->diag, this->upper_diag, this->U_upper_diag2, this->pivot_permutations, this->coupling_correction_lower, & this->block_size, & info); } if(world.rank() != 0) { std::fill_n(this->coupling_correction_upper, this->block_size, 0); this->coupling_correction_upper[0]=this->coupling_from_upper; dgttrs_("T", & this->block_size, & one, this->lower_diag, this->diag, this->upper_diag, this->U_upper_diag2, this->pivot_permutations, this->coupling_correction_upper, & this->block_size, & info); } }
void MatrixBlock::solveSeveral(double** rhs) { int info; dgttrs_("T", & this->block_size, & this->block_size, this->lower_diag, this->diag, this->upper_diag, this->U_upper_diag2, this->pivot_permutations, rhs[0], & this->block_size, & info); if(world.rank() == 0) { std::fill_n(this->local_reduced_rhs, 2*world.size()*this->block_size, 0); int reduced_size = 2*(world.size() - 1); for(unsigned int i=0; i < this->block_size; i++) { this->reduced_rhs[0][2*i + 1] = rhs[i][this->block_size-1]; } mpi::gather(world, reduced_rhs[0], 2*this->block_size, this->local_reduced_rhs, 0); std::fill_n(this->reduced_rhs[0], (2*world.size()-1)*this->block_size, 0); this->rank_ord_to_line_ord(local_reduced_rhs, reduced_rhs); dgttrs_("T", & reduced_size, & this->block_size, this->reduced_lower_diag, this->reduced_diag, this->reduced_upper_diag, this->reduced_U_upper_diag2, this->reduced_pivot_permutations, this->reduced_rhs[0], & reduced_size, & info); this->line_ord_to_rank_ord(reduced_rhs, local_reduced_rhs); mpi::scatter(world, local_reduced_rhs, reduced_rhs[0], 2*this->block_size, 0); } else { std::fill_n(this->local_reduced_rhs, 2*this->block_size, 0); for(unsigned int il=0; il < this->block_size; il++) { local_reduced_rhs[2*il] = rhs[il][0]; if(world.rank() != world.size()-1) local_reduced_rhs[2*il+1] = rhs[il][this->block_size-1]; } mpi::gather(world, local_reduced_rhs, 2*this->block_size, 0); mpi::scatter(world, local_reduced_rhs, 2*this->block_size, 0); } this->apply_correction_to_several(rhs); }
/// Solve system of linear equations A X = B using CLAPACK routines, where A is a triagonal matrix. void quantfin::interfaceCLAPACK::SolveTridiagonalSparse(const Array<double,2>& A,Array<double,2>& X,const Array<double,2>& B) { int i,j; long int n = A.rows(); if (3!=A.columns()) throw(std::logic_error("Tridiagonal matrix must be represented as N x 3 matrix")); long int nrhs = B.columns(); // subdiagonal double* dl = new double[n-1]; double* pos = dl; for (i=0;i<n-1;i++) *pos++ = A(i+1,0); // diagonal double* d = new double[n]; pos = d; for (i=0;i<n;i++) *pos++ = A(i,1); // superdiagonal double* du = new double[n-1]; pos = du; for (i=0;i<n-1;i++) *pos++ = A(i,2); double* bp = new double[nrhs*n]; // right hand side pos = bp; for (i=0;i<nrhs;i++) { for (j=0;j<n;j++) *pos++ = B(j,i); } long int* ipiv = new long int[n]; long int info = 0; // LU factorization double* du2 = new double[n-1]; dgttrf_(&n,dl,d,du,du2,ipiv,&info); // Solve tridiagonal system static char trans = 'N'; dgttrs_(&trans,&n,&nrhs,dl,d,du,du2,ipiv,bp,&n,&info); // prepare return value if (!info) { pos = bp; for (i=0;i<nrhs;i++) { for (j=0;j<n;j++) X(j,i) = *pos++; }} // clean up delete[] dl; delete[] d; delete[] du; delete[] du2; delete[] ipiv; if (info) throw(std::logic_error("Linear equation solve failed")); }
/* Subroutine */ int dchkgt_(logical *dotype, integer *nn, integer *nval, integer *nns, integer *nsval, doublereal *thresh, logical *tsterr, doublereal *a, doublereal *af, doublereal *b, doublereal *x, doublereal *xact, doublereal *work, doublereal *rwork, integer *iwork, integer *nout) { /* Initialized data */ static integer iseedy[4] = { 0,0,0,1 }; static char transs[1*3] = "N" "T" "C"; /* Format strings */ static char fmt_9999[] = "(12x,\002N =\002,i5,\002,\002,10x,\002 type" " \002,i2,\002, test(\002,i2,\002) = \002,g12.5)"; static char fmt_9997[] = "(\002 NORM ='\002,a1,\002', N =\002,i5,\002" ",\002,10x,\002 type \002,i2,\002, test(\002,i2,\002) = \002,g12." "5)"; static char fmt_9998[] = "(\002 TRANS='\002,a1,\002', N =\002,i5,\002, N" "RHS=\002,i3,\002, type \002,i2,\002, test(\002,i2,\002) = \002,g" "12.5)"; /* System generated locals */ integer i__1, i__2, i__3, i__4; doublereal d__1, d__2; /* Local variables */ integer i__, j, k, m, n; doublereal z__[3]; integer in, kl, ku, ix, lda; doublereal cond; integer mode, koff, imat, info; char path[3], dist[1]; integer irhs, nrhs; char norm[1], type__[1]; integer nrun; integer nfail, iseed[4]; doublereal rcond; integer nimat; doublereal anorm; integer itran; char trans[1]; integer izero, nerrs; logical zerot; doublereal rcondc; doublereal rcondi; doublereal rcondo; doublereal ainvnm; logical trfcon; doublereal result[7]; /* Fortran I/O blocks */ static cilist io___29 = { 0, 0, 0, fmt_9999, 0 }; static cilist io___39 = { 0, 0, 0, fmt_9997, 0 }; static cilist io___44 = { 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 */ /* ======= */ /* DCHKGT tests DGTTRF, -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. */ /* 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) DOUBLE PRECISION */ /* 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. */ /* A (workspace) DOUBLE PRECISION array, dimension (NMAX*4) */ /* AF (workspace) DOUBLE PRECISION array, dimension (NMAX*4) */ /* B (workspace) DOUBLE PRECISION array, dimension (NMAX*NSMAX) */ /* where NSMAX is the largest entry in NSVAL. */ /* X (workspace) DOUBLE PRECISION array, dimension (NMAX*NSMAX) */ /* XACT (workspace) DOUBLE PRECISION array, dimension (NMAX*NSMAX) */ /* WORK (workspace) DOUBLE PRECISION array, dimension */ /* (NMAX*max(3,NSMAX)) */ /* RWORK (workspace) DOUBLE PRECISION 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; --af; --a; --nsval; --nval; --dotype; /* Function Body */ /* .. */ /* .. Executable Statements .. */ s_copy(path, "Double precision", (ftnlen)1, (ftnlen)16); s_copy(path + 1, "GT", (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) { derrge_(path, nout); } infoc_1.infot = 0; i__1 = *nn; for (in = 1; in <= i__1; ++in) { /* Do for each value of N in NVAL. */ n = nval[in]; /* Computing MAX */ i__2 = n - 1; m = max(i__2,0); lda = max(1,n); nimat = 12; 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 L100; } /* Set up parameters with DLATB4. */ dlatb4_(path, &imat, &n, &n, type__, &kl, &ku, &anorm, &mode, & cond, dist); zerot = imat >= 8 && imat <= 10; if (imat <= 6) { /* Types 1-6: generate matrices of known condition number. */ /* Computing MAX */ i__3 = 2 - ku, i__4 = 3 - max(1,n); koff = max(i__3,i__4); s_copy(srnamc_1.srnamt, "DLATMS", (ftnlen)32, (ftnlen)6); dlatms_(&n, &n, dist, iseed, type__, &rwork[1], &mode, &cond, &anorm, &kl, &ku, "Z", &af[koff], &c__3, &work[1], & info); /* Check the error code from DLATMS. */ if (info != 0) { alaerh_(path, "DLATMS", &info, &c__0, " ", &n, &n, &kl, & ku, &c_n1, &imat, &nfail, &nerrs, nout); goto L100; } izero = 0; if (n > 1) { i__3 = n - 1; dcopy_(&i__3, &af[4], &c__3, &a[1], &c__1); i__3 = n - 1; dcopy_(&i__3, &af[3], &c__3, &a[n + m + 1], &c__1); } dcopy_(&n, &af[2], &c__3, &a[m + 1], &c__1); } else { /* Types 7-12: generate tridiagonal matrices with */ /* unknown condition numbers. */ if (! zerot || ! dotype[7]) { /* Generate a matrix with elements from [-1,1]. */ i__3 = n + (m << 1); dlarnv_(&c__2, iseed, &i__3, &a[1]); if (anorm != 1.) { i__3 = n + (m << 1); dscal_(&i__3, &anorm, &a[1], &c__1); } } else if (izero > 0) { /* Reuse the last matrix by copying back the zeroed out */ /* elements. */ if (izero == 1) { a[n] = z__[1]; if (n > 1) { a[1] = z__[2]; } } else if (izero == n) { a[n * 3 - 2] = z__[0]; a[(n << 1) - 1] = z__[1]; } else { a[(n << 1) - 2 + izero] = z__[0]; a[n - 1 + izero] = z__[1]; a[izero] = z__[2]; } } /* If IMAT > 7, set one column of the matrix to 0. */ if (! zerot) { izero = 0; } else if (imat == 8) { izero = 1; z__[1] = a[n]; a[n] = 0.; if (n > 1) { z__[2] = a[1]; a[1] = 0.; } } else if (imat == 9) { izero = n; z__[0] = a[n * 3 - 2]; z__[1] = a[(n << 1) - 1]; a[n * 3 - 2] = 0.; a[(n << 1) - 1] = 0.; } else { izero = (n + 1) / 2; i__3 = n - 1; for (i__ = izero; i__ <= i__3; ++i__) { a[(n << 1) - 2 + i__] = 0.; a[n - 1 + i__] = 0.; a[i__] = 0.; /* L20: */ } a[n * 3 - 2] = 0.; a[(n << 1) - 1] = 0.; } } /* + TEST 1 */ /* Factor A as L*U and compute the ratio */ /* norm(L*U - A) / (n * norm(A) * EPS ) */ i__3 = n + (m << 1); dcopy_(&i__3, &a[1], &c__1, &af[1], &c__1); s_copy(srnamc_1.srnamt, "DGTTRF", (ftnlen)32, (ftnlen)6); dgttrf_(&n, &af[1], &af[m + 1], &af[n + m + 1], &af[n + (m << 1) + 1], &iwork[1], &info); /* Check error code from DGTTRF. */ if (info != izero) { alaerh_(path, "DGTTRF", &info, &izero, " ", &n, &n, &c__1, & c__1, &c_n1, &imat, &nfail, &nerrs, nout); } trfcon = info != 0; dgtt01_(&n, &a[1], &a[m + 1], &a[n + m + 1], &af[1], &af[m + 1], & af[n + m + 1], &af[n + (m << 1) + 1], &iwork[1], &work[1], &lda, &rwork[1], result); /* Print the test ratio if it is .GE. THRESH. */ if (result[0] >= *thresh) { if (nfail == 0 && nerrs == 0) { alahd_(nout, path); } io___29.ciunit = *nout; s_wsfe(&io___29); do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer)); do_fio(&c__1, (char *)&imat, (ftnlen)sizeof(integer)); do_fio(&c__1, (char *)&c__1, (ftnlen)sizeof(integer)); do_fio(&c__1, (char *)&result[0], (ftnlen)sizeof(doublereal)); e_wsfe(); ++nfail; } ++nrun; for (itran = 1; itran <= 2; ++itran) { *(unsigned char *)trans = *(unsigned char *)&transs[itran - 1] ; if (itran == 1) { *(unsigned char *)norm = 'O'; } else { *(unsigned char *)norm = 'I'; } anorm = dlangt_(norm, &n, &a[1], &a[m + 1], &a[n + m + 1]); if (! trfcon) { /* Use DGTTRS to solve for one column at a time of inv(A) */ /* or inv(A^T), computing the maximum column sum as we */ /* go. */ ainvnm = 0.; i__3 = n; for (i__ = 1; i__ <= i__3; ++i__) { i__4 = n; for (j = 1; j <= i__4; ++j) { x[j] = 0.; /* L30: */ } x[i__] = 1.; dgttrs_(trans, &n, &c__1, &af[1], &af[m + 1], &af[n + m + 1], &af[n + (m << 1) + 1], &iwork[1], &x[ 1], &lda, &info); /* Computing MAX */ d__1 = ainvnm, d__2 = dasum_(&n, &x[1], &c__1); ainvnm = max(d__1,d__2); /* L40: */ } /* Compute RCONDC = 1 / (norm(A) * norm(inv(A)) */ if (anorm <= 0. || ainvnm <= 0.) { rcondc = 1.; } else { rcondc = 1. / anorm / ainvnm; } if (itran == 1) { rcondo = rcondc; } else { rcondi = rcondc; } } else { rcondc = 0.; } /* + TEST 7 */ /* Estimate the reciprocal of the condition number of the */ /* matrix. */ s_copy(srnamc_1.srnamt, "DGTCON", (ftnlen)32, (ftnlen)6); dgtcon_(norm, &n, &af[1], &af[m + 1], &af[n + m + 1], &af[n + (m << 1) + 1], &iwork[1], &anorm, &rcond, &work[1], & iwork[n + 1], &info); /* Check error code from DGTCON. */ if (info != 0) { alaerh_(path, "DGTCON", &info, &c__0, norm, &n, &n, &c_n1, &c_n1, &c_n1, &imat, &nfail, &nerrs, nout); } result[6] = dget06_(&rcond, &rcondc); /* Print the test ratio if it is .GE. THRESH. */ if (result[6] >= *thresh) { if (nfail == 0 && nerrs == 0) { alahd_(nout, path); } io___39.ciunit = *nout; s_wsfe(&io___39); do_fio(&c__1, norm, (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__7, (ftnlen)sizeof(integer)); do_fio(&c__1, (char *)&result[6], (ftnlen)sizeof( doublereal)); e_wsfe(); ++nfail; } ++nrun; /* L50: */ } /* Skip the remaining tests if the matrix is singular. */ if (trfcon) { goto L100; } i__3 = *nns; for (irhs = 1; irhs <= i__3; ++irhs) { nrhs = nsval[irhs]; /* Generate NRHS random solution vectors. */ ix = 1; i__4 = nrhs; for (j = 1; j <= i__4; ++j) { dlarnv_(&c__2, iseed, &n, &xact[ix]); ix += lda; /* L60: */ } for (itran = 1; itran <= 3; ++itran) { *(unsigned char *)trans = *(unsigned char *)&transs[itran - 1]; if (itran == 1) { rcondc = rcondo; } else { rcondc = rcondi; } /* Set the right hand side. */ dlagtm_(trans, &n, &nrhs, &c_b63, &a[1], &a[m + 1], &a[n + m + 1], &xact[1], &lda, &c_b64, &b[1], &lda); /* + TEST 2 */ /* Solve op(A) * X = B and compute the residual. */ dlacpy_("Full", &n, &nrhs, &b[1], &lda, &x[1], &lda); s_copy(srnamc_1.srnamt, "DGTTRS", (ftnlen)32, (ftnlen)6); dgttrs_(trans, &n, &nrhs, &af[1], &af[m + 1], &af[n + m + 1], &af[n + (m << 1) + 1], &iwork[1], &x[1], &lda, &info); /* Check error code from DGTTRS. */ if (info != 0) { alaerh_(path, "DGTTRS", &info, &c__0, trans, &n, &n, & c_n1, &c_n1, &nrhs, &imat, &nfail, &nerrs, nout); } dlacpy_("Full", &n, &nrhs, &b[1], &lda, &work[1], &lda); dgtt02_(trans, &n, &nrhs, &a[1], &a[m + 1], &a[n + m + 1], &x[1], &lda, &work[1], &lda, &rwork[1], &result[ 1]); /* + TEST 3 */ /* Check solution from generated exact solution. */ dget04_(&n, &nrhs, &x[1], &lda, &xact[1], &lda, &rcondc, & result[2]); /* + TESTS 4, 5, and 6 */ /* Use iterative refinement to improve the solution. */ s_copy(srnamc_1.srnamt, "DGTRFS", (ftnlen)32, (ftnlen)6); dgtrfs_(trans, &n, &nrhs, &a[1], &a[m + 1], &a[n + m + 1], &af[1], &af[m + 1], &af[n + m + 1], &af[n + (m << 1) + 1], &iwork[1], &b[1], &lda, &x[1], &lda, & rwork[1], &rwork[nrhs + 1], &work[1], &iwork[n + 1], &info); /* Check error code from DGTRFS. */ if (info != 0) { alaerh_(path, "DGTRFS", &info, &c__0, trans, &n, &n, & c_n1, &c_n1, &nrhs, &imat, &nfail, &nerrs, nout); } dget04_(&n, &nrhs, &x[1], &lda, &xact[1], &lda, &rcondc, & result[3]); dgtt05_(trans, &n, &nrhs, &a[1], &a[m + 1], &a[n + m + 1], &b[1], &lda, &x[1], &lda, &xact[1], &lda, &rwork[ 1], &rwork[nrhs + 1], &result[4]); /* Print information about the tests that did not pass */ /* the threshold. */ for (k = 2; k <= 6; ++k) { if (result[k - 1] >= *thresh) { if (nfail == 0 && nerrs == 0) { alahd_(nout, path); } io___44.ciunit = *nout; s_wsfe(&io___44); do_fio(&c__1, trans, (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(doublereal)); e_wsfe(); ++nfail; } /* L70: */ } nrun += 5; /* L80: */ } /* L90: */ } L100: ; } /* L110: */ } /* Print a summary of the results. */ alasum_(path, nout, &nfail, &nrun, &nerrs); return 0; /* End of DCHKGT */ } /* dchkgt_ */
/* Subroutine */ int dgtrfs_(char *trans, integer *n, integer *nrhs, doublereal *dl, doublereal *d__, doublereal *du, doublereal *dlf, doublereal *df, doublereal *duf, doublereal *du2, integer *ipiv, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal * ferr, doublereal *berr, doublereal *work, integer *iwork, integer * info) { /* -- LAPACK 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 ======= DGTRFS improves the computed solution to a system of linear equations when the coefficient matrix is tridiagonal, and provides error bounds and backward error estimates for the solution. Arguments ========= TRANS (input) CHARACTER*1 Specifies the form of the system of equations: = 'N': A * X = B (No transpose) = 'T': A**T * X = B (Transpose) = 'C': A**H * X = B (Conjugate transpose = Transpose) N (input) INTEGER The order of the matrix A. N >= 0. NRHS (input) INTEGER The number of right hand sides, i.e., the number of columns of the matrix B. NRHS >= 0. DL (input) DOUBLE PRECISION array, dimension (N-1) The (n-1) subdiagonal elements of A. D (input) DOUBLE PRECISION array, dimension (N) The diagonal elements of A. DU (input) DOUBLE PRECISION array, dimension (N-1) The (n-1) superdiagonal elements of A. DLF (input) DOUBLE PRECISION array, dimension (N-1) The (n-1) multipliers that define the matrix L from the LU factorization of A as computed by DGTTRF. DF (input) DOUBLE PRECISION array, dimension (N) The n diagonal elements of the upper triangular matrix U from the LU factorization of A. DUF (input) DOUBLE PRECISION array, dimension (N-1) The (n-1) elements of the first superdiagonal of U. DU2 (input) DOUBLE PRECISION array, dimension (N-2) The (n-2) elements of the second superdiagonal of U. IPIV (input) INTEGER array, dimension (N) The pivot indices; for 1 <= i <= n, row i of the matrix was interchanged with row IPIV(i). IPIV(i) will always be either i or i+1; IPIV(i) = i indicates a row interchange was not required. B (input) DOUBLE PRECISION array, dimension (LDB,NRHS) The right hand side matrix B. LDB (input) INTEGER The leading dimension of the array B. LDB >= max(1,N). X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS) On entry, the solution matrix X, as computed by DGTTRS. On exit, the improved solution matrix X. LDX (input) INTEGER The leading dimension of the array X. LDX >= max(1,N). FERR (output) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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 Internal Parameters =================== ITMAX is the maximum number of steps of iterative refinement. ===================================================================== Test the input parameters. Parameter adjustments */ /* Table of constant values */ static integer c__1 = 1; static doublereal c_b18 = -1.; static doublereal c_b19 = 1.; /* System generated locals */ integer b_dim1, b_offset, x_dim1, x_offset, i__1, i__2; doublereal d__1, d__2, d__3, d__4; /* Local variables */ static integer kase; static doublereal safe1, safe2; static integer i__, j; static doublereal s; extern logical lsame_(char *, char *); extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, doublereal *, integer *), daxpy_(integer *, doublereal *, doublereal *, integer *, doublereal *, integer *); static integer count; extern doublereal dlamch_(char *); extern /* Subroutine */ int dlacon_(integer *, doublereal *, doublereal *, integer *, doublereal *, integer *); static integer nz; extern /* Subroutine */ int dlagtm_(char *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, doublereal *, integer *); static doublereal safmin; extern /* Subroutine */ int xerbla_(char *, integer *); static logical notran; static char transn[1]; extern /* Subroutine */ int dgttrs_(char *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, integer *, integer *); static char transt[1]; static doublereal lstres, eps; #define b_ref(a_1,a_2) b[(a_2)*b_dim1 + a_1] #define x_ref(a_1,a_2) x[(a_2)*x_dim1 + a_1] --dl; --d__; --du; --dlf; --df; --duf; --du2; --ipiv; b_dim1 = *ldb; b_offset = 1 + b_dim1 * 1; b -= b_offset; x_dim1 = *ldx; x_offset = 1 + x_dim1 * 1; x -= x_offset; --ferr; --berr; --work; --iwork; /* Function Body */ *info = 0; notran = lsame_(trans, "N"); if (! notran && ! lsame_(trans, "T") && ! lsame_( trans, "C")) { *info = -1; } else if (*n < 0) { *info = -2; } else if (*nrhs < 0) { *info = -3; } else if (*ldb < max(1,*n)) { *info = -13; } else if (*ldx < max(1,*n)) { *info = -15; } if (*info != 0) { i__1 = -(*info); xerbla_("DGTRFS", &i__1); return 0; } /* Quick return if possible */ if (*n == 0 || *nrhs == 0) { i__1 = *nrhs; for (j = 1; j <= i__1; ++j) { ferr[j] = 0.; berr[j] = 0.; /* L10: */ } return 0; } if (notran) { *(unsigned char *)transn = 'N'; *(unsigned char *)transt = 'T'; } else { *(unsigned char *)transn = 'T'; *(unsigned char *)transt = 'N'; } /* NZ = maximum number of nonzero elements in each row of A, plus 1 */ nz = 4; eps = dlamch_("Epsilon"); safmin = dlamch_("Safe minimum"); safe1 = nz * safmin; safe2 = safe1 / eps; /* Do for each right hand side */ i__1 = *nrhs; for (j = 1; j <= i__1; ++j) { count = 1; lstres = 3.; L20: /* Loop until stopping criterion is satisfied. Compute residual R = B - op(A) * X, where op(A) = A, A**T, or A**H, depending on TRANS. */ dcopy_(n, &b_ref(1, j), &c__1, &work[*n + 1], &c__1); dlagtm_(trans, n, &c__1, &c_b18, &dl[1], &d__[1], &du[1], &x_ref(1, j) , ldx, &c_b19, &work[*n + 1], n); /* Compute abs(op(A))*abs(x) + abs(b) for use in the backward error bound. */ if (notran) { if (*n == 1) { work[1] = (d__1 = b_ref(1, j), abs(d__1)) + (d__2 = d__[1] * x_ref(1, j), abs(d__2)); } else { work[1] = (d__1 = b_ref(1, j), abs(d__1)) + (d__2 = d__[1] * x_ref(1, j), abs(d__2)) + (d__3 = du[1] * x_ref(2, j), abs(d__3)); i__2 = *n - 1; for (i__ = 2; i__ <= i__2; ++i__) { work[i__] = (d__1 = b_ref(i__, j), abs(d__1)) + (d__2 = dl[i__ - 1] * x_ref(i__ - 1, j), abs(d__2)) + ( d__3 = d__[i__] * x_ref(i__, j), abs(d__3)) + ( d__4 = du[i__] * x_ref(i__ + 1, j), abs(d__4)); /* L30: */ } work[*n] = (d__1 = b_ref(*n, j), abs(d__1)) + (d__2 = dl[*n - 1] * x_ref(*n - 1, j), abs(d__2)) + (d__3 = d__[*n] * x_ref(*n, j), abs(d__3)); } } else { if (*n == 1) { work[1] = (d__1 = b_ref(1, j), abs(d__1)) + (d__2 = d__[1] * x_ref(1, j), abs(d__2)); } else { work[1] = (d__1 = b_ref(1, j), abs(d__1)) + (d__2 = d__[1] * x_ref(1, j), abs(d__2)) + (d__3 = dl[1] * x_ref(2, j), abs(d__3)); i__2 = *n - 1; for (i__ = 2; i__ <= i__2; ++i__) { work[i__] = (d__1 = b_ref(i__, j), abs(d__1)) + (d__2 = du[i__ - 1] * x_ref(i__ - 1, j), abs(d__2)) + ( d__3 = d__[i__] * x_ref(i__, j), abs(d__3)) + ( d__4 = dl[i__] * x_ref(i__ + 1, j), abs(d__4)); /* L40: */ } work[*n] = (d__1 = b_ref(*n, j), abs(d__1)) + (d__2 = du[*n - 1] * x_ref(*n - 1, j), abs(d__2)) + (d__3 = d__[*n] * x_ref(*n, j), abs(d__3)); } } /* Compute componentwise relative backward error from formula max(i) ( abs(R(i)) / ( abs(op(A))*abs(X) + abs(B) )(i) ) where abs(Z) is the componentwise absolute value of the matrix or vector Z. If the i-th component of the denominator is less than SAFE2, then SAFE1 is added to the i-th components of the numerator and denominator before dividing. */ s = 0.; i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { if (work[i__] > safe2) { /* Computing MAX */ d__2 = s, d__3 = (d__1 = work[*n + i__], abs(d__1)) / work[ i__]; s = max(d__2,d__3); } else { /* Computing MAX */ d__2 = s, d__3 = ((d__1 = work[*n + i__], abs(d__1)) + safe1) / (work[i__] + safe1); s = max(d__2,d__3); } /* L50: */ } berr[j] = s; /* Test stopping criterion. Continue iterating if 1) The residual BERR(J) is larger than machine epsilon, and 2) BERR(J) decreased by at least a factor of 2 during the last iteration, and 3) At most ITMAX iterations tried. */ if (berr[j] > eps && berr[j] * 2. <= lstres && count <= 5) { /* Update solution and try again. */ dgttrs_(trans, n, &c__1, &dlf[1], &df[1], &duf[1], &du2[1], &ipiv[ 1], &work[*n + 1], n, info); daxpy_(n, &c_b19, &work[*n + 1], &c__1, &x_ref(1, j), &c__1); lstres = berr[j]; ++count; goto L20; } /* Bound error from formula norm(X - XTRUE) / norm(X) .le. FERR = norm( abs(inv(op(A)))* ( abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) / norm(X) where norm(Z) is the magnitude of the largest component of Z inv(op(A)) is the inverse of op(A) abs(Z) is the componentwise absolute value of the matrix or vector Z NZ is the maximum number of nonzeros in any row of A, plus 1 EPS is machine epsilon The i-th component of abs(R)+NZ*EPS*(abs(op(A))*abs(X)+abs(B)) is incremented by SAFE1 if the i-th component of abs(op(A))*abs(X) + abs(B) is less than SAFE2. Use DLACON to estimate the infinity-norm of the matrix inv(op(A)) * diag(W), where W = abs(R) + NZ*EPS*( abs(op(A))*abs(X)+abs(B) ))) */ i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { if (work[i__] > safe2) { work[i__] = (d__1 = work[*n + i__], abs(d__1)) + nz * eps * work[i__]; } else { work[i__] = (d__1 = work[*n + i__], abs(d__1)) + nz * eps * work[i__] + safe1; } /* L60: */ } kase = 0; L70: dlacon_(n, &work[(*n << 1) + 1], &work[*n + 1], &iwork[1], &ferr[j], & kase); if (kase != 0) { if (kase == 1) { /* Multiply by diag(W)*inv(op(A)**T). */ dgttrs_(transt, n, &c__1, &dlf[1], &df[1], &duf[1], &du2[1], & ipiv[1], &work[*n + 1], n, info); i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { work[*n + i__] = work[i__] * work[*n + i__]; /* L80: */ } } else { /* Multiply by inv(op(A))*diag(W). */ i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { work[*n + i__] = work[i__] * work[*n + i__]; /* L90: */ } dgttrs_(transn, n, &c__1, &dlf[1], &df[1], &duf[1], &du2[1], & ipiv[1], &work[*n + 1], n, info); } goto L70; } /* Normalize error. */ lstres = 0.; i__2 = *n; for (i__ = 1; i__ <= i__2; ++i__) { /* Computing MAX */ d__2 = lstres, d__3 = (d__1 = x_ref(i__, j), abs(d__1)); lstres = max(d__2,d__3); /* L100: */ } if (lstres != 0.) { ferr[j] /= lstres; } /* L110: */ } return 0; /* End of DGTRFS */ } /* dgtrfs_ */
/* Subroutine */ int dtimgt_(char *line, integer *nm, integer *mval, integer * nns, integer *nsval, integer *nlda, integer *ldaval, doublereal * timmin, doublereal *a, doublereal *b, integer *iwork, doublereal * reslts, integer *ldr1, integer *ldr2, integer *ldr3, integer *nout, ftnlen line_len) { /* Initialized data */ static char subnam[6*4] = "DGTTRF" "DGTTRS" "DGTSV " "DGTSL "; static char transs[1*2] = "N" "T"; /* Format strings */ static char fmt_9998[] = "(1x,a6,\002 timing run not attempted\002,/)"; static char fmt_9997[] = "(/\002 *** Speed of \002,a6,\002 in megaflops " "***\002)"; static char fmt_9996[] = "(5x,\002line \002,i2,\002 with LDA = \002,i5)"; static char fmt_9999[] = "(\002 DGTTRS with TRANS = '\002,a1,\002'\002,/)" ; /* System generated locals */ integer reslts_dim1, reslts_dim2, reslts_dim3, reslts_offset, 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), s_wsle(cilist *), e_wsle(void); /* Local variables */ static integer ilda, info; static char path[3]; static doublereal time; static integer isub, nrhs, i__, m, n; static char cname[6]; extern doublereal dopgb_(char *, integer *, integer *, integer *, integer *, integer *); static integer laval[1], itran; extern /* Subroutine */ int dgtsl_(integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *); static char trans[1]; extern /* Subroutine */ int dgtsv_(integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, integer *); static doublereal s1, s2; static integer ic, im; extern doublereal dsecnd_(void); extern /* Subroutine */ int atimck_(integer *, char *, integer *, integer *, integer *, integer *, integer *, integer *, ftnlen); extern doublereal dmflop_(doublereal *, doublereal *, integer *); extern /* Subroutine */ int atimin_(char *, char *, integer *, char *, logical *, integer *, integer *, ftnlen, ftnlen, ftnlen), dtimmg_( integer *, integer *, integer *, doublereal *, integer *, integer *, integer *), dprtbl_(char *, char *, integer *, integer *, integer *, integer *, integer *, doublereal *, integer *, integer *, integer *, ftnlen, ftnlen), dgttrf_(integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, integer *); static doublereal untime; static logical timsub[4]; extern /* Subroutine */ int dgttrs_(char *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, integer *, integer *); static integer ldb, icl; static doublereal ops; /* Fortran I/O blocks */ static cilist io___8 = { 0, 0, 0, fmt_9998, 0 }; static cilist io___25 = { 0, 0, 0, fmt_9997, 0 }; static cilist io___26 = { 0, 0, 0, fmt_9996, 0 }; static cilist io___27 = { 0, 0, 0, 0, 0 }; static cilist io___29 = { 0, 0, 0, fmt_9999, 0 }; static cilist io___30 = { 0, 0, 0, fmt_9999, 0 }; #define subnam_ref(a_0,a_1) &subnam[(a_1)*6 + a_0 - 6] #define reslts_ref(a_1,a_2,a_3,a_4) reslts[(((a_4)*reslts_dim3 + (a_3))*\ reslts_dim2 + (a_2))*reslts_dim1 + a_1] /* -- LAPACK timing 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 ======= DTIMGT times DGTTRF, -TRS, -SV, and -SL. Arguments ========= LINE (input) CHARACTER*80 The input line that requested this routine. The first six characters contain either the name of a subroutine or a generic path name. The remaining characters may be used to specify the individual routines to be timed. See ATIMIN for a full description of the format of the input line. NM (input) INTEGER The number of values of M contained in the vector MVAL. MVAL (input) INTEGER array, dimension (NM) The values of the matrix size M. 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. NLDA (input) INTEGER The number of values of LDA contained in the vector LDAVAL. LDAVAL (input) INTEGER array, dimension (NLDA) The values of the leading dimension of the array A. TIMMIN (input) DOUBLE PRECISION The minimum time a subroutine will be timed. A (workspace) DOUBLE PRECISION array, dimension (NMAX*4) where NMAX is the maximum value permitted for N. B (workspace) DOUBLE PRECISION array, dimension (LDAMAX*NMAX) IWORK (workspace) INTEGER array, dimension (NMAX) RESLTS (output) DOUBLE PRECISION array, dimension (LDR1,LDR2,LDR3,NSUBS+1) The timing results for each subroutine over the relevant values of N. LDR1 (input) INTEGER The first dimension of RESLTS. LDR1 >= 1. LDR2 (input) INTEGER The second dimension of RESLTS. LDR2 >= max(1,NM). LDR3 (input) INTEGER The third dimension of RESLTS. LDR3 >= max(1,NLDA). NOUT (input) INTEGER The unit number for output. ===================================================================== Parameter adjustments */ --mval; --nsval; --ldaval; --a; --b; --iwork; reslts_dim1 = *ldr1; reslts_dim2 = *ldr2; reslts_dim3 = *ldr3; reslts_offset = 1 + reslts_dim1 * (1 + reslts_dim2 * (1 + reslts_dim3 * 1) ); reslts -= reslts_offset; /* Function Body Extract the timing request from the input line. */ s_copy(path, "Double precision", (ftnlen)1, (ftnlen)16); s_copy(path + 1, "GT", (ftnlen)2, (ftnlen)2); atimin_(path, line, &c__4, subnam, timsub, nout, &info, (ftnlen)3, ( ftnlen)80, (ftnlen)6); if (info != 0) { goto L180; } /* Check that N <= LDA for the input values. */ for (isub = 2; isub <= 4; ++isub) { if (! timsub[isub - 1]) { goto L10; } s_copy(cname, subnam_ref(0, isub), (ftnlen)6, (ftnlen)6); atimck_(&c__2, cname, nm, &mval[1], nlda, &ldaval[1], nout, &info, ( ftnlen)6); if (info > 0) { io___8.ciunit = *nout; s_wsfe(&io___8); do_fio(&c__1, cname, (ftnlen)6); e_wsfe(); timsub[isub - 1] = FALSE_; } L10: ; } /* Do for each value of M: */ i__1 = *nm; for (im = 1; im <= i__1; ++im) { m = mval[im]; n = max(m,1); /* Time DGTTRF */ if (timsub[0]) { i__2 = n * 3; dtimmg_(&c__12, &m, &m, &a[1], &i__2, &c__0, &c__0); ic = 0; s1 = dsecnd_(); L20: dgttrf_(&m, &a[1], &a[n], &a[n * 2], &a[n * 3 - 2], &iwork[1], & info); s2 = dsecnd_(); time = s2 - s1; ++ic; if (time < *timmin) { i__2 = n * 3; dtimmg_(&c__12, &m, &m, &a[1], &i__2, &c__0, &c__0); goto L20; } /* Subtract the time used in DTIMMG. */ icl = 1; s1 = dsecnd_(); L30: s2 = dsecnd_(); untime = s2 - s1; ++icl; if (icl <= ic) { i__2 = n * 3; dtimmg_(&c__12, &m, &m, &a[1], &i__2, &c__0, &c__0); goto L30; } time = (time - untime) / (doublereal) ic; ops = dopgb_("DGTTRF", &m, &m, &c__1, &c__1, &iwork[1]) ; reslts_ref(1, im, 1, 1) = dmflop_(&ops, &time, &info); } else if (timsub[1]) { i__2 = n * 3; dtimmg_(&c__12, &m, &m, &a[1], &i__2, &c__0, &c__0); } /* Generate another matrix and factor it using DGTTRF so that the factored form can be used in timing the other routines. */ if (ic != 1) { dgttrf_(&m, &a[1], &a[n], &a[n * 2], &a[n * 3 - 2], &iwork[1], & info); } /* Time DGTTRS */ if (timsub[1]) { for (itran = 1; itran <= 2; ++itran) { *(unsigned char *)trans = *(unsigned char *)&transs[itran - 1] ; i__2 = *nlda; for (ilda = 1; ilda <= i__2; ++ilda) { ldb = ldaval[ilda]; i__3 = *nns; for (i__ = 1; i__ <= i__3; ++i__) { nrhs = nsval[i__]; dtimmg_(&c__0, &m, &nrhs, &b[1], &ldb, &c__0, &c__0); ic = 0; s1 = dsecnd_(); L40: dgttrs_(trans, &m, &nrhs, &a[1], &a[n], &a[n * 2], &a[ n * 3 - 2], &iwork[1], &b[1], &ldb, &info); s2 = dsecnd_(); time = s2 - s1; ++ic; if (time < *timmin) { dtimmg_(&c__0, &m, &nrhs, &b[1], &ldb, &c__0, & c__0); goto L40; } /* Subtract the time used in DTIMMG. */ icl = 1; s1 = dsecnd_(); L50: s2 = dsecnd_(); untime = s2 - s1; ++icl; if (icl <= ic) { dtimmg_(&c__0, &m, &nrhs, &b[1], &ldb, &c__0, & c__0); goto L50; } time = (time - untime) / (doublereal) ic; ops = dopgb_("DGTTRS", &m, &nrhs, &c__0, &c__0, & iwork[1]); if (itran == 1) { reslts_ref(i__, im, ilda, 2) = dmflop_(&ops, & time, &info); } else { reslts_ref(i__, im, ilda, 5) = dmflop_(&ops, & time, &info); } /* L60: */ } /* L70: */ } /* L80: */ } } if (timsub[2]) { i__2 = *nlda; for (ilda = 1; ilda <= i__2; ++ilda) { ldb = ldaval[ilda]; i__3 = *nns; for (i__ = 1; i__ <= i__3; ++i__) { nrhs = nsval[i__]; i__4 = n * 3; dtimmg_(&c__12, &m, &m, &a[1], &i__4, &c__0, &c__0); dtimmg_(&c__0, &m, &nrhs, &b[1], &ldb, &c__0, &c__0); ic = 0; s1 = dsecnd_(); L90: dgtsv_(&m, &nrhs, &a[1], &a[n], &a[n * 2], &b[1], &ldb, & info); s2 = dsecnd_(); time = s2 - s1; ++ic; if (time < *timmin) { i__4 = n * 3; dtimmg_(&c__12, &m, &m, &a[1], &i__4, &c__0, &c__0); dtimmg_(&c__0, &m, &nrhs, &b[1], &ldb, &c__0, &c__0); goto L90; } /* Subtract the time used in DTIMMG. */ icl = 1; s1 = dsecnd_(); L100: s2 = dsecnd_(); untime = s2 - s1; ++icl; if (icl <= ic) { i__4 = n * 3; dtimmg_(&c__12, &m, &m, &a[1], &i__4, &c__0, &c__0); dtimmg_(&c__0, &m, &nrhs, &b[1], &ldb, &c__0, &c__0); goto L100; } time = (time - untime) / (doublereal) ic; ops = dopgb_("DGTSV ", &m, &nrhs, &c__0, &c__0, &iwork[1]); reslts_ref(i__, im, ilda, 3) = dmflop_(&ops, &time, &info) ; /* L110: */ } /* L120: */ } } if (timsub[3]) { i__2 = n * 3; dtimmg_(&c__12, &m, &m, &a[1], &i__2, &c__0, &c__0); dtimmg_(&c__0, &m, &c__1, &b[1], &n, &c__0, &c__0); ic = 0; s1 = dsecnd_(); L130: dgtsl_(&m, &a[1], &a[n], &a[n * 2], &b[1], &info); s2 = dsecnd_(); time = s2 - s1; ++ic; if (time < *timmin) { i__2 = n * 3; dtimmg_(&c__12, &m, &m, &a[1], &i__2, &c__0, &c__0); dtimmg_(&c__0, &m, &c__1, &b[1], &ldb, &c__0, &c__0); goto L130; } /* Subtract the time used in DTIMMG. */ icl = 1; s1 = dsecnd_(); L140: s2 = dsecnd_(); untime = s2 - s1; ++icl; if (icl <= ic) { i__2 = n * 3; dtimmg_(&c__12, &m, &m, &a[1], &i__2, &c__0, &c__0); dtimmg_(&c__0, &m, &c__1, &b[1], &ldb, &c__0, &c__0); goto L140; } time = (time - untime) / (doublereal) ic; ops = dopgb_("DGTSV ", &m, &c__1, &c__0, &c__0, &iwork[1]); reslts_ref(1, im, 1, 4) = dmflop_(&ops, &time, &info); } /* L150: */ } /* Print a table of results for each timed routine. */ for (isub = 1; isub <= 4; ++isub) { if (! timsub[isub - 1]) { goto L170; } io___25.ciunit = *nout; s_wsfe(&io___25); do_fio(&c__1, subnam_ref(0, isub), (ftnlen)6); e_wsfe(); if (*nlda > 1 && (timsub[1] || timsub[2])) { i__1 = *nlda; for (i__ = 1; i__ <= i__1; ++i__) { io___26.ciunit = *nout; s_wsfe(&io___26); do_fio(&c__1, (char *)&i__, (ftnlen)sizeof(integer)); do_fio(&c__1, (char *)&ldaval[i__], (ftnlen)sizeof(integer)); e_wsfe(); /* L160: */ } } io___27.ciunit = *nout; s_wsle(&io___27); e_wsle(); if (isub == 1) { dprtbl_(" ", "N", &c__1, laval, nm, &mval[1], &c__1, &reslts[ reslts_offset], ldr1, ldr2, nout, (ftnlen)1, (ftnlen)1); } else if (isub == 2) { io___29.ciunit = *nout; s_wsfe(&io___29); do_fio(&c__1, "N", (ftnlen)1); e_wsfe(); dprtbl_("NRHS", "N", nns, &nsval[1], nm, &mval[1], nlda, & reslts_ref(1, 1, 1, 2), ldr1, ldr2, nout, (ftnlen)4, ( ftnlen)1); io___30.ciunit = *nout; s_wsfe(&io___30); do_fio(&c__1, "T", (ftnlen)1); e_wsfe(); dprtbl_("NRHS", "N", nns, &nsval[1], nm, &mval[1], nlda, & reslts_ref(1, 1, 1, 5), ldr1, ldr2, nout, (ftnlen)4, ( ftnlen)1); } else if (isub == 3) { dprtbl_("NRHS", "N", nns, &nsval[1], nm, &mval[1], nlda, & reslts_ref(1, 1, 1, 3), ldr1, ldr2, nout, (ftnlen)4, ( ftnlen)1); } else if (isub == 4) { dprtbl_(" ", "N", &c__1, laval, nm, &mval[1], &c__1, &reslts_ref( 1, 1, 1, 4), ldr1, ldr2, nout, (ftnlen)1, (ftnlen)1); } L170: ; } L180: return 0; /* End of DTIMGT */ } /* dtimgt_ */
/* Subroutine */ int dgtcon_(char *norm, integer *n, doublereal *dl, doublereal *d__, doublereal *du, doublereal *du2, integer *ipiv, doublereal *anorm, doublereal *rcond, doublereal *work, integer * iwork, integer *info) { /* -- LAPACK 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 ======= DGTCON estimates the reciprocal of the condition number of a real tridiagonal matrix A using the LU factorization as computed by DGTTRF. An estimate is obtained for norm(inv(A)), and the reciprocal of the condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). Arguments ========= NORM (input) CHARACTER*1 Specifies whether the 1-norm condition number or the infinity-norm condition number is required: = '1' or 'O': 1-norm; = 'I': Infinity-norm. N (input) INTEGER The order of the matrix A. N >= 0. DL (input) DOUBLE PRECISION array, dimension (N-1) The (n-1) multipliers that define the matrix L from the LU factorization of A as computed by DGTTRF. D (input) DOUBLE PRECISION array, dimension (N) The n diagonal elements of the upper triangular matrix U from the LU factorization of A. DU (input) DOUBLE PRECISION array, dimension (N-1) The (n-1) elements of the first superdiagonal of U. DU2 (input) DOUBLE PRECISION array, dimension (N-2) The (n-2) elements of the second superdiagonal of U. IPIV (input) INTEGER array, dimension (N) The pivot indices; for 1 <= i <= n, row i of the matrix was interchanged with row IPIV(i). IPIV(i) will always be either i or i+1; IPIV(i) = i indicates a row interchange was not required. ANORM (input) DOUBLE PRECISION If NORM = '1' or 'O', the 1-norm of the original matrix A. If NORM = 'I', the infinity-norm of the original matrix A. RCOND (output) DOUBLE PRECISION The reciprocal of the condition number of the matrix A, computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an estimate of the 1-norm of inv(A) computed in this routine. WORK (workspace) DOUBLE PRECISION array, dimension (2*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 ===================================================================== Test the input arguments. Parameter adjustments */ /* Table of constant values */ static integer c__1 = 1; /* System generated locals */ integer i__1; /* Local variables */ static integer kase, kase1, i__; extern logical lsame_(char *, char *); extern /* Subroutine */ int dlacon_(integer *, doublereal *, doublereal *, integer *, doublereal *, integer *), xerbla_(char *, integer *); static doublereal ainvnm; static logical onenrm; extern /* Subroutine */ int dgttrs_(char *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, integer *, integer *); --iwork; --work; --ipiv; --du2; --du; --d__; --dl; /* Function Body */ *info = 0; onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O"); if (! onenrm && ! lsame_(norm, "I")) { *info = -1; } else if (*n < 0) { *info = -2; } else if (*anorm < 0.) { *info = -8; } if (*info != 0) { i__1 = -(*info); xerbla_("DGTCON", &i__1); return 0; } /* Quick return if possible */ *rcond = 0.; if (*n == 0) { *rcond = 1.; return 0; } else if (*anorm == 0.) { return 0; } /* Check that D(1:N) is non-zero. */ i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { if (d__[i__] == 0.) { return 0; } /* L10: */ } ainvnm = 0.; if (onenrm) { kase1 = 1; } else { kase1 = 2; } kase = 0; L20: dlacon_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase); if (kase != 0) { if (kase == kase1) { /* Multiply by inv(U)*inv(L). */ dgttrs_("No transpose", n, &c__1, &dl[1], &d__[1], &du[1], &du2[1] , &ipiv[1], &work[1], n, info); } else { /* Multiply by inv(L')*inv(U'). */ dgttrs_("Transpose", n, &c__1, &dl[1], &d__[1], &du[1], &du2[1], & ipiv[1], &work[1], n, info); } goto L20; } /* Compute the estimate of the reciprocal condition number. */ if (ainvnm != 0.) { *rcond = 1. / ainvnm / *anorm; } return 0; /* End of DGTCON */ } /* dgtcon_ */
/* Subroutine */ int derrgt_(char *path, integer *nunit) { /* System generated locals */ doublereal d__1; /* Builtin functions */ integer s_wsle(cilist *), e_wsle(void); /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen); /* Local variables */ static integer info; static doublereal b[2], c__[2], d__[2], e[2], f[2], w[2], x[2], rcond, anorm; static char c2[2]; static doublereal r1[2], r2[2], cf[2], df[2], ef[2]; static integer ip[2], iw[2]; extern /* Subroutine */ int alaesm_(char *, logical *, integer *), dgtcon_(char *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, doublereal *, doublereal *, integer *, integer *); extern logical lsamen_(integer *, char *, char *); extern /* Subroutine */ int chkxer_(char *, integer *, integer *, logical *, logical *), dptcon_(integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, integer *) , dgtrfs_(char *, integer *, integer *, doublereal *, doublereal * , doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, integer *, doublereal *, integer *, doublereal *, doublereal *, doublereal *, integer *, integer *), dgttrf_(integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, integer *), dptrfs_( integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, integer *, doublereal *, doublereal *, doublereal *, integer *), dpttrf_( integer *, doublereal *, doublereal *, integer *), dgttrs_(char *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, integer *, integer *), dpttrs_(integer *, integer *, doublereal *, doublereal *, doublereal *, integer *, integer *); /* Fortran I/O blocks */ static cilist io___1 = { 0, 0, 0, 0, 0 }; /* -- 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 ======= DERRGT tests the error exits for the DOUBLE PRECISION tridiagonal routines. Arguments ========= PATH (input) CHARACTER*3 The LAPACK path name for the routines to be tested. NUNIT (input) INTEGER The unit number for output. ===================================================================== */ infoc_1.nout = *nunit; io___1.ciunit = infoc_1.nout; s_wsle(&io___1); e_wsle(); s_copy(c2, path + 1, (ftnlen)2, (ftnlen)2); d__[0] = 1.; d__[1] = 2.; df[0] = 1.; df[1] = 2.; e[0] = 3.; e[1] = 4.; ef[0] = 3.; ef[1] = 4.; anorm = 1.; infoc_1.ok = TRUE_; if (lsamen_(&c__2, c2, "GT")) { /* Test error exits for the general tridiagonal routines. DGTTRF */ s_copy(srnamc_1.srnamt, "DGTTRF", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; dgttrf_(&c_n1, c__, d__, e, f, ip, &info); chkxer_("DGTTRF", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* DGTTRS */ s_copy(srnamc_1.srnamt, "DGTTRS", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; dgttrs_("/", &c__0, &c__0, c__, d__, e, f, ip, x, &c__1, &info); chkxer_("DGTTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; dgttrs_("N", &c_n1, &c__0, c__, d__, e, f, ip, x, &c__1, &info); chkxer_("DGTTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; dgttrs_("N", &c__0, &c_n1, c__, d__, e, f, ip, x, &c__1, &info); chkxer_("DGTTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 10; dgttrs_("N", &c__2, &c__1, c__, d__, e, f, ip, x, &c__1, &info); chkxer_("DGTTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* DGTRFS */ s_copy(srnamc_1.srnamt, "DGTRFS", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; dgtrfs_("/", &c__0, &c__0, c__, d__, e, cf, df, ef, f, ip, b, &c__1, x, &c__1, r1, r2, w, iw, &info); chkxer_("DGTRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; dgtrfs_("N", &c_n1, &c__0, c__, d__, e, cf, df, ef, f, ip, b, &c__1, x, &c__1, r1, r2, w, iw, &info); chkxer_("DGTRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 3; dgtrfs_("N", &c__0, &c_n1, c__, d__, e, cf, df, ef, f, ip, b, &c__1, x, &c__1, r1, r2, w, iw, &info); chkxer_("DGTRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 13; dgtrfs_("N", &c__2, &c__1, c__, d__, e, cf, df, ef, f, ip, b, &c__1, x, &c__2, r1, r2, w, iw, &info); chkxer_("DGTRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 15; dgtrfs_("N", &c__2, &c__1, c__, d__, e, cf, df, ef, f, ip, b, &c__2, x, &c__1, r1, r2, w, iw, &info); chkxer_("DGTRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* DGTCON */ s_copy(srnamc_1.srnamt, "DGTCON", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; dgtcon_("/", &c__0, c__, d__, e, f, ip, &anorm, &rcond, w, iw, &info); chkxer_("DGTCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; dgtcon_("I", &c_n1, c__, d__, e, f, ip, &anorm, &rcond, w, iw, &info); chkxer_("DGTCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; d__1 = -anorm; dgtcon_("I", &c__0, c__, d__, e, f, ip, &d__1, &rcond, w, iw, &info); chkxer_("DGTCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } else if (lsamen_(&c__2, c2, "PT")) { /* Test error exits for the positive definite tridiagonal routines. DPTTRF */ s_copy(srnamc_1.srnamt, "DPTTRF", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; dpttrf_(&c_n1, d__, e, &info); chkxer_("DPTTRF", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* DPTTRS */ s_copy(srnamc_1.srnamt, "DPTTRS", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; dpttrs_(&c_n1, &c__0, d__, e, x, &c__1, &info); chkxer_("DPTTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; dpttrs_(&c__0, &c_n1, d__, e, x, &c__1, &info); chkxer_("DPTTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 6; dpttrs_(&c__2, &c__1, d__, e, x, &c__1, &info); chkxer_("DPTTRS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* DPTRFS */ s_copy(srnamc_1.srnamt, "DPTRFS", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; dptrfs_(&c_n1, &c__0, d__, e, df, ef, b, &c__1, x, &c__1, r1, r2, w, & info); chkxer_("DPTRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 2; dptrfs_(&c__0, &c_n1, d__, e, df, ef, b, &c__1, x, &c__1, r1, r2, w, & info); chkxer_("DPTRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 8; dptrfs_(&c__2, &c__1, d__, e, df, ef, b, &c__1, x, &c__2, r1, r2, w, & info); chkxer_("DPTRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 10; dptrfs_(&c__2, &c__1, d__, e, df, ef, b, &c__2, x, &c__1, r1, r2, w, & info); chkxer_("DPTRFS", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); /* DPTCON */ s_copy(srnamc_1.srnamt, "DPTCON", (ftnlen)6, (ftnlen)6); infoc_1.infot = 1; dptcon_(&c_n1, d__, e, &anorm, &rcond, w, &info); chkxer_("DPTCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); infoc_1.infot = 4; d__1 = -anorm; dptcon_(&c__0, d__, e, &d__1, &rcond, w, &info); chkxer_("DPTCON", &infoc_1.infot, &infoc_1.nout, &infoc_1.lerr, & infoc_1.ok); } /* Print a summary line. */ alaesm_(path, &infoc_1.ok, &infoc_1.nout); return 0; /* End of DERRGT */ } /* derrgt_ */
/* Subroutine */ int dgtcon_(char *norm, integer *n, doublereal *dl, doublereal *d__, doublereal *du, doublereal *du2, integer *ipiv, doublereal *anorm, doublereal *rcond, doublereal *work, integer * iwork, integer *info) { /* System generated locals */ integer i__1; /* Local variables */ integer i__, kase, kase1; extern logical lsame_(char *, char *); integer isave[3]; extern /* Subroutine */ int dlacn2_(integer *, doublereal *, doublereal *, integer *, doublereal *, integer *, integer *), xerbla_(char *, integer *); doublereal ainvnm; logical onenrm; extern /* Subroutine */ int dgttrs_(char *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, integer *, integer *); /* -- LAPACK routine (version 3.2) -- */ /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ /* November 2006 */ /* Modified to call DLACN2 in place of DLACON, 5 Feb 03, SJH. */ /* .. Scalar Arguments .. */ /* .. */ /* .. Array Arguments .. */ /* .. */ /* Purpose */ /* ======= */ /* DGTCON estimates the reciprocal of the condition number of a real */ /* tridiagonal matrix A using the LU factorization as computed by */ /* DGTTRF. */ /* An estimate is obtained for norm(inv(A)), and the reciprocal of the */ /* condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))). */ /* Arguments */ /* ========= */ /* NORM (input) CHARACTER*1 */ /* Specifies whether the 1-norm condition number or the */ /* infinity-norm condition number is required: */ /* = '1' or 'O': 1-norm; */ /* = 'I': Infinity-norm. */ /* N (input) INTEGER */ /* The order of the matrix A. N >= 0. */ /* DL (input) DOUBLE PRECISION array, dimension (N-1) */ /* The (n-1) multipliers that define the matrix L from the */ /* LU factorization of A as computed by DGTTRF. */ /* D (input) DOUBLE PRECISION array, dimension (N) */ /* The n diagonal elements of the upper triangular matrix U from */ /* the LU factorization of A. */ /* DU (input) DOUBLE PRECISION array, dimension (N-1) */ /* The (n-1) elements of the first superdiagonal of U. */ /* DU2 (input) DOUBLE PRECISION array, dimension (N-2) */ /* The (n-2) elements of the second superdiagonal of U. */ /* IPIV (input) INTEGER array, dimension (N) */ /* The pivot indices; for 1 <= i <= n, row i of the matrix was */ /* interchanged with row IPIV(i). IPIV(i) will always be either */ /* i or i+1; IPIV(i) = i indicates a row interchange was not */ /* required. */ /* ANORM (input) DOUBLE PRECISION */ /* If NORM = '1' or 'O', the 1-norm of the original matrix A. */ /* If NORM = 'I', the infinity-norm of the original matrix A. */ /* RCOND (output) DOUBLE PRECISION */ /* The reciprocal of the condition number of the matrix A, */ /* computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an */ /* estimate of the 1-norm of inv(A) computed in this routine. */ /* WORK (workspace) DOUBLE PRECISION array, dimension (2*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 */ /* ===================================================================== */ /* .. Parameters .. */ /* .. */ /* .. Local Scalars .. */ /* .. */ /* .. Local Arrays .. */ /* .. */ /* .. External Functions .. */ /* .. */ /* .. External Subroutines .. */ /* .. */ /* .. Executable Statements .. */ /* Test the input arguments. */ /* Parameter adjustments */ --iwork; --work; --ipiv; --du2; --du; --d__; --dl; /* Function Body */ *info = 0; onenrm = *(unsigned char *)norm == '1' || lsame_(norm, "O"); if (! onenrm && ! lsame_(norm, "I")) { *info = -1; } else if (*n < 0) { *info = -2; } else if (*anorm < 0.) { *info = -8; } if (*info != 0) { i__1 = -(*info); xerbla_("DGTCON", &i__1); return 0; } /* Quick return if possible */ *rcond = 0.; if (*n == 0) { *rcond = 1.; return 0; } else if (*anorm == 0.) { return 0; } /* Check that D(1:N) is non-zero. */ i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { if (d__[i__] == 0.) { return 0; } /* L10: */ } ainvnm = 0.; if (onenrm) { kase1 = 1; } else { kase1 = 2; } kase = 0; L20: dlacn2_(n, &work[*n + 1], &work[1], &iwork[1], &ainvnm, &kase, isave); if (kase != 0) { if (kase == kase1) { /* Multiply by inv(U)*inv(L). */ dgttrs_("No transpose", n, &c__1, &dl[1], &d__[1], &du[1], &du2[1] , &ipiv[1], &work[1], n, info); } else { /* Multiply by inv(L')*inv(U'). */ dgttrs_("Transpose", n, &c__1, &dl[1], &d__[1], &du[1], &du2[1], & ipiv[1], &work[1], n, info); } goto L20; } /* Compute the estimate of the reciprocal condition number. */ if (ainvnm != 0.) { *rcond = 1. / ainvnm / *anorm; } return 0; /* End of DGTCON */ } /* dgtcon_ */
/* Subroutine */ int dgtsvx_(char *fact, char *trans, integer *n, integer * nrhs, doublereal *dl, doublereal *d__, doublereal *du, doublereal * dlf, doublereal *df, doublereal *duf, doublereal *du2, integer *ipiv, doublereal *b, integer *ldb, doublereal *x, integer *ldx, doublereal * rcond, doublereal *ferr, doublereal *berr, doublereal *work, integer * iwork, integer *info) { /* -- LAPACK 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 ======= DGTSVX uses the LU factorization to compute the solution to a real system of linear equations A * X = B or A**T * X = B, where A is a tridiagonal matrix of order N 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 LU decomposition is used to factor the matrix A as A = L * U, where L is a product of permutation and unit lower bidiagonal matrices and U is upper triangular with nonzeros in only the main diagonal and first two superdiagonals. 2. If some U(i,i)=0, so that U 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': DLF, DF, DUF, DU2, and IPIV contain the factored form of A; DL, D, DU, DLF, DF, DUF, DU2 and IPIV will not be modified. = 'N': The matrix will be copied to DLF, DF, and DUF and factored. TRANS (input) CHARACTER*1 Specifies the form of the system of equations: = 'N': A * X = B (No transpose) = 'T': A**T * X = B (Transpose) = 'C': A**H * X = B (Conjugate transpose = Transpose) N (input) INTEGER The order of the matrix A. N >= 0. NRHS (input) INTEGER The number of right hand sides, i.e., the number of columns of the matrix B. NRHS >= 0. DL (input) DOUBLE PRECISION array, dimension (N-1) The (n-1) subdiagonal elements of A. D (input) DOUBLE PRECISION array, dimension (N) The n diagonal elements of A. DU (input) DOUBLE PRECISION array, dimension (N-1) The (n-1) superdiagonal elements of A. DLF (input or output) DOUBLE PRECISION array, dimension (N-1) If FACT = 'F', then DLF is an input argument and on entry contains the (n-1) multipliers that define the matrix L from the LU factorization of A as computed by DGTTRF. If FACT = 'N', then DLF is an output argument and on exit contains the (n-1) multipliers that define the matrix L from the LU factorization of A. DF (input or output) DOUBLE PRECISION array, dimension (N) If FACT = 'F', then DF is an input argument and on entry contains the n diagonal elements of the upper triangular matrix U from the LU factorization of A. If FACT = 'N', then DF is an output argument and on exit contains the n diagonal elements of the upper triangular matrix U from the LU factorization of A. DUF (input or output) DOUBLE PRECISION array, dimension (N-1) If FACT = 'F', then DUF is an input argument and on entry contains the (n-1) elements of the first superdiagonal of U. If FACT = 'N', then DUF is an output argument and on exit contains the (n-1) elements of the first superdiagonal of U. DU2 (input or output) DOUBLE PRECISION array, dimension (N-2) If FACT = 'F', then DU2 is an input argument and on entry contains the (n-2) elements of the second superdiagonal of U. If FACT = 'N', then DU2 is an output argument and on exit contains the (n-2) elements of the second superdiagonal of U. IPIV (input or output) INTEGER array, dimension (N) If FACT = 'F', then IPIV is an input argument and on entry contains the pivot indices from the LU factorization of A as computed by DGTTRF. If FACT = 'N', then IPIV is an output argument and on exit contains the pivot indices from the LU factorization of A; row i of the matrix was interchanged with row IPIV(i). IPIV(i) will always be either i or i+1; IPIV(i) = i indicates a row interchange was not required. B (input) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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) DOUBLE PRECISION 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: U(i,i) is exactly zero. The factorization has not been completed unless i = N, but the factor U is exactly singular, so the solution and error bounds could not be 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. ===================================================================== Parameter adjustments */ /* Table of constant values */ static integer c__1 = 1; /* System generated locals */ integer b_dim1, b_offset, x_dim1, x_offset, i__1; /* Local variables */ static char norm[1]; extern logical lsame_(char *, char *); static doublereal anorm; extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, doublereal *, integer *); extern doublereal dlamch_(char *), dlangt_(char *, integer *, doublereal *, doublereal *, doublereal *); static logical nofact; extern /* Subroutine */ int dlacpy_(char *, integer *, integer *, doublereal *, integer *, doublereal *, integer *), xerbla_(char *, integer *), dgtcon_(char *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, doublereal *, doublereal *, integer *, integer *), dgtrfs_(char *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, integer *, doublereal *, integer *, doublereal *, doublereal *, doublereal *, integer *, integer *), dgttrf_(integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, integer *); static logical notran; extern /* Subroutine */ int dgttrs_(char *, integer *, integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *, doublereal *, integer *, integer *); --dl; --d__; --du; --dlf; --df; --duf; --du2; --ipiv; b_dim1 = *ldb; b_offset = 1 + b_dim1 * 1; b -= b_offset; x_dim1 = *ldx; x_offset = 1 + x_dim1 * 1; x -= x_offset; --ferr; --berr; --work; --iwork; /* Function Body */ *info = 0; nofact = lsame_(fact, "N"); notran = lsame_(trans, "N"); if (! nofact && ! lsame_(fact, "F")) { *info = -1; } else if (! notran && ! lsame_(trans, "T") && ! lsame_(trans, "C")) { *info = -2; } else if (*n < 0) { *info = -3; } else if (*nrhs < 0) { *info = -4; } else if (*ldb < max(1,*n)) { *info = -14; } else if (*ldx < max(1,*n)) { *info = -16; } if (*info != 0) { i__1 = -(*info); xerbla_("DGTSVX", &i__1); return 0; } if (nofact) { /* Compute the LU factorization of A. */ dcopy_(n, &d__[1], &c__1, &df[1], &c__1); if (*n > 1) { i__1 = *n - 1; dcopy_(&i__1, &dl[1], &c__1, &dlf[1], &c__1); i__1 = *n - 1; dcopy_(&i__1, &du[1], &c__1, &duf[1], &c__1); } dgttrf_(n, &dlf[1], &df[1], &duf[1], &du2[1], &ipiv[1], info); /* Return if INFO is non-zero. */ if (*info != 0) { if (*info > 0) { *rcond = 0.; } return 0; } } /* Compute the norm of the matrix A. */ if (notran) { *(unsigned char *)norm = '1'; } else { *(unsigned char *)norm = 'I'; } anorm = dlangt_(norm, n, &dl[1], &d__[1], &du[1]); /* Compute the reciprocal of the condition number of A. */ dgtcon_(norm, n, &dlf[1], &df[1], &duf[1], &du2[1], &ipiv[1], &anorm, rcond, &work[1], &iwork[1], info); /* Set INFO = N+1 if the matrix is singular to working precision. */ if (*rcond < dlamch_("Epsilon")) { *info = *n + 1; } /* Compute the solution vectors X. */ dlacpy_("Full", n, nrhs, &b[b_offset], ldb, &x[x_offset], ldx); dgttrs_(trans, n, nrhs, &dlf[1], &df[1], &duf[1], &du2[1], &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. */ dgtrfs_(trans, n, nrhs, &dl[1], &d__[1], &du[1], &dlf[1], &df[1], &duf[1], &du2[1], &ipiv[1], &b[b_offset], ldb, &x[x_offset], ldx, &ferr[1] , &berr[1], &work[1], &iwork[1], info); return 0; /* End of DGTSVX */ } /* dgtsvx_ */