dpotrs.c 4.6 KB

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