dla_lin_berr.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* _starpu_dla_lin_berr.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_dla_lin_berr__(integer *n, integer *nz, integer *nrhs,
  14. doublereal *res, doublereal *ayb, doublereal *berr)
  15. {
  16. /* System generated locals */
  17. integer ayb_dim1, ayb_offset, res_dim1, res_offset, i__1, i__2;
  18. doublereal d__1;
  19. /* Local variables */
  20. integer i__, j;
  21. doublereal tmp, safe1;
  22. extern doublereal _starpu_dlamch_(char *);
  23. /* -- LAPACK routine (version 3.2.1) -- */
  24. /* -- Contributed by James Demmel, Deaglan Halligan, Yozo Hida and -- */
  25. /* -- Jason Riedy of Univ. of California Berkeley. -- */
  26. /* -- April 2009 -- */
  27. /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
  28. /* -- Univ. of California Berkeley and NAG Ltd. -- */
  29. /* .. */
  30. /* .. Scalar Arguments .. */
  31. /* .. */
  32. /* .. Array Arguments .. */
  33. /* .. */
  34. /* Purpose */
  35. /* ======= */
  36. /* DLA_LIN_BERR computes componentwise relative backward error from */
  37. /* the formula */
  38. /* max(i) ( abs(R(i)) / ( abs(op(A_s))*abs(Y) + abs(B_s) )(i) ) */
  39. /* where abs(Z) is the componentwise absolute value of the matrix */
  40. /* or vector Z. */
  41. /* Arguments */
  42. /* ========== */
  43. /* N (input) INTEGER */
  44. /* The number of linear equations, i.e., the order of the */
  45. /* matrix A. N >= 0. */
  46. /* NZ (input) INTEGER */
  47. /* We add (NZ+1)*SLAMCH( 'Safe minimum' ) to R(i) in the numerator to */
  48. /* guard against spuriously zero residuals. Default value is N. */
  49. /* NRHS (input) INTEGER */
  50. /* The number of right hand sides, i.e., the number of columns */
  51. /* of the matrices AYB, RES, and BERR. NRHS >= 0. */
  52. /* RES (input) DOUBLE PRECISION array, dimension (N,NRHS) */
  53. /* The residual matrix, i.e., the matrix R in the relative backward */
  54. /* error formula above. */
  55. /* AYB (input) DOUBLE PRECISION array, dimension (N, NRHS) */
  56. /* The denominator in the relative backward error formula above, i.e., */
  57. /* the matrix abs(op(A_s))*abs(Y) + abs(B_s). The matrices A, Y, and B */
  58. /* are from iterative refinement (see _starpu_dla_gerfsx_extended.f). */
  59. /* RES (output) DOUBLE PRECISION array, dimension (NRHS) */
  60. /* The componentwise relative backward error from the formula above. */
  61. /* ===================================================================== */
  62. /* .. Local Scalars .. */
  63. /* .. */
  64. /* .. Intrinsic Functions .. */
  65. /* .. */
  66. /* .. External Functions .. */
  67. /* .. */
  68. /* .. Executable Statements .. */
  69. /* Adding SAFE1 to the numerator guards against spuriously zero */
  70. /* residuals. A similar safeguard is in the SLA_yyAMV routine used */
  71. /* to compute AYB. */
  72. /* Parameter adjustments */
  73. --berr;
  74. ayb_dim1 = *n;
  75. ayb_offset = 1 + ayb_dim1;
  76. ayb -= ayb_offset;
  77. res_dim1 = *n;
  78. res_offset = 1 + res_dim1;
  79. res -= res_offset;
  80. /* Function Body */
  81. safe1 = _starpu_dlamch_("Safe minimum");
  82. safe1 = (*nz + 1) * safe1;
  83. i__1 = *nrhs;
  84. for (j = 1; j <= i__1; ++j) {
  85. berr[j] = 0.;
  86. i__2 = *n;
  87. for (i__ = 1; i__ <= i__2; ++i__) {
  88. if (ayb[i__ + j * ayb_dim1] != 0.) {
  89. tmp = (safe1 + (d__1 = res[i__ + j * res_dim1], abs(d__1))) /
  90. ayb[i__ + j * ayb_dim1];
  91. /* Computing MAX */
  92. d__1 = berr[j];
  93. berr[j] = max(d__1,tmp);
  94. }
  95. /* If AYB is exactly 0.0 (and if computed by SLA_yyAMV), then we know */
  96. /* the true residual also must be exactly 0.0. */
  97. }
  98. }
  99. return 0;
  100. } /* _starpu_dla_lin_berr__ */