dsysv.c 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /* dsysv.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. static integer c_n1 = -1;
  16. /* Subroutine */ int _starpu_dsysv_(char *uplo, integer *n, integer *nrhs, doublereal
  17. *a, integer *lda, integer *ipiv, doublereal *b, integer *ldb,
  18. doublereal *work, integer *lwork, integer *info)
  19. {
  20. /* System generated locals */
  21. integer a_dim1, a_offset, b_dim1, b_offset, i__1;
  22. /* Local variables */
  23. integer nb;
  24. extern logical _starpu_lsame_(char *, char *);
  25. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  26. extern integer _starpu_ilaenv_(integer *, char *, char *, integer *, integer *,
  27. integer *, integer *);
  28. extern /* Subroutine */ int _starpu_dsytrf_(char *, integer *, doublereal *,
  29. integer *, integer *, doublereal *, integer *, integer *);
  30. integer lwkopt;
  31. logical lquery;
  32. extern /* Subroutine */ int _starpu_dsytrs_(char *, integer *, integer *,
  33. doublereal *, integer *, integer *, doublereal *, integer *,
  34. integer *);
  35. /* -- LAPACK driver routine (version 3.2) -- */
  36. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  37. /* November 2006 */
  38. /* .. Scalar Arguments .. */
  39. /* .. */
  40. /* .. Array Arguments .. */
  41. /* .. */
  42. /* Purpose */
  43. /* ======= */
  44. /* DSYSV computes the solution to a real system of linear equations */
  45. /* A * X = B, */
  46. /* where A is an N-by-N symmetric matrix and X and B are N-by-NRHS */
  47. /* matrices. */
  48. /* The diagonal pivoting method is used to factor A as */
  49. /* A = U * D * U**T, if UPLO = 'U', or */
  50. /* A = L * D * L**T, if UPLO = 'L', */
  51. /* where U (or L) is a product of permutation and unit upper (lower) */
  52. /* triangular matrices, and D is symmetric and block diagonal with */
  53. /* 1-by-1 and 2-by-2 diagonal blocks. The factored form of A is then */
  54. /* used to solve the system of equations A * X = B. */
  55. /* Arguments */
  56. /* ========= */
  57. /* UPLO (input) CHARACTER*1 */
  58. /* = 'U': Upper triangle of A is stored; */
  59. /* = 'L': Lower triangle of A is stored. */
  60. /* N (input) INTEGER */
  61. /* The number of linear equations, i.e., the order of the */
  62. /* matrix A. N >= 0. */
  63. /* NRHS (input) INTEGER */
  64. /* The number of right hand sides, i.e., the number of columns */
  65. /* of the matrix B. NRHS >= 0. */
  66. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  67. /* On entry, the symmetric matrix A. If UPLO = 'U', the leading */
  68. /* N-by-N upper triangular part of A contains the upper */
  69. /* triangular part of the matrix A, and the strictly lower */
  70. /* triangular part of A is not referenced. If UPLO = 'L', the */
  71. /* leading N-by-N lower triangular part of A contains the lower */
  72. /* triangular part of the matrix A, and the strictly upper */
  73. /* triangular part of A is not referenced. */
  74. /* On exit, if INFO = 0, the block diagonal matrix D and the */
  75. /* multipliers used to obtain the factor U or L from the */
  76. /* factorization A = U*D*U**T or A = L*D*L**T as computed by */
  77. /* DSYTRF. */
  78. /* LDA (input) INTEGER */
  79. /* The leading dimension of the array A. LDA >= max(1,N). */
  80. /* IPIV (output) INTEGER array, dimension (N) */
  81. /* Details of the interchanges and the block structure of D, as */
  82. /* determined by DSYTRF. If IPIV(k) > 0, then rows and columns */
  83. /* k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1 */
  84. /* diagonal block. If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, */
  85. /* then rows and columns k-1 and -IPIV(k) were interchanged and */
  86. /* D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If UPLO = 'L' and */
  87. /* IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and */
  88. /* -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2 */
  89. /* diagonal block. */
  90. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  91. /* On entry, the N-by-NRHS right hand side matrix B. */
  92. /* On exit, if INFO = 0, the N-by-NRHS solution matrix X. */
  93. /* LDB (input) INTEGER */
  94. /* The leading dimension of the array B. LDB >= max(1,N). */
  95. /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
  96. /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
  97. /* LWORK (input) INTEGER */
  98. /* The length of WORK. LWORK >= 1, and for best performance */
  99. /* LWORK >= max(1,N*NB), where NB is the optimal blocksize for */
  100. /* DSYTRF. */
  101. /* If LWORK = -1, then a workspace query is assumed; the routine */
  102. /* only calculates the optimal size of the WORK array, returns */
  103. /* this value as the first entry of the WORK array, and no error */
  104. /* message related to LWORK is issued by XERBLA. */
  105. /* INFO (output) INTEGER */
  106. /* = 0: successful exit */
  107. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  108. /* > 0: if INFO = i, D(i,i) is exactly zero. The factorization */
  109. /* has been completed, but the block diagonal matrix D is */
  110. /* exactly singular, so the solution could not be computed. */
  111. /* ===================================================================== */
  112. /* .. Local Scalars .. */
  113. /* .. */
  114. /* .. External Functions .. */
  115. /* .. */
  116. /* .. External Subroutines .. */
  117. /* .. */
  118. /* .. Intrinsic Functions .. */
  119. /* .. */
  120. /* .. Executable Statements .. */
  121. /* Test the input parameters. */
  122. /* Parameter adjustments */
  123. a_dim1 = *lda;
  124. a_offset = 1 + a_dim1;
  125. a -= a_offset;
  126. --ipiv;
  127. b_dim1 = *ldb;
  128. b_offset = 1 + b_dim1;
  129. b -= b_offset;
  130. --work;
  131. /* Function Body */
  132. *info = 0;
  133. lquery = *lwork == -1;
  134. if (! _starpu_lsame_(uplo, "U") && ! _starpu_lsame_(uplo, "L")) {
  135. *info = -1;
  136. } else if (*n < 0) {
  137. *info = -2;
  138. } else if (*nrhs < 0) {
  139. *info = -3;
  140. } else if (*lda < max(1,*n)) {
  141. *info = -5;
  142. } else if (*ldb < max(1,*n)) {
  143. *info = -8;
  144. } else if (*lwork < 1 && ! lquery) {
  145. *info = -10;
  146. }
  147. if (*info == 0) {
  148. if (*n == 0) {
  149. lwkopt = 1;
  150. } else {
  151. nb = _starpu_ilaenv_(&c__1, "DSYTRF", uplo, n, &c_n1, &c_n1, &c_n1);
  152. lwkopt = *n * nb;
  153. }
  154. work[1] = (doublereal) lwkopt;
  155. }
  156. if (*info != 0) {
  157. i__1 = -(*info);
  158. _starpu_xerbla_("DSYSV ", &i__1);
  159. return 0;
  160. } else if (lquery) {
  161. return 0;
  162. }
  163. /* Compute the factorization A = U*D*U' or A = L*D*L'. */
  164. _starpu_dsytrf_(uplo, n, &a[a_offset], lda, &ipiv[1], &work[1], lwork, info);
  165. if (*info == 0) {
  166. /* Solve the system A*X = B, overwriting B with X. */
  167. _starpu_dsytrs_(uplo, n, nrhs, &a[a_offset], lda, &ipiv[1], &b[b_offset], ldb,
  168. info);
  169. }
  170. work[1] = (doublereal) lwkopt;
  171. return 0;
  172. /* End of DSYSV */
  173. } /* _starpu_dsysv_ */