Skip to content

Commit 6a77dd9

Browse files
committed
header updates
1 parent 679b788 commit 6a77dd9

25 files changed

+251
-108
lines changed

include/universal/math/math.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
|---------------|-------------|
66
| abs ( ) | absolute value of an integer. The absolute value of a number is always positive. Only integer values are supported in C. |
77
| floor ( ) | nearest integer which is less than or equal to the argument passed to this function. |
8-
| round ( ) | nearest integer value of the float/double/long double argument passed to this function. If decimal value is from “.1 to .5”, it returns integer value less than the argument. If decimal value is from “.6 to .9”, it returns the integer value greater than the argument. |
98
| ceil ( ) | return nearest integer value which is greater than or equal to the argument passed to this function. |
9+
| round ( ) | nearest integer value of the float/double/long double argument passed to this function. If decimal value is from “.1 to .5”, it returns integer value less than the argument. If decimal value is from “.6 to .9”, it returns the integer value greater than the argument. |
1010
| sin ( ) | return sine value. |
1111
| cos ( ) | return cosine. |
1212
| cosh ( ) | return hyperbolic cosine. |

include/universal/math/math_constants.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// math_constants.hpp: definition of math constants
33
//
44
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/math_functions.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// math_functions.hpp: definition of universal mathematical functions
33
//
4-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/math include/universal/math/mathlib_shim.hpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
// <universal/math/math>: standard header of the universal math library shim layer
2-
// which injects the standard math library functions for native IEEE-754 types into the sw::universal namespace.
1+
// <universal/math/mathlib.hpp>: standard header of the universal math library shim layer
2+
// which injects the standard math library functions for native IEEE-754 types into
3+
// the sw::universal namespace.
4+
//
35
// For example, std::abs(float) is shimmed to
46
// template<typename NativeFloat> sw::universal::abs(NativeFloat)
57
//
6-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
8+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
9+
// SPDX-License-Identifier: MIT
710
//
811
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
9-
#ifndef _UNIVERSAL_MATH_STANDARD_HEADER_
10-
#define _UNIVERSAL_MATH_STANDARD_HEADER_
12+
#ifndef _UNIVERSAL_MATHLIB_STANDARD_HEADER_
13+
#define _UNIVERSAL_MATHLIB_STANDARD_HEADER_
1114

1215
////////////////////////////////////////////////////////////////////////////////////////
1316
/// BEHAVIORAL COMPILATION SWITCHES

include/universal/math/stub/abs.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// abs.hpp: templated abs function stub for native floating-point
33
//
4-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/classify.hpp

