1 /* ./src_f77/chpsv.f -- translated by f2c (version 20030320).
2    You must link the resulting object file with the libraries:
3 	-lf2c -lm   (in that order)
4 */
5 
6 #include <punc/vf2c.h>
7 
chpsv_(char * uplo,integer * n,integer * nrhs,complex * ap,integer * ipiv,complex * b,integer * ldb,integer * info,ftnlen uplo_len)8 /* Subroutine */ int chpsv_(char *uplo, integer *n, integer *nrhs, complex *
9 	ap, integer *ipiv, complex *b, integer *ldb, integer *info, ftnlen
10 	uplo_len)
11 {
12     /* System generated locals */
13     integer b_dim1, b_offset, i__1;
14 
15     /* Local variables */
16     extern logical lsame_(char *, char *, ftnlen, ftnlen);
17     extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), chptrf_(
18 	    char *, integer *, complex *, integer *, integer *, ftnlen),
19 	    chptrs_(char *, integer *, integer *, complex *, integer *,
20 	    complex *, integer *, integer *, ftnlen);
21 
22 
23 /*  -- LAPACK driver routine (version 3.0) -- */
24 /*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
25 /*     Courant Institute, Argonne National Lab, and Rice University */
26 /*     March 31, 1993 */
27 
28 /*     .. Scalar Arguments .. */
29 /*     .. */
30 /*     .. Array Arguments .. */
31 /*     .. */
32 
33 /*  Purpose */
34 /*  ======= */
35 
36 /*  CHPSV computes the solution to a complex system of linear equations */
37 /*     A * X = B, */
38 /*  where A is an N-by-N Hermitian matrix stored in packed format and X */
39 /*  and B are N-by-NRHS matrices. */
40 
41 /*  The diagonal pivoting method is used to factor A as */
42 /*     A = U * D * U**H,  if UPLO = 'U', or */
43 /*     A = L * D * L**H,  if UPLO = 'L', */
44 /*  where U (or L) is a product of permutation and unit upper (lower) */
45 /*  triangular matrices, D is Hermitian and block diagonal with 1-by-1 */
46 /*  and 2-by-2 diagonal blocks.  The factored form of A is then used to */
47 /*  solve the system of equations A * X = B. */
48 
49 /*  Arguments */
50 /*  ========= */
51 
52 /*  UPLO    (input) CHARACTER*1 */
53 /*          = 'U':  Upper triangle of A is stored; */
54 /*          = 'L':  Lower triangle of A is stored. */
55 
56 /*  N       (input) INTEGER */
57 /*          The number of linear equations, i.e., the order of the */
58 /*          matrix A.  N >= 0. */
59 
60 /*  NRHS    (input) INTEGER */
61 /*          The number of right hand sides, i.e., the number of columns */
62 /*          of the matrix B.  NRHS >= 0. */
63 
64 /*  AP      (input/output) COMPLEX array, dimension (N*(N+1)/2) */
65 /*          On entry, the upper or lower triangle of the Hermitian matrix */
66 /*          A, packed columnwise in a linear array.  The j-th column of A */
67 /*          is stored in the array AP as follows: */
68 /*          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
69 /*          if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
70 /*          See below for further details. */
71 
72 /*          On exit, the block diagonal matrix D and the multipliers used */
73 /*          to obtain the factor U or L from the factorization */
74 /*          A = U*D*U**H or A = L*D*L**H as computed by CHPTRF, stored as */
75 /*          a packed triangular matrix in the same storage format as A. */
76 
77 /*  IPIV    (output) INTEGER array, dimension (N) */
78 /*          Details of the interchanges and the block structure of D, as */
79 /*          determined by CHPTRF.  If IPIV(k) > 0, then rows and columns */
80 /*          k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1 */
81 /*          diagonal block.  If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, */
82 /*          then rows and columns k-1 and -IPIV(k) were interchanged and */
83 /*          D(k-1:k,k-1:k) is a 2-by-2 diagonal block.  If UPLO = 'L' and */
84 /*          IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and */
85 /*          -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2 */
86 /*          diagonal block. */
87 
88 /*  B       (input/output) COMPLEX array, dimension (LDB,NRHS) */
89 /*          On entry, the N-by-NRHS right hand side matrix B. */
90 /*          On exit, if INFO = 0, the N-by-NRHS solution matrix X. */
91 
92 /*  LDB     (input) INTEGER */
93 /*          The leading dimension of the array B.  LDB >= max(1,N). */
94 
95 /*  INFO    (output) INTEGER */
96 /*          = 0:  successful exit */
97 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
98 /*          > 0:  if INFO = i, D(i,i) is exactly zero.  The factorization */
99 /*                has been completed, but the block diagonal matrix D is */
100 /*                exactly singular, so the solution could not be */
101 /*                computed. */
102 
103 /*  Further Details */
104 /*  =============== */
105 
106 /*  The packed storage scheme is illustrated by the following example */
107 /*  when N = 4, UPLO = 'U': */
108 
109 /*  Two-dimensional storage of the Hermitian matrix A: */
110 
111 /*     a11 a12 a13 a14 */
112 /*         a22 a23 a24 */
113 /*             a33 a34     (aij = conjg(aji)) */
114 /*                 a44 */
115 
116 /*  Packed storage of the upper triangle of A: */
117 
118 /*  AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] */
119 
120 /*  ===================================================================== */
121 
122 /*     .. External Functions .. */
123 /*     .. */
124 /*     .. External Subroutines .. */
125 /*     .. */
126 /*     .. Intrinsic Functions .. */
127 /*     .. */
128 /*     .. Executable Statements .. */
129 
130 /*     Test the input parameters. */
131 
132     /* Parameter adjustments */
133     --ap;
134     --ipiv;
135     b_dim1 = *ldb;
136     b_offset = 1 + b_dim1;
137     b -= b_offset;
138 
139     /* Function Body */
140     *info = 0;
141     if (! lsame_(uplo, "U", (ftnlen)1, (ftnlen)1) && ! lsame_(uplo, "L", (
142 	    ftnlen)1, (ftnlen)1)) {
143 	*info = -1;
144     } else if (*n < 0) {
145 	*info = -2;
146     } else if (*nrhs < 0) {
147 	*info = -3;
148     } else if (*ldb < max(1,*n)) {
149 	*info = -7;
150     }
151     if (*info != 0) {
152 	i__1 = -(*info);
153 	xerbla_("CHPSV ", &i__1, (ftnlen)6);
154 	return 0;
155     }
156 
157 /*     Compute the factorization A = U*D*U' or A = L*D*L'. */
158 
159     chptrf_(uplo, n, &ap[1], &ipiv[1], info, (ftnlen)1);
160     if (*info == 0) {
161 
162 /*        Solve the system A*X = B, overwriting B with X. */
163 
164 	chptrs_(uplo, n, nrhs, &ap[1], &ipiv[1], &b[b_offset], ldb, info, (
165 		ftnlen)1);
166 
167     }
168     return 0;
169 
170 /*     End of CHPSV */
171 
172 } /* chpsv_ */
173 
174