dpptri.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* dpptri.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_b8 = 1.;
  15. static integer c__1 = 1;
  16. /* Subroutine */ int _starpu_dpptri_(char *uplo, integer *n, doublereal *ap, integer *
  17. info)
  18. {
  19. /* System generated locals */
  20. integer i__1, i__2;
  21. /* Local variables */
  22. integer j, jc, jj;
  23. doublereal ajj;
  24. integer jjn;
  25. extern doublereal _starpu_ddot_(integer *, doublereal *, integer *, doublereal *,
  26. integer *);
  27. extern /* Subroutine */ int _starpu_dspr_(char *, integer *, doublereal *,
  28. doublereal *, integer *, doublereal *), _starpu_dscal_(integer *,
  29. doublereal *, doublereal *, integer *);
  30. extern logical _starpu_lsame_(char *, char *);
  31. extern /* Subroutine */ int _starpu_dtpmv_(char *, char *, char *, integer *,
  32. doublereal *, doublereal *, integer *);
  33. logical upper;
  34. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *), _starpu_dtptri_(
  35. char *, char *, integer *, doublereal *, integer *);
  36. /* -- LAPACK routine (version 3.2) -- */
  37. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  38. /* November 2006 */
  39. /* .. Scalar Arguments .. */
  40. /* .. */
  41. /* .. Array Arguments .. */
  42. /* .. */
  43. /* Purpose */
  44. /* ======= */
  45. /* DPPTRI computes the inverse of a real symmetric positive definite */
  46. /* matrix A using the Cholesky factorization A = U**T*U or A = L*L**T */
  47. /* computed by DPPTRF. */
  48. /* Arguments */
  49. /* ========= */
  50. /* UPLO (input) CHARACTER*1 */
  51. /* = 'U': Upper triangular factor is stored in AP; */
  52. /* = 'L': Lower triangular factor is stored in AP. */
  53. /* N (input) INTEGER */
  54. /* The order of the matrix A. N >= 0. */
  55. /* AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
  56. /* On entry, the triangular factor U or L from the Cholesky */
  57. /* factorization A = U**T*U or A = L*L**T, packed columnwise as */
  58. /* a linear array. The j-th column of U or L is stored in the */
  59. /* array AP as follows: */
  60. /* if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j; */
  61. /* if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n. */
  62. /* On exit, the upper or lower triangle of the (symmetric) */
  63. /* inverse of A, overwriting the input factor U or L. */
  64. /* INFO (output) INTEGER */
  65. /* = 0: successful exit */
  66. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  67. /* > 0: if INFO = i, the (i,i) element of the factor U or L is */
  68. /* zero, and the inverse could not be computed. */
  69. /* ===================================================================== */
  70. /* .. Parameters .. */
  71. /* .. */
  72. /* .. Local Scalars .. */
  73. /* .. */
  74. /* .. External Functions .. */
  75. /* .. */
  76. /* .. External Subroutines .. */
  77. /* .. */
  78. /* .. Executable Statements .. */
  79. /* Test the input parameters. */
  80. /* Parameter adjustments */
  81. --ap;
  82. /* Function Body */
  83. *info = 0;
  84. upper = _starpu_lsame_(uplo, "U");
  85. if (! upper && ! _starpu_lsame_(uplo, "L")) {
  86. *info = -1;
  87. } else if (*n < 0) {
  88. *info = -2;
  89. }
  90. if (*info != 0) {
  91. i__1 = -(*info);
  92. _starpu_xerbla_("DPPTRI", &i__1);
  93. return 0;
  94. }
  95. /* Quick return if possible */
  96. if (*n == 0) {
  97. return 0;
  98. }
  99. /* Invert the triangular Cholesky factor U or L. */
  100. _starpu_dtptri_(uplo, "Non-unit", n, &ap[1], info);
  101. if (*info > 0) {
  102. return 0;
  103. }
  104. if (upper) {
  105. /* Compute the product inv(U) * inv(U)'. */
  106. jj = 0;
  107. i__1 = *n;
  108. for (j = 1; j <= i__1; ++j) {
  109. jc = jj + 1;
  110. jj += j;
  111. if (j > 1) {
  112. i__2 = j - 1;
  113. _starpu_dspr_("Upper", &i__2, &c_b8, &ap[jc], &c__1, &ap[1]);
  114. }
  115. ajj = ap[jj];
  116. _starpu_dscal_(&j, &ajj, &ap[jc], &c__1);
  117. /* L10: */
  118. }
  119. } else {
  120. /* Compute the product inv(L)' * inv(L). */
  121. jj = 1;
  122. i__1 = *n;
  123. for (j = 1; j <= i__1; ++j) {
  124. jjn = jj + *n - j + 1;
  125. i__2 = *n - j + 1;
  126. ap[jj] = _starpu_ddot_(&i__2, &ap[jj], &c__1, &ap[jj], &c__1);
  127. if (j < *n) {
  128. i__2 = *n - j;
  129. _starpu_dtpmv_("Lower", "Transpose", "Non-unit", &i__2, &ap[jjn], &ap[
  130. jj + 1], &c__1);
  131. }
  132. jj = jjn;
  133. /* L20: */
  134. }
  135. }
  136. return 0;
  137. /* End of DPPTRI */
  138. } /* _starpu_dpptri_ */