-27
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,6 @@ namespace sw { namespace universal {
6969
#elif defined(_MSC_VER)
7070
/* Microsoft Visual Studio. --------------------------------- */
7171

72-
// STD LIB function for IEEE floats: Categorizes floating point value arg into the following categories: zero, subnormal, normal, infinite, NAN, or implementation-defined category.
73-
template<typename Scalar,
74-
typename = typename std::enable_if<std::is_floating_point<Scalar>::value, Scalar>::type>
75-
int fpclassify(const Scalar& v) {
76-
return std::fpclassify(v);
77-
}
78-
79-
// STD LIB function for IEEE floats:
80-
template<typename Scalar,
81-
typename = typename std::enable_if<std::is_floating_point<Scalar>::value, Scalar>::type>
82-
inline bool isfinite(const Scalar& v) {
83-
return !std::isnan(v) && !std::isinf(v);
84-
}
8572

8673
#elif defined(__PGI)
8774
/* Portland Group PGCC/PGCPP. ------------------------------- */
@@ -92,18 +79,4 @@ namespace sw { namespace universal {
9279
#endif
9380

9481

95-
// Universal function supported by all number systems
96-
97-
template<typename Scalar,
98-
typename = typename std::enable_if<std::is_floating_point<Scalar>::value, Scalar>::type>
99-
inline bool isdenorm(const Scalar& v) {
100-
return !std::isnormal(v) && !std::isnan(v) && !std::isinf(v);
101-
}
102-
103-
// define an alias issubnorm for isdenorm
104-
template<typename Scalar,
105-
typename = typename std::enable_if<std::is_floating_point<Scalar>::value, Scalar>::type>
106-
inline bool issubnorm(const Scalar& v) { return isdenorm(v); }
107-
108-
10982
}} // namespace sw::universal

include/universal/math/stub/complex.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// complex.hpp: templated complex functions stubs for native floating-point
33
//
4-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78
#include <complex>

include/universal/math/stub/error_and_gamma.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// error_gamma.hpp: templated error and gamma function stubs for native floating-point
33
//
4-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/exponent.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// exponent.hpp: templated exponent function stubs for native floating-point
33
//
4-
// Copyright (C) 2017-2022 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/fractional.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// fractional.hpp: templated fractional function stubs for native floating-point
33
//
4-
// Copyright (C) 2017-2022 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/hyperbolic.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// hyperbolic.hpp: templated hyperbolic function stubs for native floating-point
33
//
4-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/hypot.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// hypot.hpp: templated hypotenuse function stubs for native floating-point
33
//
4-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/logarithm.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// logarithm.hpp: templated logarithm function stubs for native floating-point
33
//
4-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/minmax.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// math_minmax.hpp: templated min/max function stubs for native floating-point
33
//
4-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/next.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// next.hpp: templated nextafter/nexttoward function stubs for native floating-point
33
//
4-
// Copyright (C) 2017-2022 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/pow.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// pow.hpp: templated pow function stubs for native floating-point
33
//
4-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/sqrt.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// sqrt.hpp: templated sqrt function stub for native floating-point
33
//
4-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/trigonometry.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// trigonometric.hpp: templated trigonometric function stubs for native floating-point
33
//
4-
// Copyright (C) 2017-2021 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/math/stub/truncate.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#pragma once
22
// truncate.hpp: templated truncation function stubs for native floating-point (trunc, round, floor, and ceil) for posits
33
//
4-
// Copyright (C) 2017-2022 Stillwater Supercomputing, Inc.
4+
// Copyright (C) 2017 Stillwater Supercomputing, Inc.
5+
// SPDX-License-Identifier: MIT
56
//
67
// This file is part of the universal numbers project, which is released under an MIT Open Source license.
78

include/universal/native/ieee754.hpp

-7
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@
2222
#include <universal/native/ieee754_decoder.hpp>
2323
#include <universal/native/ieee754_type_tag.hpp>
2424

25-
////////////////////////////////////////////////////////////////////////////////////////
26-
// enable throwing specific exceptions long double special handling of 128bit fields
27-
#if !defined(BITBLOCK_THROW_ARITHMETIC_EXCEPTION)
28-
// default is to use std::cerr for signalling an error
29-
#define BITBLOCK_THROW_ARITHMETIC_EXCEPTION 0
30-
#endif
31-
3225
// if the compiler environment allows, set up
3326
// constexpr compatible bit casts, otherwise
3427
// fallback to nonconstexpr bit casts.

include/universal/native/ieee754_numeric.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ namespace sw { namespace universal {
2828
return (std::fpclassify(a) == FP_ZERO);
2929
}
3030

31+
// check if the floating-point number is a denorm
32+
template<typename Real,
33+
typename = typename ::std::enable_if< ::std::is_floating_point<Real>::value, Real >::type
34+
>
35+
inline bool isdenorm(const Real& a) {
36+
return (std::fpclassify(a) == FP_SUBNORMAL);
37+
}
38+
3139
// compile time power of 2
3240
template<typename Real, size_t powerOfTwo,
3341
typename = typename ::std::enable_if< ::std::is_floating_point<Real>::value, Real >::type

0 commit comments

Comments
 (0)