00001 /* sppsv.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Subroutine */ int sppsv_(char *uplo, integer *n, integer *nrhs, real *ap, 00017 real *b, integer *ldb, integer *info) 00018 { 00019 /* System generated locals */ 00020 integer b_dim1, b_offset, i__1; 00021 00022 /* Local variables */ 00023 extern logical lsame_(char *, char *); 00024 extern /* Subroutine */ int xerbla_(char *, integer *), spptrf_( 00025 char *, integer *, real *, integer *), spptrs_(char *, 00026 integer *, integer *, real *, real *, integer *, integer *); 00027 00028 00029 /* -- LAPACK driver routine (version 3.2) -- */ 00030 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00031 /* November 2006 */ 00032 00033 /* .. Scalar Arguments .. */ 00034 /* .. */ 00035 /* .. Array Arguments .. */ 00036 /* .. */ 00037 00038 /* Purpose */ 00039 /* ======= */ 00040 00041 /* SPPSV computes the solution to a real system of linear equations */ 00042 /* A * X = B, */ 00043 /* where A is an N-by-N symmetric positive definite matrix stored in */ 00044 /* packed format and X and B are N-by-NRHS matrices. */ 00045 00046 /* The Cholesky decomposition is used to factor A as */ 00047 /* A = U**T* U, if UPLO = 'U', or */ 00048 /* A = L * L**T, if UPLO = 'L', */ 00049 /* where U is an upper triangular matrix and L is a lower triangular */ 00050 /* matrix. The factored form of A is then used to solve the system of */ 00051 /* equations A * X = B. */ 00052 00053 /* Arguments */ 00054 /* ========= */ 00055 00056 /* UPLO (input) CHARACTER*1 */ 00057 /* = 'U': Upper triangle of A is stored; */ 00058 /* = 'L': Lower triangle of A is stored. */ 00059 00060 /* N (input) INTEGER */ 00061 /* The number of linear equations, i.e., the order of the */ 00062 /* matrix A. N >= 0. */ 00063 00064 /* NRHS (input) INTEGER */ 00065 /* The number of right hand sides, i.e., the number of columns */ 00066 /* of the matrix B. NRHS >= 0. */ 00067 00068 /* AP (input/output) REAL array, dimension (N*(N+1)/2) */ 00069 /* On entry, the upper or lower triangle of the symmetric matrix */ 00070 /* A, packed columnwise in a linear array. The j-th column of A */ 00071 /* is stored in the array AP as follows: */ 00072 /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ 00073 /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */ 00074 /* See below for further details. */ 00075 00076 /* On exit, if INFO = 0, the factor U or L from the Cholesky */ 00077 /* factorization A = U**T*U or A = L*L**T, in the same storage */ 00078 /* format as A. */ 00079 00080 /* B (input/output) REAL array, dimension (LDB,NRHS) */ 00081 /* On entry, the N-by-NRHS right hand side matrix B. */ 00082 /* On exit, if INFO = 0, the N-by-NRHS solution matrix X. */ 00083 00084 /* LDB (input) INTEGER */ 00085 /* The leading dimension of the array B. LDB >= max(1,N). */ 00086 00087 /* INFO (output) INTEGER */ 00088 /* = 0: successful exit */ 00089 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00090 /* > 0: if INFO = i, the leading minor of order i of A is not */ 00091 /* positive definite, so the factorization could not be */ 00092 /* completed, and the solution has not been computed. */ 00093 00094 /* Further Details */ 00095 /* =============== */ 00096 00097 /* The packed storage scheme is illustrated by the following example */ 00098 /* when N = 4, UPLO = 'U': */ 00099 00100 /* Two-dimensional storage of the symmetric matrix A: */ 00101 00102 /* a11 a12 a13 a14 */ 00103 /* a22 a23 a24 */ 00104 /* a33 a34 (aij = conjg(aji)) */ 00105 /* a44 */ 00106 00107 /* Packed storage of the upper triangle of A: */ 00108 00109 /* AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] */ 00110 00111 /* ===================================================================== */ 00112 00113 /* .. External Functions .. */ 00114 /* .. */ 00115 /* .. External Subroutines .. */ 00116 /* .. */ 00117 /* .. Intrinsic Functions .. */ 00118 /* .. */ 00119 /* .. Executable Statements .. */ 00120 00121 /* Test the input parameters. */ 00122 00123 /* Parameter adjustments */ 00124 --ap; 00125 b_dim1 = *ldb; 00126 b_offset = 1 + b_dim1; 00127 b -= b_offset; 00128 00129 /* Function Body */ 00130 *info = 0; 00131 if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) { 00132 *info = -1; 00133 } else if (*n < 0) { 00134 *info = -2; 00135 } else if (*nrhs < 0) { 00136 *info = -3; 00137 } else if (*ldb < max(1,*n)) { 00138 *info = -6; 00139 } 00140 if (*info != 0) { 00141 i__1 = -(*info); 00142 xerbla_("SPPSV ", &i__1); 00143 return 0; 00144 } 00145 00146 /* Compute the Cholesky factorization A = U'*U or A = L*L'. */ 00147 00148 spptrf_(uplo, n, &ap[1], info); 00149 if (*info == 0) { 00150 00151 /* Solve the system A*X = B, overwriting B with X. */ 00152 00153 spptrs_(uplo, n, nrhs, &ap[1], &b[b_offset], ldb, info); 00154 00155 } 00156 return 0; 00157 00158 /* End of SPPSV */ 00159 00160 } /* sppsv_ */