ieeeck.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* ieeeck.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. integer _starpu_ieeeck_(integer *ispec, real *zero, real *one)
  14. {
  15. /* System generated locals */
  16. integer ret_val;
  17. /* Local variables */
  18. real nan1, nan2, nan3, nan4, nan5, nan6, neginf, posinf, negzro, newzro;
  19. /* -- LAPACK auxiliary routine (version 3.2) -- */
  20. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  21. /* November 2006 */
  22. /* .. Scalar Arguments .. */
  23. /* .. */
  24. /* Purpose */
  25. /* ======= */
  26. /* IEEECK is called from the ILAENV to verify that Infinity and */
  27. /* possibly NaN arithmetic is safe (i.e. will not trap). */
  28. /* Arguments */
  29. /* ========= */
  30. /* ISPEC (input) INTEGER */
  31. /* Specifies whether to test just for inifinity arithmetic */
  32. /* or whether to test for infinity and NaN arithmetic. */
  33. /* = 0: Verify infinity arithmetic only. */
  34. /* = 1: Verify infinity and NaN arithmetic. */
  35. /* ZERO (input) REAL */
  36. /* Must contain the value 0.0 */
  37. /* This is passed to prevent the compiler from optimizing */
  38. /* away this code. */
  39. /* ONE (input) REAL */
  40. /* Must contain the value 1.0 */
  41. /* This is passed to prevent the compiler from optimizing */
  42. /* away this code. */
  43. /* RETURN VALUE: INTEGER */
  44. /* = 0: Arithmetic failed to produce the correct answers */
  45. /* = 1: Arithmetic produced the correct answers */
  46. /* .. Local Scalars .. */
  47. /* .. */
  48. /* .. Executable Statements .. */
  49. ret_val = 1;
  50. posinf = *one / *zero;
  51. if (posinf <= *one) {
  52. ret_val = 0;
  53. return ret_val;
  54. }
  55. neginf = -(*one) / *zero;
  56. if (neginf >= *zero) {
  57. ret_val = 0;
  58. return ret_val;
  59. }
  60. negzro = *one / (neginf + *one);
  61. if (negzro != *zero) {
  62. ret_val = 0;
  63. return ret_val;
  64. }
  65. neginf = *one / negzro;
  66. if (neginf >= *zero) {
  67. ret_val = 0;
  68. return ret_val;
  69. }
  70. newzro = negzro + *zero;
  71. if (newzro != *zero) {
  72. ret_val = 0;
  73. return ret_val;
  74. }
  75. posinf = *one / newzro;
  76. if (posinf <= *one) {
  77. ret_val = 0;
  78. return ret_val;
  79. }
  80. neginf *= posinf;
  81. if (neginf >= *zero) {
  82. ret_val = 0;
  83. return ret_val;
  84. }
  85. posinf *= posinf;
  86. if (posinf <= *one) {
  87. ret_val = 0;
  88. return ret_val;
  89. }
  90. /* Return if we were only asked to check infinity arithmetic */
  91. if (*ispec == 0) {
  92. return ret_val;
  93. }
  94. nan1 = posinf + neginf;
  95. nan2 = posinf / neginf;
  96. nan3 = posinf / posinf;
  97. nan4 = posinf * *zero;
  98. nan5 = neginf * negzro;
  99. nan6 = nan5 * 0.f;
  100. if (nan1 == nan1) {
  101. ret_val = 0;
  102. return ret_val;
  103. }
  104. if (nan2 == nan2) {
  105. ret_val = 0;
  106. return ret_val;
  107. }
  108. if (nan3 == nan3) {
  109. ret_val = 0;
  110. return ret_val;
  111. }
  112. if (nan4 == nan4) {
  113. ret_val = 0;
  114. return ret_val;
  115. }
  116. if (nan5 == nan5) {
  117. ret_val = 0;
  118. return ret_val;
  119. }
  120. if (nan6 == nan6) {
  121. ret_val = 0;
  122. return ret_val;
  123. }
  124. return ret_val;
  125. } /* _starpu_ieeeck_ */