You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

droundup_lwork.f 2.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. *> \brief \b DROUNDUP_LWORK
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * DOUBLE PRECISION FUNCTION DROUNDUP_LWORK( LWORK )
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER LWORK
  15. * ..
  16. *
  17. *
  18. *> \par Purpose:
  19. * =============
  20. *>
  21. *> \verbatim
  22. *>
  23. *> DROUNDUP_LWORK deals with a subtle bug with returning LWORK as a Float.
  24. *> This routine guarantees it is rounded up instead of down by
  25. *> multiplying LWORK by 1+eps when it is necessary, where eps is the relative machine precision.
  26. *> E.g.,
  27. *>
  28. *> float( 9007199254740993 ) == 9007199254740992
  29. *> float( 9007199254740993 ) * (1.+eps) == 9007199254740994
  30. *>
  31. *> \return DROUNDUP_LWORK
  32. *> \verbatim
  33. *> DROUNDUP_LWORK >= LWORK.
  34. *> DROUNDUP_LWORK is guaranteed to have zero decimal part.
  35. *> \endverbatim
  36. *
  37. * Arguments:
  38. * ==========
  39. *
  40. *> \param[in] LWORK Workspace size.
  41. *
  42. * Authors:
  43. * ========
  44. *
  45. *> \author Weslley Pereira, University of Colorado Denver, USA
  46. *
  47. *> \ingroup auxOTHERauxiliary
  48. *
  49. *> \par Further Details:
  50. * =====================
  51. *>
  52. *> \verbatim
  53. *> This routine was inspired in the method `magma_zmake_lwork` from MAGMA.
  54. *> \see https://bitbucket.org/icl/magma/src/master/control/magma_zauxiliary.cpp
  55. *> \endverbatim
  56. *
  57. * =====================================================================
  58. DOUBLE PRECISION FUNCTION DROUNDUP_LWORK( LWORK )
  59. *
  60. * -- LAPACK auxiliary routine --
  61. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  62. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  63. *
  64. * .. Scalar Arguments ..
  65. INTEGER LWORK
  66. * ..
  67. *
  68. * =====================================================================
  69. * ..
  70. * .. Intrinsic Functions ..
  71. INTRINSIC EPSILON, DBLE, INT
  72. * ..
  73. * .. Executable Statements ..
  74. * ..
  75. DROUNDUP_LWORK = DBLE( LWORK )
  76. *
  77. IF( INT( DROUNDUP_LWORK ) .LT. LWORK ) THEN
  78. * Force round up of LWORK
  79. DROUNDUP_LWORK = DROUNDUP_LWORK * ( 1.0D+0 + EPSILON(0.0D+0) )
  80. ENDIF
  81. *
  82. RETURN
  83. *
  84. * End of DROUNDUP_LWORK
  85. *
  86. END