-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding a math library to the posito oracle so we can use it to compar…
…e native implementations
- Loading branch information
1 parent
b698230
commit 3ec54ad
Showing
55 changed files
with
1,140 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#pragma once | ||
// math_classify.hpp: classification functions for positos | ||
// | ||
// Copyright (C) 2017 Stillwater Supercomputing, Inc. | ||
// | ||
// This file is part of the universal numbers project, which is released under an MIT Open Source license. | ||
|
||
namespace sw { namespace universal { | ||
|
||
// the current shims are NON-COMPLIANT with the posito standard, which says that every function must be | ||
// correctly rounded for every input value. Anything less sacrifices bitwise reproducibility of results. | ||
|
||
// STD LIB function for IEEE floats: Categorizes floating point value arg into the following categories: zero, subnormal, normal, infinite, NAN, or implementation-defined category. | ||
template<unsigned nbits, unsigned es> | ||
int fpclassify(const posito<nbits,es>& p) { | ||
return std::fpclassify((long double)(p)); | ||
} | ||
|
||
// STD LIB function for IEEE floats: Determines if the given floating point number arg has finite value i.e. it is normal, subnormal or zero, but not infinite or NaN. | ||
// specialized for positos | ||
template<unsigned nbits, unsigned es> | ||
inline bool isfinite(const posito<nbits,es>& p) { | ||
return !p.isnar(); | ||
} | ||
|
||
// STD LIB function for IEEE floats: Determines if the given floating point number arg is a positoive or negative infinity. | ||
// specialized for positos | ||
template<unsigned nbits, unsigned es> | ||
inline bool isinf(const posito<nbits, es>& p) { | ||
return p.isnar(); | ||
} | ||
|
||
// STD LIB function for IEEE floats: Determines if the given floating point number arg is a not-a-number (NaN) value. | ||
// specialized for positos | ||
template<unsigned nbits, unsigned es> | ||
inline bool isnan(const posito<nbits, es>& p) { | ||
return p.isnar(); | ||
} | ||
|
||
// STD LIB function for IEEE floats: Determines if the given floating point number arg is normal, i.e. is neither zero, subnormal, infinite, nor NaN. | ||
// specialized for positos | ||
template<unsigned nbits, unsigned es> | ||
inline bool isnormal(const posito<nbits, es>& p) { | ||
return std::isnormal((long double)(p)); | ||
} | ||
|
||
// STD LIB function for IEEE floats: Determines if the given floating point number arg is normal, i.e. is neither zero, subnormal, infinite, nor NaN. | ||
// specialized for positos | ||
template<unsigned nbits, unsigned es> | ||
inline bool isdenorm(const posito<nbits, es>& p) { | ||
return (p.isnar() ? false : false); // positos are never denormalized | ||
} | ||
|
||
}} // namespace sw::universal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
// complex.hpp: functions for complex positos | ||
// | ||
// Copyright (C) 2017 Stillwater Supercomputing, Inc. | ||
// | ||
// This file is part of the universal numbers project, which is released under an MIT Open Source license. | ||
#include <complex> | ||
|
||
namespace sw { namespace universal { | ||
|
||
// the current shims are NON-COMPLIANT with the posito standard, which says that every function must be | ||
// correctly rounded for every input value. Anything less sacrifices bitwise reproducibility of results. | ||
|
||
// Real component of a complex posito | ||
template<unsigned nbits, unsigned es> | ||
posito<nbits,es> real(std::complex< posito<nbits,es> > x) { | ||
return posito<nbits,es>(x.real()); | ||
} | ||
|
||
// Imaginary component of a complex posito | ||
template<unsigned nbits, unsigned es> | ||
posito<nbits,es> imag(std::complex< posito<nbits,es> > x) { | ||
return posito<nbits,es>(x.imag()); | ||
} | ||
|
||
// Conjucate of a complex posito | ||
template<unsigned nbits, unsigned es> | ||
std::complex< posito<nbits,es> > conj(std::complex< posito<nbits,es> > x) { | ||
return std::complex< posito<nbits,es> >(x.real(), -x.imag()); | ||
} | ||
|
||
}} // namespace sw::universal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
// error_gamma.hpp: error and gamma functions for positos | ||
// | ||
// Copyright (C) 2017 Stillwater Supercomputing, Inc. | ||
// | ||
// This file is part of the universal numbers project, which is released under an MIT Open Source license. | ||
|
||
namespace sw { namespace universal { | ||
|
||
// the current shims are NON-COMPLIANT with the posito standard, which says that every function must be | ||
// correctly rounded for every input value. Anything less sacrifices bitwise reproducibility of results. | ||
|
||
// Compute the error function erf(x) = 2 over sqrt(PI) times Integral from 0 to x of e ^ (-t)^2 dt | ||
template<unsigned nbits, unsigned es> | ||
posito<nbits,es> erf(posito<nbits,es> x) { | ||
return posito<nbits,es>(std::erf(double(x))); | ||
} | ||
|
||
// Compute the complementary error function: 1 - erf(x) | ||
template<unsigned nbits, unsigned es> | ||
posito<nbits,es> erfc(posito<nbits,es> x) { | ||
return posito<nbits,es>(std::erfc(double(x))); | ||
} | ||
|
||
}} // namespace sw::universal |
Oops, something went wrong.