dtptrs.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /* dtptrs.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Table of constant values */
  14. static integer c__1 = 1;
  15. /* Subroutine */ int dtptrs_(char *uplo, char *trans, char *diag, integer *n,
  16. integer *nrhs, doublereal *ap, doublereal *b, integer *ldb, integer *
  17. info)
  18. {
  19. /* System generated locals */
  20. integer b_dim1, b_offset, i__1;
  21. /* Local variables */
  22. integer j, jc;
  23. extern logical lsame_(char *, char *);
  24. logical upper;
  25. extern /* Subroutine */ int dtpsv_(char *, char *, char *, integer *,
  26. doublereal *, doublereal *, integer *),
  27. xerbla_(char *, integer *);
  28. logical nounit;
  29. /* -- LAPACK routine (version 3.2) -- */
  30. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  31. /* November 2006 */
  32. /* .. Scalar Arguments .. */
  33. /* .. */
  34. /* .. Array Arguments .. */
  35. /* .. */
  36. /* Purpose */
  37. /* ======= */
  38. /* DTPTRS solves a triangular system of the form */
  39. /* A * X = B or A**T * X = B, */
  40. /* where A is a triangular matrix of order N stored in packed format, */
  41. /* and B is an N-by-NRHS matrix. A check is made to verify that A is */
  42. /* nonsingular. */
  43. /* Arguments */
  44. /* ========= */
  45. /* UPLO (input) CHARACTER*1 */
  46. /* = 'U': A is upper triangular; */
  47. /* = 'L': A is lower triangular. */
  48. /* TRANS (input) CHARACTER*1 */
  49. /* Specifies the form of the system of equations: */
  50. /* = 'N': A * X = B (No transpose) */
  51. /* = 'T': A**T * X = B (Transpose) */
  52. /* = 'C': A**H * X = B (Conjugate transpose = Transpose) */
  53. /* DIAG (input) CHARACTER*1 */
  54. /* = 'N': A is non-unit triangular; */
  55. /* = 'U': A is unit triangular. */
  56. /* N (input) INTEGER */
  57. /* The order of the matrix A. N >= 0. */
  58. /* NRHS (input) INTEGER */
  59. /* The number of right hand sides, i.e., the number of columns */
  60. /* of the matrix B. NRHS >= 0. */
  61. /* AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
  62. /* The upper or lower triangular matrix A, packed columnwise in */
  63. /* a linear array. The j-th column of A is stored in the array */
  64. /* AP as follows: */
  65. /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
  66. /* if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. */
  67. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  68. /* On entry, the right hand side matrix B. */
  69. /* On exit, if INFO = 0, the solution matrix X. */
  70. /* LDB (input) INTEGER */
  71. /* The leading dimension of the array B. LDB >= max(1,N). */
  72. /* INFO (output) INTEGER */
  73. /* = 0: successful exit */
  74. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  75. /* > 0: if INFO = i, the i-th diagonal element of A is zero, */
  76. /* indicating that the matrix is singular and the */
  77. /* solutions X have not been computed. */
  78. /* ===================================================================== */
  79. /* .. Parameters .. */
  80. /* .. */
  81. /* .. Local Scalars .. */
  82. /* .. */
  83. /* .. External Functions .. */
  84. /* .. */
  85. /* .. External Subroutines .. */
  86. /* .. */
  87. /* .. Intrinsic Functions .. */
  88. /* .. */
  89. /* .. Executable Statements .. */
  90. /* Test the input parameters. */
  91. /* Parameter adjustments */
  92. --ap;
  93. b_dim1 = *ldb;
  94. b_offset = 1 + b_dim1;
  95. b -= b_offset;
  96. /* Function Body */
  97. *info = 0;
  98. upper = lsame_(uplo, "U");
  99. nounit = lsame_(diag, "N");
  100. if (! upper && ! lsame_(uplo, "L")) {
  101. *info = -1;
  102. } else if (! lsame_(trans, "N") && ! lsame_(trans,
  103. "T") && ! lsame_(trans, "C")) {
  104. *info = -2;
  105. } else if (! nounit && ! lsame_(diag, "U")) {
  106. *info = -3;
  107. } else if (*n < 0) {
  108. *info = -4;
  109. } else if (*nrhs < 0) {
  110. *info = -5;
  111. } else if (*ldb < max(1,*n)) {
  112. *info = -8;
  113. }
  114. if (*info != 0) {
  115. i__1 = -(*info);
  116. xerbla_("DTPTRS", &i__1);
  117. return 0;
  118. }
  119. /* Quick return if possible */
  120. if (*n == 0) {
  121. return 0;
  122. }
  123. /* Check for singularity. */
  124. if (nounit) {
  125. if (upper) {
  126. jc = 1;
  127. i__1 = *n;
  128. for (*info = 1; *info <= i__1; ++(*info)) {
  129. if (ap[jc + *info - 1] == 0.) {
  130. return 0;
  131. }
  132. jc += *info;
  133. /* L10: */
  134. }
  135. } else {
  136. jc = 1;
  137. i__1 = *n;
  138. for (*info = 1; *info <= i__1; ++(*info)) {
  139. if (ap[jc] == 0.) {
  140. return 0;
  141. }
  142. jc = jc + *n - *info + 1;
  143. /* L20: */
  144. }
  145. }
  146. }
  147. *info = 0;
  148. /* Solve A * x = b or A' * x = b. */
  149. i__1 = *nrhs;
  150. for (j = 1; j <= i__1; ++j) {
  151. dtpsv_(uplo, trans, diag, n, &ap[1], &b[j * b_dim1 + 1], &c__1);
  152. /* L30: */
  153. }
  154. return 0;
  155. /* End of DTPTRS */
  156. } /* dtptrs_ */