The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

146 lines
4.2 KiB

2 months ago
  1. /**
  2. @file
  3. @ingroup epd
  4. @brief Internal header for the University of Colorado extended
  5. double precision package.
  6. @author In-Ho Moon
  7. @copyright@parblock
  8. Copyright (c) 1995-2015, Regents of the University of Colorado
  9. All rights reserved.
  10. Redistribution and use in source and binary forms, with or without
  11. modification, are permitted provided that the following conditions
  12. are met:
  13. Redistributions of source code must retain the above copyright
  14. notice, this list of conditions and the following disclaimer.
  15. Redistributions in binary form must reproduce the above copyright
  16. notice, this list of conditions and the following disclaimer in the
  17. documentation and/or other materials provided with the distribution.
  18. Neither the name of the University of Colorado nor the names of its
  19. contributors may be used to endorse or promote products derived from
  20. this software without specific prior written permission.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  28. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. POSSIBILITY OF SUCH DAMAGE.
  33. @endparblock
  34. */
  35. #ifndef EPD_INT_H_
  36. #define EPD_INT_H_
  37. #include "config.h"
  38. #include "epd.h"
  39. #if WORDS_BIGENDIAN == 1
  40. #define EPD_BIG_ENDIAN
  41. #endif
  42. /*---------------------------------------------------------------------------*/
  43. /* Constant declarations */
  44. /*---------------------------------------------------------------------------*/
  45. #define EPD_MAX_BIN 1023
  46. #define EPD_MAX_DEC 308
  47. #define EPD_EXP_INF 0x7ff
  48. /*---------------------------------------------------------------------------*/
  49. /* Type declarations */
  50. /*---------------------------------------------------------------------------*/
  51. typedef struct IeeeDoubleStruct IeeeDouble;
  52. typedef struct IeeeNanStruct IeeeNan;
  53. typedef union EpTypeUnion EpType;
  54. /*---------------------------------------------------------------------------*/
  55. /* Structure declarations */
  56. /*---------------------------------------------------------------------------*/
  57. /**
  58. @brief IEEE double struct.
  59. */
  60. #ifdef EPD_BIG_ENDIAN
  61. struct IeeeDoubleStruct { /* BIG_ENDIAN */
  62. unsigned int sign: 1;
  63. unsigned int exponent: 11;
  64. unsigned int mantissa0: 20;
  65. unsigned int mantissa1: 32;
  66. };
  67. #else
  68. struct IeeeDoubleStruct { /* LITTLE_ENDIAN */
  69. unsigned int mantissa1: 32;
  70. unsigned int mantissa0: 20;
  71. unsigned int exponent: 11;
  72. unsigned int sign: 1;
  73. };
  74. #endif
  75. /**
  76. @brief IEEE double NaN struct.
  77. */
  78. #ifdef EPD_BIG_ENDIAN
  79. struct IeeeNanStruct { /* BIG_ENDIAN */
  80. unsigned int sign: 1;
  81. unsigned int exponent: 11;
  82. unsigned int quiet_bit: 1;
  83. unsigned int mantissa0: 19;
  84. unsigned int mantissa1: 32;
  85. };
  86. #else
  87. struct IeeeNanStruct { /* LITTLE_ENDIAN */
  88. unsigned int mantissa1: 32;
  89. unsigned int mantissa0: 19;
  90. unsigned int quiet_bit: 1;
  91. unsigned int exponent: 11;
  92. unsigned int sign: 1;
  93. };
  94. #endif
  95. /**
  96. @brief Different views of a double.
  97. */
  98. union EpTypeUnion {
  99. double value;
  100. struct IeeeDoubleStruct bits;
  101. struct IeeeNanStruct nan;
  102. };
  103. /**
  104. @brief Extended precision double to keep very large value.
  105. */
  106. struct EpDoubleStruct {
  107. union EpTypeUnion type;
  108. int exponent;
  109. };
  110. /*---------------------------------------------------------------------------*/
  111. /* Function prototypes */
  112. /*---------------------------------------------------------------------------*/
  113. #ifdef __cplusplus
  114. extern "C" {
  115. #endif
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119. #endif /* EPD_H_ */