dpftrs.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /* dpftrs.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 doublereal c_b10 = 1.;
  15. /* Subroutine */ int _starpu_dpftrs_(char *transr, char *uplo, integer *n, integer *
  16. nrhs, doublereal *a, doublereal *b, integer *ldb, integer *info)
  17. {
  18. /* System generated locals */
  19. integer b_dim1, b_offset, i__1;
  20. /* Local variables */
  21. logical normaltransr;
  22. extern logical _starpu_lsame_(char *, char *);
  23. extern /* Subroutine */ int _starpu_dtfsm_(char *, char *, char *, char *, char *,
  24. integer *, integer *, doublereal *, doublereal *, doublereal *,
  25. integer *);
  26. logical lower;
  27. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  28. /* -- LAPACK routine (version 3.2) -- */
  29. /* -- Contributed by Fred Gustavson of the IBM Watson Research Center -- */
  30. /* -- November 2008 -- */
  31. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  32. /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
  33. /* .. Scalar Arguments .. */
  34. /* .. */
  35. /* .. Array Arguments .. */
  36. /* .. */
  37. /* Purpose */
  38. /* ======= */
  39. /* DPFTRS solves a system of linear equations A*X = B with a symmetric */
  40. /* positive definite matrix A using the Cholesky factorization */
  41. /* A = U**T*U or A = L*L**T computed by DPFTRF. */
  42. /* Arguments */
  43. /* ========= */
  44. /* TRANSR (input) CHARACTER */
  45. /* = 'N': The Normal TRANSR of RFP A is stored; */
  46. /* = 'T': The Transpose TRANSR of RFP A is stored. */
  47. /* UPLO (input) CHARACTER */
  48. /* = 'U': Upper triangle of RFP A is stored; */
  49. /* = 'L': Lower triangle of RFP A is stored. */
  50. /* N (input) INTEGER */
  51. /* The order of the matrix A. N >= 0. */
  52. /* NRHS (input) INTEGER */
  53. /* The number of right hand sides, i.e., the number of columns */
  54. /* of the matrix B. NRHS >= 0. */
  55. /* A (input) DOUBLE PRECISION array, dimension ( N*(N+1)/2 ). */
  56. /* The triangular factor U or L from the Cholesky factorization */
  57. /* of RFP A = U**T*U or RFP A = L*L**T, as computed by DPFTRF. */
  58. /* See note below for more details about RFP A. */
  59. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  60. /* On entry, the right hand side matrix B. */
  61. /* On exit, the solution matrix X. */
  62. /* LDB (input) INTEGER */
  63. /* The leading dimension of the array B. LDB >= max(1,N). */
  64. /* INFO (output) INTEGER */
  65. /* = 0: successful exit */
  66. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  67. /* Notes */
  68. /* ===== */
  69. /* We first consider Rectangular Full Packed (RFP) Format when N is */
  70. /* even. We give an example where N = 6. */
  71. /* AP is Upper AP is Lower */
  72. /* 00 01 02 03 04 05 00 */
  73. /* 11 12 13 14 15 10 11 */
  74. /* 22 23 24 25 20 21 22 */
  75. /* 33 34 35 30 31 32 33 */
  76. /* 44 45 40 41 42 43 44 */
  77. /* 55 50 51 52 53 54 55 */
  78. /* Let TRANSR = 'N'. RFP holds AP as follows: */
  79. /* For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last */
  80. /* three columns of AP upper. The lower triangle A(4:6,0:2) consists of */
  81. /* the transpose of the first three columns of AP upper. */
  82. /* For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first */
  83. /* three columns of AP lower. The upper triangle A(0:2,0:2) consists of */
  84. /* the transpose of the last three columns of AP lower. */
  85. /* This covers the case N even and TRANSR = 'N'. */
  86. /* RFP A RFP A */
  87. /* 03 04 05 33 43 53 */
  88. /* 13 14 15 00 44 54 */
  89. /* 23 24 25 10 11 55 */
  90. /* 33 34 35 20 21 22 */
  91. /* 00 44 45 30 31 32 */
  92. /* 01 11 55 40 41 42 */
  93. /* 02 12 22 50 51 52 */
  94. /* Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */
  95. /* transpose of RFP A above. One therefore gets: */
  96. /* RFP A RFP A */
  97. /* 03 13 23 33 00 01 02 33 00 10 20 30 40 50 */
  98. /* 04 14 24 34 44 11 12 43 44 11 21 31 41 51 */
  99. /* 05 15 25 35 45 55 22 53 54 55 22 32 42 52 */
  100. /* We first consider Rectangular Full Packed (RFP) Format when N is */
  101. /* odd. We give an example where N = 5. */
  102. /* AP is Upper AP is Lower */
  103. /* 00 01 02 03 04 00 */
  104. /* 11 12 13 14 10 11 */
  105. /* 22 23 24 20 21 22 */
  106. /* 33 34 30 31 32 33 */
  107. /* 44 40 41 42 43 44 */
  108. /* Let TRANSR = 'N'. RFP holds AP as follows: */
  109. /* For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last */
  110. /* three columns of AP upper. The lower triangle A(3:4,0:1) consists of */
  111. /* the transpose of the first two columns of AP upper. */
  112. /* For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first */
  113. /* three columns of AP lower. The upper triangle A(0:1,1:2) consists of */
  114. /* the transpose of the last two columns of AP lower. */
  115. /* This covers the case N odd and TRANSR = 'N'. */
  116. /* RFP A RFP A */
  117. /* 02 03 04 00 33 43 */
  118. /* 12 13 14 10 11 44 */
  119. /* 22 23 24 20 21 22 */
  120. /* 00 33 34 30 31 32 */
  121. /* 01 11 44 40 41 42 */
  122. /* Now let TRANSR = 'T'. RFP A in both UPLO cases is just the */
  123. /* transpose of RFP A above. One therefore gets: */
  124. /* RFP A RFP A */
  125. /* 02 12 22 00 01 00 10 20 30 40 50 */
  126. /* 03 13 23 33 11 33 11 21 31 41 51 */
  127. /* 04 14 24 34 44 43 44 22 32 42 52 */
  128. /* ===================================================================== */
  129. /* .. Parameters .. */
  130. /* .. */
  131. /* .. Local Scalars .. */
  132. /* .. */
  133. /* .. External Functions .. */
  134. /* .. */
  135. /* .. External Subroutines .. */
  136. /* .. */
  137. /* .. Intrinsic Functions .. */
  138. /* .. */
  139. /* .. Executable Statements .. */
  140. /* Test the input parameters. */
  141. /* Parameter adjustments */
  142. b_dim1 = *ldb;
  143. b_offset = 1 + b_dim1;
  144. b -= b_offset;
  145. /* Function Body */
  146. *info = 0;
  147. normaltransr = _starpu_lsame_(transr, "N");
  148. lower = _starpu_lsame_(uplo, "L");
  149. if (! normaltransr && ! _starpu_lsame_(transr, "T")) {
  150. *info = -1;
  151. } else if (! lower && ! _starpu_lsame_(uplo, "U")) {
  152. *info = -2;
  153. } else if (*n < 0) {
  154. *info = -3;
  155. } else if (*nrhs < 0) {
  156. *info = -4;
  157. } else if (*ldb < max(1,*n)) {
  158. *info = -7;
  159. }
  160. if (*info != 0) {
  161. i__1 = -(*info);
  162. _starpu_xerbla_("DPFTRS", &i__1);
  163. return 0;
  164. }
  165. /* Quick return if possible */
  166. if (*n == 0 || *nrhs == 0) {
  167. return 0;
  168. }
  169. /* start execution: there are two triangular solves */
  170. if (lower) {
  171. _starpu_dtfsm_(transr, "L", uplo, "N", "N", n, nrhs, &c_b10, a, &b[b_offset],
  172. ldb);
  173. _starpu_dtfsm_(transr, "L", uplo, "T", "N", n, nrhs, &c_b10, a, &b[b_offset],
  174. ldb);
  175. } else {
  176. _starpu_dtfsm_(transr, "L", uplo, "T", "N", n, nrhs, &c_b10, a, &b[b_offset],
  177. ldb);
  178. _starpu_dtfsm_(transr, "L", uplo, "N", "N", n, nrhs, &c_b10, a, &b[b_offset],
  179. ldb);
  180. }
  181. return 0;
  182. /* End of DPFTRS */
  183. } /* _starpu_dpftrs_ */