e97d0d65f070674c24b120c48ef5e6782c37e10a
[platform/upstream/lapack.git] / SRC / ctptrs.f
1 *> \brief \b CTPTRS
2 *
3 *  =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at 
6 *            http://www.netlib.org/lapack/explore-html/ 
7 *
8 *> \htmlonly
9 *> Download CTPTRS + dependencies 
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctptrs.f"> 
11 *> [TGZ]</a> 
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctptrs.f"> 
13 *> [ZIP]</a> 
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctptrs.f"> 
15 *> [TXT]</a>
16 *> \endhtmlonly 
17 *
18 *  Definition:
19 *  ===========
20 *
21 *       SUBROUTINE CTPTRS( UPLO, TRANS, DIAG, N, NRHS, AP, B, LDB, INFO )
22
23 *       .. Scalar Arguments ..
24 *       CHARACTER          DIAG, TRANS, UPLO
25 *       INTEGER            INFO, LDB, N, NRHS
26 *       ..
27 *       .. Array Arguments ..
28 *       COMPLEX            AP( * ), B( LDB, * )
29 *       ..
30 *  
31 *
32 *> \par Purpose:
33 *  =============
34 *>
35 *> \verbatim
36 *>
37 *> CTPTRS solves a triangular system of the form
38 *>
39 *>    A * X = B,  A**T * X = B,  or  A**H * X = B,
40 *>
41 *> where A is a triangular matrix of order N stored in packed format,
42 *> and B is an N-by-NRHS matrix.  A check is made to verify that A is
43 *> nonsingular.
44 *> \endverbatim
45 *
46 *  Arguments:
47 *  ==========
48 *
49 *> \param[in] UPLO
50 *> \verbatim
51 *>          UPLO is CHARACTER*1
52 *>          = 'U':  A is upper triangular;
53 *>          = 'L':  A is lower triangular.
54 *> \endverbatim
55 *>
56 *> \param[in] TRANS
57 *> \verbatim
58 *>          TRANS is CHARACTER*1
59 *>          Specifies the form of the system of equations:
60 *>          = 'N':  A * X = B     (No transpose)
61 *>          = 'T':  A**T * X = B  (Transpose)
62 *>          = 'C':  A**H * X = B  (Conjugate transpose)
63 *> \endverbatim
64 *>
65 *> \param[in] DIAG
66 *> \verbatim
67 *>          DIAG is CHARACTER*1
68 *>          = 'N':  A is non-unit triangular;
69 *>          = 'U':  A is unit triangular.
70 *> \endverbatim
71 *>
72 *> \param[in] N
73 *> \verbatim
74 *>          N is INTEGER
75 *>          The order of the matrix A.  N >= 0.
76 *> \endverbatim
77 *>
78 *> \param[in] NRHS
79 *> \verbatim
80 *>          NRHS is INTEGER
81 *>          The number of right hand sides, i.e., the number of columns
82 *>          of the matrix B.  NRHS >= 0.
83 *> \endverbatim
84 *>
85 *> \param[in] AP
86 *> \verbatim
87 *>          AP is COMPLEX array, dimension (N*(N+1)/2)
88 *>          The upper or lower triangular matrix A, packed columnwise in
89 *>          a linear array.  The j-th column of A is stored in the array
90 *>          AP as follows:
91 *>          if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
92 *>          if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
93 *> \endverbatim
94 *>
95 *> \param[in,out] B
96 *> \verbatim
97 *>          B is COMPLEX array, dimension (LDB,NRHS)
98 *>          On entry, the right hand side matrix B.
99 *>          On exit, if INFO = 0, the solution matrix X.
100 *> \endverbatim
101 *>
102 *> \param[in] LDB
103 *> \verbatim
104 *>          LDB is INTEGER
105 *>          The leading dimension of the array B.  LDB >= max(1,N).
106 *> \endverbatim
107 *>
108 *> \param[out] INFO
109 *> \verbatim
110 *>          INFO is INTEGER
111 *>          = 0:  successful exit
112 *>          < 0:  if INFO = -i, the i-th argument had an illegal value
113 *>          > 0:  if INFO = i, the i-th diagonal element of A is zero,
114 *>                indicating that the matrix is singular and the
115 *>                solutions X have not been computed.
116 *> \endverbatim
117 *
118 *  Authors:
119 *  ========
120 *
121 *> \author Univ. of Tennessee 
122 *> \author Univ. of California Berkeley 
123 *> \author Univ. of Colorado Denver 
124 *> \author NAG Ltd. 
125 *
126 *> \date November 2011
127 *
128 *> \ingroup complexOTHERcomputational
129 *
130 *  =====================================================================
131       SUBROUTINE CTPTRS( UPLO, TRANS, DIAG, N, NRHS, AP, B, LDB, INFO )
132 *
133 *  -- LAPACK computational routine (version 3.4.0) --
134 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
135 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
136 *     November 2011
137 *
138 *     .. Scalar Arguments ..
139       CHARACTER          DIAG, TRANS, UPLO
140       INTEGER            INFO, LDB, N, NRHS
141 *     ..
142 *     .. Array Arguments ..
143       COMPLEX            AP( * ), B( LDB, * )
144 *     ..
145 *
146 *  =====================================================================
147 *
148 *     .. Parameters ..
149       COMPLEX            ZERO
150       PARAMETER          ( ZERO = ( 0.0E+0, 0.0E+0 ) )
151 *     ..
152 *     .. Local Scalars ..
153       LOGICAL            NOUNIT, UPPER
154       INTEGER            J, JC
155 *     ..
156 *     .. External Functions ..
157       LOGICAL            LSAME
158       EXTERNAL           LSAME
159 *     ..
160 *     .. External Subroutines ..
161       EXTERNAL           CTPSV, XERBLA
162 *     ..
163 *     .. Intrinsic Functions ..
164       INTRINSIC          MAX
165 *     ..
166 *     .. Executable Statements ..
167 *
168 *     Test the input parameters.
169 *
170       INFO = 0
171       UPPER = LSAME( UPLO, 'U' )
172       NOUNIT = LSAME( DIAG, 'N' )
173       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
174          INFO = -1
175       ELSE IF( .NOT.LSAME( TRANS, 'N' ) .AND. .NOT.
176      $         LSAME( TRANS, 'T' ) .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
177          INFO = -2
178       ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN
179          INFO = -3
180       ELSE IF( N.LT.0 ) THEN
181          INFO = -4
182       ELSE IF( NRHS.LT.0 ) THEN
183          INFO = -5
184       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
185          INFO = -8
186       END IF
187       IF( INFO.NE.0 ) THEN
188          CALL XERBLA( 'CTPTRS', -INFO )
189          RETURN
190       END IF
191 *
192 *     Quick return if possible
193 *
194       IF( N.EQ.0 )
195      $   RETURN
196 *
197 *     Check for singularity.
198 *
199       IF( NOUNIT ) THEN
200          IF( UPPER ) THEN
201             JC = 1
202             DO 10 INFO = 1, N
203                IF( AP( JC+INFO-1 ).EQ.ZERO )
204      $            RETURN
205                JC = JC + INFO
206    10       CONTINUE
207          ELSE
208             JC = 1
209             DO 20 INFO = 1, N
210                IF( AP( JC ).EQ.ZERO )
211      $            RETURN
212                JC = JC + N - INFO + 1
213    20       CONTINUE
214          END IF
215       END IF
216       INFO = 0
217 *
218 *     Solve  A * x = b,  A**T * x = b,  or  A**H * x = b.
219 *
220       DO 30 J = 1, NRHS
221          CALL CTPSV( UPLO, TRANS, DIAG, N, AP, B( 1, J ), 1 )
222    30 CONTINUE
223 *
224       RETURN
225 *
226 *     End of CTPTRS
227 *
228       END