Skip to content

Commit

Permalink
Prepare for 0.1.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinzii committed Mar 2, 2024
1 parent 37a6cff commit 1398eb1
Show file tree
Hide file tree
Showing 17 changed files with 143 additions and 159 deletions.
59 changes: 0 additions & 59 deletions .github/workflows/delete-workflows.yml

This file was deleted.

7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(is_root_project ON)
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand All @@ -24,7 +24,6 @@ option(CCMATH_BUILD_EXAMPLES "Build ccmath examples" ${is_root_project})
option(CCMATH_BUILD_BENCHMARKS "Build ccmath benchmarks" ${is_root_project})
option(CCMATH_INSTALL "Setup install and package steps" ${is_root_project})
option(CCMATH_USE_SIMD "Use SIMD instructions" OFF)
option(CCMATH_BUILD_EXE "Build ccmath benchmarks" ${is_root_project}) # TODO: This will be removed once we reach a stable API

# include the global configuration file
include(cmake/GlobalConfig.cmake)
Expand Down Expand Up @@ -65,8 +64,8 @@ target_link_libraries(${PROJECT_NAME} INTERFACE

configure_file(cmake/version.hpp.in "${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/version.hpp" @ONLY)

if (CCMATH_BUILD_EXE)
add_subdirectory(temp_exe)
if (CCMATH_BUILD_EXAMPLES)
add_subdirectory(example)
endif()

if (CCMATH_BUILD_EXAMPLES OR CCMATH_BUILD_BENCHMARKS OR CCMATH_BUILD_TEST)
Expand Down
7 changes: 7 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project(ccmath-examples)

set(CMAKE_CXX_STANDARD 17)

add_executable(${PROJECT_NAME} main.cpp)

target_link_libraries(${PROJECT_NAME} ccmath::ccmath)
11 changes: 11 additions & 0 deletions temp_exe/main.cpp → example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,23 @@ int main()
constexpr double val = ccm::signbit(a);
static_assert(val == true, "ccm::signbit(-0.0) != true");

std::remquo(1.0, 2.0, nullptr);
__builtin_remquo(1.0, 2.0, nullptr);
// EXPECT_EQ(ccm::trunc(-std::numeric_limits<double>::quiet_NaN()), std::trunc(-std::numeric_limits<double>::quiet_NaN()));

constexpr double b = -std::numeric_limits<double>::quiet_NaN();
constexpr double val2 = ccm::trunc(b);
static_assert(ccm::isnan(val2), "ccm::trunc(-std::numeric_limits<double>::quiet_NaN()) != std::trunc(-std::numeric_limits<double>::quiet_NaN())");

// Test constexpr remquo
constexpr double x = 1.0;
constexpr double y = 2.0;
static constexpr int * quo = nullptr;
constexpr double result = ccm::remquo(x, y, quo);

// Test trunc
double b1 = std::trunc(-std::numeric_limits<double>::quiet_NaN());


double b2 = ccm::trunc(-std::numeric_limits<double>::quiet_NaN());

Expand Down
98 changes: 9 additions & 89 deletions include/ccmath/ccmath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,125 +18,45 @@ CCMATH REQUIREMENTS:
* Anything that could be considered UB is strictly forbidden.
* Performance is are primary concern. Everything must be as fast as possible.
* Anything implemented by cmath that is already constexpr is allowed to be wrapped by ccmath and not implemented by ccmath.
*/

/// Basic math functions

#include "ccmath/detail/basic/abs.hpp"
#include "ccmath/detail/basic/fdim.hpp"
#include "ccmath/detail/basic/fma.hpp"
#include "ccmath/detail/basic/fmod.hpp"
#include "ccmath/detail/basic/max.hpp"
#include "ccmath/detail/basic/min.hpp"
#include "ccmath/detail/basic/remainder.hpp"
#include "ccmath/detail/basic/remquo.hpp"
#include "ccmath/basic.hpp"


/// Comparison functions

#include "ccmath/detail/compare/fpclassify.hpp"
#include "ccmath/detail/compare/isfinite.hpp"
#include "ccmath/detail/compare/isgreater.hpp"
#include "ccmath/detail/compare/isgreaterequal.hpp"
#include "ccmath/detail/compare/isinf.hpp"
#include "ccmath/detail/compare/isless.hpp"
#include "ccmath/detail/compare/islessequal.hpp"
#include "ccmath/detail/compare/islessgreater.hpp"
#include "ccmath/detail/compare/isnan.hpp"
#include "ccmath/detail/compare/isnormal.hpp"
#include "ccmath/detail/compare/isunordered.hpp"
#include "ccmath/detail/compare/signbit.hpp"
#include "ccmath/compare.hpp"


/// Exponential functions

#include "ccmath/detail/exponential/exp.hpp"
#include "ccmath/detail/exponential/exp2.hpp"
#include "ccmath/detail/exponential/expm1.hpp"
#include "ccmath/detail/exponential/log.hpp"
#include "ccmath/detail/exponential/log1p.hpp"
#include "ccmath/detail/exponential/log2.hpp"
#include "ccmath/detail/exponential/log10.hpp"
#include "ccmath/exponential.hpp"


/// Float manipulation functions

#include "ccmath/detail/fmanip/copysign.hpp"
#include "ccmath/detail/fmanip/frexp.hpp"
#include "ccmath/detail/fmanip/ilogb.hpp"
#include "ccmath/detail/fmanip/ldexp.hpp"
#include "ccmath/detail/fmanip/logb.hpp"
#include "ccmath/detail/fmanip/modf.hpp"
#include "ccmath/detail/fmanip/nextafter.hpp"
#include "ccmath/detail/fmanip/scalbn.hpp"
#include "ccmath/fmanip.hpp"


/// Hyperbolic functions

#include "ccmath/detail/hyperbolic/acosh.hpp"
#include "ccmath/detail/hyperbolic/asinh.hpp"
#include "ccmath/detail/hyperbolic/atanh.hpp"
#include "ccmath/detail/hyperbolic/cosh.hpp"
#include "ccmath/detail/hyperbolic/sinh.hpp"
#include "ccmath/detail/hyperbolic/tanh.hpp"
#include "ccmath/hyperbolic.hpp"


/// Nearest functions

#include "ccmath/detail/nearest/ceil.hpp"
#include "ccmath/detail/nearest/floor.hpp"
#include "ccmath/detail/nearest/nearbyint.hpp"
#include "ccmath/detail/nearest/rint.hpp"
#include "ccmath/detail/nearest/round.hpp"
#include "ccmath/detail/nearest/trunc.hpp"
#include "ccmath/nearest.hpp"


/// Power functions

#include "ccmath/detail/power/cbrt.hpp"
#include "ccmath/detail/power/hypot.hpp"
#include "ccmath/detail/power/pow.hpp"
#include "ccmath/detail/power/sqrt.hpp"
#include "ccmath/power.hpp"


/// Special functions

#include "ccmath/detail/special/assoc_laguerre.hpp"
#include "ccmath/detail/special/assoc_legendre.hpp"
#include "ccmath/detail/special/beta.hpp"
#include "ccmath/detail/special/comp_ellint_1.hpp"
#include "ccmath/detail/special/comp_ellint_2.hpp"
#include "ccmath/detail/special/comp_ellint_3.hpp"
#include "ccmath/detail/special/cyl_bessel_i.hpp"
#include "ccmath/detail/special/cyl_bessel_j.hpp"
#include "ccmath/detail/special/cyl_bessel_k.hpp"
#include "ccmath/detail/special/cyl_neumann.hpp"
#include "ccmath/detail/special/ellint_1.hpp"
#include "ccmath/detail/special/ellint_2.hpp"
#include "ccmath/detail/special/ellint_3.hpp"
#include "ccmath/detail/special/expint.hpp"
#include "ccmath/detail/special/hermite.hpp"
#include "ccmath/detail/special/laguerre.hpp"
#include "ccmath/detail/special/legendre.hpp"
#include "ccmath/detail/special/riemann_zeta.hpp"
#include "ccmath/detail/special/sph_bessel.hpp"
#include "ccmath/detail/special/sph_legendre.hpp"
#include "ccmath/detail/special/sph_neumann.hpp"
#include "ccmath/special.hpp"


/// Trigonometric functions
#include "ccmath/detail/trig/acos.hpp"
#include "ccmath/detail/trig/asin.hpp"
#include "ccmath/detail/trig/atan.hpp"
#include "ccmath/detail/trig/atan2.hpp"
#include "ccmath/detail/trig/cos.hpp"
#include "ccmath/detail/trig/sin.hpp"
#include "ccmath/detail/trig/tan.hpp"
#include "ccmath/trig.hpp"


/// Uncategorized functions

#include "ccmath/detail/gamma.hpp"
#include "ccmath/detail/lerp.hpp"
#include "ccmath/detail/lgamma.hpp"
13 changes: 13 additions & 0 deletions include/ccmath/compare.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,16 @@
*/

#pragma once

#include "ccmath/detail/compare/fpclassify.hpp"
#include "ccmath/detail/compare/isfinite.hpp"
#include "ccmath/detail/compare/isgreater.hpp"
#include "ccmath/detail/compare/isgreaterequal.hpp"
#include "ccmath/detail/compare/isinf.hpp"
#include "ccmath/detail/compare/isless.hpp"
#include "ccmath/detail/compare/islessequal.hpp"
#include "ccmath/detail/compare/islessgreater.hpp"
#include "ccmath/detail/compare/isnan.hpp"
#include "ccmath/detail/compare/isnormal.hpp"
#include "ccmath/detail/compare/isunordered.hpp"
#include "ccmath/detail/compare/signbit.hpp"
1 change: 1 addition & 0 deletions include/ccmath/detail/basic/fma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace ccm

// If the compiler has a builtin, use it
#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
// TODO: Add a wrapper for if constexpr
if constexpr (std::is_same_v<T, float>)
{
return __builtin_fmaf(x, y, z);
Expand Down
33 changes: 33 additions & 0 deletions include/ccmath/detail/basic/remquo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,40 @@

#pragma once

#include "ccmath/detail/compare/isnan.hpp"
#include "ccmath/detail/compare/isinf.hpp"
#include "ccmath/detail/basic/remainder.hpp"

namespace ccm
{
template<typename T>
inline constexpr T remquo(T x, T y, int* quo)
{
#if false && (defined(__GNUC__) && !defined(__clang__) && __GNUC__ >= 7 && __GNUC_MINOR__ >= 1)
// Works with GCC 7.1
// Not static_assert-able
return __builtin_remquo(x, y, quo);
#else
// TODO: This function is a lot trickier to get working with constexpr.
// TODO: I'm putting this on hold for now and not require it for the first release.
if constexpr (std::is_floating_point_v<T>)
{
// If x is ±∞ and y is not NaN, NaN is returned.
// If y is ±0 and x is not NaN, NaN is returned.
// If either argument is NaN, NaN is returned.
if ((ccm::isinf(x) && !ccm::isnan(y)) || (y == 0 && !ccm::isnan(x)) || (ccm::isnan(x) || ccm::isnan(y)))
{
// All major compilers return -NaN.
return -std::numeric_limits<T>::quiet_NaN();
}
}

T r = ccm::remainder(x, y);
// Having a lot of issues with handling the quo parameter. May use __builtin_bit_cast to handle this.
//*quo = static_cast<int>(x / y) & ~(std::numeric_limits<int>::min)();

return r;
#endif
}

} // namespace ccm
8 changes: 8 additions & 0 deletions include/ccmath/exponential.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@
*/

#pragma once

#include "ccmath/detail/exponential/exp.hpp"
#include "ccmath/detail/exponential/exp2.hpp"
#include "ccmath/detail/exponential/expm1.hpp"
#include "ccmath/detail/exponential/log.hpp"
#include "ccmath/detail/exponential/log1p.hpp"
#include "ccmath/detail/exponential/log2.hpp"
#include "ccmath/detail/exponential/log10.hpp"
9 changes: 9 additions & 0 deletions include/ccmath/fmanip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@
*/

#pragma once

#include "ccmath/detail/fmanip/copysign.hpp"
#include "ccmath/detail/fmanip/frexp.hpp"
#include "ccmath/detail/fmanip/ilogb.hpp"
#include "ccmath/detail/fmanip/ldexp.hpp"
#include "ccmath/detail/fmanip/logb.hpp"
#include "ccmath/detail/fmanip/modf.hpp"
#include "ccmath/detail/fmanip/nextafter.hpp"
#include "ccmath/detail/fmanip/scalbn.hpp"
7 changes: 7 additions & 0 deletions include/ccmath/hyperbolic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@
*/

#pragma once

#include "ccmath/detail/hyperbolic/acosh.hpp"
#include "ccmath/detail/hyperbolic/asinh.hpp"
#include "ccmath/detail/hyperbolic/atanh.hpp"
#include "ccmath/detail/hyperbolic/cosh.hpp"
#include "ccmath/detail/hyperbolic/sinh.hpp"
#include "ccmath/detail/hyperbolic/tanh.hpp"
7 changes: 7 additions & 0 deletions include/ccmath/nearest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@
*/

#pragma once

#include "ccmath/detail/nearest/ceil.hpp"
#include "ccmath/detail/nearest/floor.hpp"
#include "ccmath/detail/nearest/nearbyint.hpp"
#include "ccmath/detail/nearest/rint.hpp"
#include "ccmath/detail/nearest/round.hpp"
#include "ccmath/detail/nearest/trunc.hpp"
5 changes: 5 additions & 0 deletions include/ccmath/power.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
*/

#pragma once

#include "ccmath/detail/power/cbrt.hpp"
#include "ccmath/detail/power/hypot.hpp"
#include "ccmath/detail/power/pow.hpp"
#include "ccmath/detail/power/sqrt.hpp"
Loading

0 comments on commit 1398eb1

Please sign in to comment.