dpptrs.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /* dpptrs.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 _starpu_dpptrs_(char *uplo, integer *n, integer *nrhs,
  16. doublereal *ap, doublereal *b, integer *ldb, integer *info)
  17. {
  18. /* System generated locals */
  19. integer b_dim1, b_offset, i__1;
  20. /* Local variables */
  21. integer i__;
  22. extern logical _starpu_lsame_(char *, char *);
  23. logical upper;
  24. extern /* Subroutine */ int _starpu_dtpsv_(char *, char *, char *, integer *,
  25. doublereal *, doublereal *, integer *),
  26. _starpu_xerbla_(char *, integer *);
  27. /* -- LAPACK routine (version 3.2) -- */
  28. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  29. /* November 2006 */
  30. /* .. Scalar Arguments .. */
  31. /* .. */
  32. /* .. Array Arguments .. */
  33. /* .. */
  34. /* Purpose */
  35. /* ======= */
  36. /* DPPTRS solves a system of linear equations A*X = B with a symmetric */
  37. /* positive definite matrix A in packed storage using the Cholesky */
  38. /* factorization A = U**T*U or A = L*L**T computed by DPPTRF. */
  39. /* Arguments */
  40. /* ========= */
  41. /* UPLO (input) CHARACTER*1 */
  42. /* = 'U': Upper triangle of A is stored; */
  43. /* = 'L': Lower triangle of A is stored. */
  44. /* N (input) INTEGER */
  45. /* The order of the matrix A. N >= 0. */
  46. /* NRHS (input) INTEGER */
  47. /* The number of right hand sides, i.e., the number of columns */
  48. /* of the matrix B. NRHS >= 0. */
  49. /* AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
  50. /* The triangular factor U or L from the Cholesky factorization */
  51. /* A = U**T*U or A = L*L**T, packed columnwise in a linear */
  52. /* array. The j-th column of U or L is stored in the array AP */
  53. /* as follows: */
  54. /* if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j; */
  55. /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n. */
  56. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  57. /* On entry, the right hand side matrix B. */
  58. /* On exit, the solution matrix X. */
  59. /* LDB (input) INTEGER */
  60. /* The leading dimension of the array B. LDB >= max(1,N). */
  61. /* INFO (output) INTEGER */
  62. /* = 0: successful exit */
  63. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  64. /* ===================================================================== */
  65. /* .. Local Scalars .. */
  66. /* .. */
  67. /* .. External Functions .. */
  68. /* .. */
  69. /* .. External Subroutines .. */
  70. /* .. */
  71. /* .. Intrinsic Functions .. */
  72. /* .. */
  73. /* .. Executable Statements .. */
  74. /* Test the input parameters. */
  75. /* Parameter adjustments */
  76. --ap;
  77. b_dim1 = *ldb;
  78. b_offset = 1 + b_dim1;
  79. b -= b_offset;
  80. /* Function Body */
  81. *info = 0;
  82. upper = _starpu_lsame_(uplo, "U");
  83. if (! upper && ! _starpu_lsame_(uplo, "L")) {
  84. *info = -1;
  85. } else if (*n < 0) {
  86. *info = -2;
  87. } else if (*nrhs < 0) {
  88. *info = -3;
  89. } else if (*ldb < max(1,*n)) {
  90. *info = -6;
  91. }
  92. if (*info != 0) {
  93. i__1 = -(*info);
  94. _starpu_xerbla_("DPPTRS", &i__1);
  95. return 0;
  96. }
  97. /* Quick return if possible */
  98. if (*n == 0 || *nrhs == 0) {
  99. return 0;
  100. }
  101. if (upper) {
  102. /* Solve A*X = B where A = U'*U. */
  103. i__1 = *nrhs;
  104. for (i__ = 1; i__ <= i__1; ++i__) {
  105. /* Solve U'*X = B, overwriting B with X. */
  106. _starpu_dtpsv_("Upper", "Transpose", "Non-unit", n, &ap[1], &b[i__ *
  107. b_dim1 + 1], &c__1);
  108. /* Solve U*X = B, overwriting B with X. */
  109. _starpu_dtpsv_("Upper", "No transpose", "Non-unit", n, &ap[1], &b[i__ *
  110. b_dim1 + 1], &c__1);
  111. /* L10: */
  112. }
  113. } else {
  114. /* Solve A*X = B where A = L*L'. */
  115. i__1 = *nrhs;
  116. for (i__ = 1; i__ <= i__1; ++i__) {
  117. /* Solve L*Y = B, overwriting B with X. */
  118. _starpu_dtpsv_("Lower", "No transpose", "Non-unit", n, &ap[1], &b[i__ *
  119. b_dim1 + 1], &c__1);
  120. /* Solve L'*X = Y, overwriting B with X. */
  121. _starpu_dtpsv_("Lower", "Transpose", "Non-unit", n, &ap[1], &b[i__ *
  122. b_dim1 + 1], &c__1);
  123. /* L20: */
  124. }
  125. }
  126. return 0;
  127. /* End of DPPTRS */
  128. } /* _starpu_dpptrs_ */