-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
335 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*################################################################################ | ||
## | ||
## Copyright (C) 2016-2024 Keith O'Hara | ||
## | ||
## This file is part of the GCE-Math C++ library. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
################################################################################*/ | ||
|
||
#ifndef _gcem_fabs_HPP | ||
#define _gcem_fabs_HPP | ||
|
||
/** | ||
* Compile-time floating-point absolute value function | ||
* | ||
* @param x a real-valued input. | ||
* @return the absolute value of \c x, \f$ |x| \f$, where the return type is a floating point number (float, double, or long double). | ||
*/ | ||
|
||
template<typename T> | ||
constexpr | ||
return_t<T> | ||
fabs(const T x) | ||
noexcept | ||
{ | ||
return gcem::abs( static_cast<return_t<T>>(x) ); | ||
} | ||
|
||
#endif |
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,40 @@ | ||
/*################################################################################ | ||
## | ||
## Copyright (C) 2016-2024 Keith O'Hara | ||
## | ||
## This file is part of the GCE-Math C++ library. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
################################################################################*/ | ||
|
||
#ifndef _gcem_fabsf_HPP | ||
#define _gcem_fabsf_HPP | ||
|
||
/** | ||
* Compile-time floating-point absolute value function | ||
* | ||
* @param x a real-valued input. | ||
* @return the absolute value of \c x, \f$ |x| \f$, where the return type is a floating point number (float only). | ||
*/ | ||
|
||
template<typename T> | ||
constexpr | ||
float | ||
fabsf(const T x) | ||
noexcept | ||
{ | ||
return gcem::abs( static_cast<float>(x) ); | ||
} | ||
|
||
#endif |
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,40 @@ | ||
/*################################################################################ | ||
## | ||
## Copyright (C) 2016-2024 Keith O'Hara | ||
## | ||
## This file is part of the GCE-Math C++ library. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
################################################################################*/ | ||
|
||
#ifndef _gcem_fabsl_HPP | ||
#define _gcem_fabsl_HPP | ||
|
||
/** | ||
* Compile-time floating-point absolute value function | ||
* | ||
* @param x a real-valued input. | ||
* @return the absolute value of \c x, \f$ |x| \f$, where the return type is a floating point number (long double only). | ||
*/ | ||
|
||
template<typename T> | ||
constexpr | ||
long double | ||
fabsl(const T x) | ||
noexcept | ||
{ | ||
return gcem::abs( static_cast<long double>(x) ); | ||
} | ||
|
||
#endif |
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,71 @@ | ||
/*################################################################################ | ||
## | ||
## Copyright (C) 2016-2024 Keith O'Hara | ||
## | ||
## This file is part of the GCE-Math C++ library. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
################################################################################*/ | ||
|
||
#define TEST_PRINT_PRECISION_1 6 | ||
#define TEST_PRINT_PRECISION_2 18 | ||
|
||
#include "gcem_tests.hpp" | ||
|
||
int main() | ||
{ | ||
print_begin("fabs"); | ||
|
||
// | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, 0.0f); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs,-0.0f); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, 1.0f); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs,-1.0f); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, 0.0); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs,-0.0); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, 1.0); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs,-1.0); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, 0); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, 1); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs,-1); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, 0.0L); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs,-0.0L); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, 1.0L); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs,-1.0L); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, std::numeric_limits<float>::lowest()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, std::numeric_limits<float>::min()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, std::numeric_limits<float>::max()); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, std::numeric_limits<double>::lowest()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, std::numeric_limits<double>::min()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, std::numeric_limits<double>::max()); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, std::numeric_limits<long double>::lowest()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, std::numeric_limits<long double>::min()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, std::numeric_limits<long double>::max()); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, TEST_NAN); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, TEST_NEGINF); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabs,std::fabs, TEST_POSINF); | ||
|
||
// | ||
|
||
print_final("fabs"); | ||
|
||
return 0; | ||
} |
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,50 @@ | ||
/*################################################################################ | ||
## | ||
## Copyright (C) 2016-2024 Keith O'Hara | ||
## | ||
## This file is part of the GCE-Math C++ library. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
################################################################################*/ | ||
|
||
#define TEST_PRINT_PRECISION_1 6 | ||
#define TEST_PRINT_PRECISION_2 18 | ||
|
||
#include "gcem_tests.hpp" | ||
|
||
int main() | ||
{ | ||
print_begin("fabsf"); | ||
|
||
// | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabsf,std::fabsf, 0.0f); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsf,std::fabsf,-0.0f); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsf,std::fabsf, 1.0f); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsf,std::fabsf,-1.0f); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabsf,std::fabsf, std::numeric_limits<float>::lowest()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsf,std::fabsf, std::numeric_limits<float>::min()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsf,std::fabsf, std::numeric_limits<float>::max()); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabsf,std::fabsf, std::numeric_limits<float>::quiet_NaN()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsf,std::fabsf, std::numeric_limits<float>::infinity()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsf,std::fabsf, -std::numeric_limits<float>::infinity()); | ||
|
||
// | ||
|
||
print_final("fabsf"); | ||
|
||
return 0; | ||
} |
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,63 @@ | ||
/*################################################################################ | ||
## | ||
## Copyright (C) 2016-2024 Keith O'Hara | ||
## | ||
## This file is part of the GCE-Math C++ library. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
################################################################################*/ | ||
|
||
#define TEST_PRINT_PRECISION_1 6 | ||
#define TEST_PRINT_PRECISION_2 18 | ||
|
||
#include "gcem_tests.hpp" | ||
|
||
int main() | ||
{ | ||
print_begin("fabsl"); | ||
|
||
// | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, 0.0); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl,-0.0); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, 1.0); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl,-1.0); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, 0.0L); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl,-0.0L); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, 1.0L); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl,-1.0L); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, std::numeric_limits<double>::lowest()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, std::numeric_limits<double>::min()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, std::numeric_limits<double>::max()); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, std::numeric_limits<long double>::lowest()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, std::numeric_limits<long double>::min()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, std::numeric_limits<long double>::max()); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, std::numeric_limits<double>::quiet_NaN()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, std::numeric_limits<double>::infinity()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, -std::numeric_limits<double>::infinity()); | ||
|
||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, std::numeric_limits<long double>::quiet_NaN()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, std::numeric_limits<long double>::infinity()); | ||
GCEM_TEST_COMPARE_VALS(gcem::fabsl,std::fabsl, -std::numeric_limits<long double>::infinity()); | ||
|
||
// | ||
|
||
print_final("fabsl"); | ||
|
||
return 0; | ||
} |