dspsv.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* dspsv.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. /* Subroutine */ int _starpu_dspsv_(char *uplo, integer *n, integer *nrhs, doublereal
  14. *ap, integer *ipiv, doublereal *b, integer *ldb, integer *info)
  15. {
  16. /* System generated locals */
  17. integer b_dim1, b_offset, i__1;
  18. /* Local variables */
  19. extern logical _starpu_lsame_(char *, char *);
  20. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *), _starpu_dsptrf_(
  21. char *, integer *, doublereal *, integer *, integer *),
  22. _starpu_dsptrs_(char *, integer *, integer *, doublereal *, integer *,
  23. doublereal *, integer *, integer *);
  24. /* -- LAPACK driver routine (version 3.2) -- */
  25. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  26. /* November 2006 */
  27. /* .. Scalar Arguments .. */
  28. /* .. */
  29. /* .. Array Arguments .. */
  30. /* .. */
  31. /* Purpose */
  32. /* ======= */
  33. /* DSPSV computes the solution to a real system of linear equations */
  34. /* A * X = B, */
  35. /* where A is an N-by-N symmetric matrix stored in packed format and X */
  36. /* and B are N-by-NRHS matrices. */
  37. /* The diagonal pivoting method is used to factor A as */
  38. /* A = U * D * U**T, if UPLO = 'U', or */
  39. /* A = L * D * L**T, if UPLO = 'L', */
  40. /* where U (or L) is a product of permutation and unit upper (lower) */
  41. /* triangular matrices, D is symmetric and block diagonal with 1-by-1 */
  42. /* and 2-by-2 diagonal blocks. The factored form of A is then used to */
  43. /* solve the system of equations A * X = B. */
  44. /* Arguments */
  45. /* ========= */
  46. /* UPLO (input) CHARACTER*1 */
  47. /* = 'U': Upper triangle of A is stored; */
  48. /* = 'L': Lower triangle of A is stored. */
  49. /* N (input) INTEGER */
  50. /* The number of linear equations, i.e., the order of the */
  51. /* 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. /* AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
  56. /* On entry, the upper or lower triangle of the symmetric matrix */
  57. /* A, packed columnwise in a linear array. The j-th column of A */
  58. /* is stored in the array AP as follows: */
  59. /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */
  60. /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n. */
  61. /* See below for further details. */
  62. /* On exit, the block diagonal matrix D and the multipliers used */
  63. /* to obtain the factor U or L from the factorization */
  64. /* A = U*D*U**T or A = L*D*L**T as computed by DSPTRF, stored as */
  65. /* a packed triangular matrix in the same storage format as A. */
  66. /* IPIV (output) INTEGER array, dimension (N) */
  67. /* Details of the interchanges and the block structure of D, as */
  68. /* determined by DSPTRF. If IPIV(k) > 0, then rows and columns */
  69. /* k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1 */
  70. /* diagonal block. If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, */
  71. /* then rows and columns k-1 and -IPIV(k) were interchanged and */
  72. /* D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If UPLO = 'L' and */
  73. /* IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and */
  74. /* -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2 */
  75. /* diagonal block. */
  76. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  77. /* On entry, the N-by-NRHS right hand side matrix B. */
  78. /* On exit, if INFO = 0, the N-by-NRHS solution matrix X. */
  79. /* LDB (input) INTEGER */
  80. /* The leading dimension of the array B. LDB >= max(1,N). */
  81. /* INFO (output) INTEGER */
  82. /* = 0: successful exit */
  83. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  84. /* > 0: if INFO = i, D(i,i) is exactly zero. The factorization */
  85. /* has been completed, but the block diagonal matrix D is */
  86. /* exactly singular, so the solution could not be */
  87. /* computed. */
  88. /* Further Details */
  89. /* =============== */
  90. /* The packed storage scheme is illustrated by the following example */
  91. /* when N = 4, UPLO = 'U': */
  92. /* Two-dimensional storage of the symmetric matrix A: */
  93. /* a11 a12 a13 a14 */
  94. /* a22 a23 a24 */
  95. /* a33 a34 (aij = aji) */
  96. /* a44 */
  97. /* Packed storage of the upper triangle of A: */
  98. /* AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ] */
  99. /* ===================================================================== */
  100. /* .. External Functions .. */
  101. /* .. */
  102. /* .. External Subroutines .. */
  103. /* .. */
  104. /* .. Intrinsic Functions .. */
  105. /* .. */
  106. /* .. Executable Statements .. */
  107. /* Test the input parameters. */
  108. /* Parameter adjustments */
  109. --ap;
  110. --ipiv;
  111. b_dim1 = *ldb;
  112. b_offset = 1 + b_dim1;
  113. b -= b_offset;
  114. /* Function Body */
  115. *info = 0;
  116. if (! _starpu_lsame_(uplo, "U") && ! _starpu_lsame_(uplo, "L")) {
  117. *info = -1;
  118. } else if (*n < 0) {
  119. *info = -2;
  120. } else if (*nrhs < 0) {
  121. *info = -3;
  122. } else if (*ldb < max(1,*n)) {
  123. *info = -7;
  124. }
  125. if (*info != 0) {
  126. i__1 = -(*info);
  127. _starpu_xerbla_("DSPSV ", &i__1);
  128. return 0;
  129. }
  130. /* Compute the factorization A = U*D*U' or A = L*D*L'. */
  131. _starpu_dsptrf_(uplo, n, &ap[1], &ipiv[1], info);
  132. if (*info == 0) {
  133. /* Solve the system A*X = B, overwriting B with X. */
  134. _starpu_dsptrs_(uplo, n, nrhs, &ap[1], &ipiv[1], &b[b_offset], ldb, info);
  135. }
  136. return 0;
  137. /* End of DSPSV */
  138. } /* _starpu_dspsv_ */