Skip to content

Commit

Permalink
Bring version 0.1.1 into main (#12)
Browse files Browse the repository at this point in the history
* Add support for builtin detection

* Update comments to be more eye catching

* Add clang-cl and apple clang support

* Fix bug with MSVC where not checking for nan

* Remove msvc specific code in favor of generic approach

* Prepare for 0.1.0 release.

* Add doxygen docs

* Finalize min/max

* Add todo for later work on remquo

* Cleanup main for 0.1.0 release

* Bring standard back to C++17

* Minor cleanup to cmake list

* Prep files for v0.1.0 release

* Prepare for 0.1.0 release.

* Add doxygen docs

* Finalize min/max

* Add todo for later work on remquo

* Cleanup main for 0.1.0 release

* Bring standard back to C++17

* Minor cleanup to cmake list

* Prep files for v0.1.0 release

* Bring everything in

* Remove artifacts that mistakenly got pushed to main

* Implement isgreater

* Implement isgreaterequal

* Implement isless

* Implement islessequal

* Implement islessgreater

* Implement isnormal

* Implement isunordered

* Add test cases for all new compare functions

* Add boilerplate code for future unit tests

* Update progress

* A lot of work done so far on log

* log now far more efficient and accurate

* Update readme progress

* Continue work on log for double

* remove unnecessary include

* remove msvc section of unlikely

* improve variable names

* remove old log impl

* Cleanup double implementation of log

* cleanup of log details and add more comments.

* Finalize work on log function

* Update current progress

* Fix bug with ±0 in log

* Update test cases to cover all major edge cases

* Move to correct folder

* Add headers for log and log2

* Remove dependency on Threads

* Initial addition of Contribution Guide

* Cleanup README and add extra information

* Update project version to v0.1.1

* Add top12 bits function for upcoming work

* Finalize work with log function

* Initial working revision of log2

* Push current work. Need to revise log2 to resolve bugs later.

* Initial implementation of lerp

* Fix scope bug

* remove the direct use of cmath.

* Update include to use cfloat instead of float.h

* Cleanup macros and fix minor bugs

* Fix bug where we were improperly assigning a correct value to the wrong variable

* Update docs to mention not accounting for big-endian

* Add comment to mention we are mirroring impl from cmath

* Remove MSVC fallback that was inconsistent with every other impl

* Add additional helpers for future work

* Add test for static_assert support and some additional tests

* Finalize implementation of log2

* Remove static_assert for now

* Update README.md
  • Loading branch information
Rinzii authored Mar 9, 2024
1 parent 867fc9d commit fa136d5
Show file tree
Hide file tree
Showing 71 changed files with 2,617 additions and 121 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.18)

enable_language(CXX)

set(CCMATH_BUILD_VERSION 0.1.0)
set(CCMATH_BUILD_VERSION 0.1.1)
set(INTERNAL_PROJ_DEFAULT_NAME ccmath)

project(${INTERNAL_PROJ_DEFAULT_NAME} VERSION ${CCMATH_BUILD_VERSION})
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contribution Guidelines

WIP
67 changes: 39 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ ccmath is a C++17 library that provides a re-implementation of the standard `<cm

## Features

- **constexpr Compatibility**: All functions provided by ccmath are implemented as `constexpr`, allowing them to be evaluated at compile time when used with constant expressions.
- **Full constexpr Compatibility**: All functions provided by ccmath are implemented as `constexpr`, allowing them to be evaluated at compile time when used with constant expressions.

- **Standard Math Functions**: ccmath provides a comprehensive set of mathematical functions similar to those in the standard `<cmath>` library, including trigonometric, exponential, logarithmic, and other common mathematical operations. If `<cmath>` has it then it is likely ccmath has implemented it.

- **Performance Optimization**: By leveraging constexpr, ccmath aims to optimize performance by computing mathematical expressions at compile time where possible, reducing runtime overhead.
- **Performance Optimization**: By leveraging constexpr, ccmath aims to optimize performance by computing mathematical expressions at compile time when possible, reducing runtime overhead.

- **No External Dependencies**: ccmath has no external dependencies and only requires a C++17-compliant compiler.

Expand All @@ -33,40 +33,51 @@ int main() {
ccmath has a comprehensive cmake setup and can be easily included in your project using fetchcontent like so:

```cmake
cmake_minimum_required(VERSION 3.11) # FetchContent is new in version 3.11.
include(FetchContent)
FetchContent_Declare(
ccmath
GIT_REPOSITORY https://github.com/Rinzii/ccmath.git
GIT_TAG main
GIT_TAG v0.1.0 # Replace with the version you want to use
)
FetchContent_MakeAvailable(ccmath)
target_link_libraries(main PRIVATE ccmath::ccmath)
```

## Compatability
## Compiler Support
* GCC 11.1+
* Clang 9.0.0+
* AppleClang 14.0.3+ (Lowest tested version)
* MSVC 19.26+
* Intel DPC++ 2022.0.0+
* Nvidia HPC SDK 22.7+ (Lowest tested version)

ccmath is designed to be compatible with any C++17-compliant compiler. It should work seamlessly with popular compilers such as GCC, Clang, and MSVC.
> [!NOTE]
> Currently working on finding manners to lower these requirements.
## Contributing

Contributions to ccmath are welcome! If you encounter any bugs, have suggestions for improvements, or would like to contribute new features, feel free to open an issue or submit a pull request!
CCmath is an open-source project, and it needs your help to go on growing and improving. If you want to get involved and suggest some additional features, file a bug report or submit a patch, please have a look at the contribution guidelines.

## Implementation Progress (Sub Sections)
| Section | % done | In Progress? | Notes? | Planned Completion Version |
## Implementation Progress (Modules)
| Module | % done | In Progress? | Notes? | Planned Completion Version |
|--------------------|--------|--------------|---------------------------------------------------------------------------|----------------------------|
| Basic | 91 | | Remquo is being pushed back to a later release due to technical problems. | v0.1.0 |
| Compare | 40 | | |
| Exponential | 0 | | |
| Basic | 91 | | Remquo is being pushed back to a later release due to technical problems. | v0.1.0 (Released) |
| Compare | 100 | | | v0.2.0 |
| Exponential | 33 || | v0.2.0 |
| Float Manipulation | 0 | | |
| Hyperbolic | 0 | | |
| Nearest | 15 | | |
| Power | 5 | | |
| Special Functions | 0 | | |
| Trigonometric | 0 | | |
| Misc Functions | 0 | | |
| Misc Functions | 10 | | |

> Last Updated: Mar 02, 2024
> Last Updated: Mar 09, 2024
## Implementation Progress (All Functions)
## Implementation Progress (Functions)

| Feature | % done | TODO |
|----------------|--------|------------------------------------------------------------------------------------------|
Expand All @@ -79,22 +90,22 @@ Contributions to ccmath are welcome! If you encounter any bugs, have suggestions
| remquo | 40 | Partially implemented, but being pushed back to later release due to technical problems. |
| fpclassify | 100 | |
| isfinite | 100 | |
| isgreater | 0 | Implement function |
| isgreaterequal | 0 | Implement function |
| isinf | 98 | Improve documentation |
| isless | 0 | Implement function |
| islessequal | 0 | Implement function |
| islessgreater | 0 | Implement function |
| isnan | 95 | Add more support for built-in functions and improve documentation |
| isnormal | 0 | Implement function |
| isunordered | 0 | Implement function |
| signbit | 90 | Add more fallbacks and builtin support if possible and improve reliability with MSVC |
| isgreater | 100 | |
| isgreaterequal | 100 | |
| isinf | 100 | Improve documentation |
| isless | 100 | |
| islessequal | 100 | |
| islessgreater | 100 | |
| isnan | 100 | Functional, need improved documentation and more test cases. |
| isnormal | 100 | |
| isunordered | 100 | |
| signbit | 100 | Need to find manner of implementing signbit on lower versions of MSVC. |
| exp | 35 | Continue implementation process and add documentation and tests |
| exp2 | 0 | Implement function |
| expm1 | 0 | Implement function |
| log | 0 | Implement function |
| log | 100 | Functional, but fallbacks without requiring recent compiler versions is desired. |
| log1p | 0 | Implement function |
| log2 | 0 | Implement function |
| log2 | 100 | Functional, but fallbacks without requiring recent compiler versions is desired. |
| log10 | 0 | Implement function |
| copysign | 0 | Implement function |
| frexp | 0 | Implement function |
Expand Down Expand Up @@ -149,10 +160,10 @@ Contributions to ccmath are welcome! If you encounter any bugs, have suggestions
| sin | 0 | Implement function |
| tan | 0 | Implement function |
| gamma | 0 | Implement function |
| lerp | 0 | Implement function |
| lerp | 30 | Need to finish implementation process along with handling edge cases and promotion. |
| lgamma | 0 | Implement function |

> Last Updated: Mar 02, 2024
> Last Updated: Mar 09, 2024

## License
Expand Down
File renamed without changes.
21 changes: 21 additions & 0 deletions ccmath_headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ set(ccmath_internal_helpers_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/helpers/make_mantisa.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/helpers/not_null.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/helpers/fpclassify_helper.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/helpers/pow_integral.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/helpers/find_number.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/helpers/is_odd.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/helpers/exponentiation_helpers.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/helpers/bits.hpp
)

set(ccmath_internal_predef_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/predef/unlikely.hpp
)

set(ccmath_internal_setup_headers
Expand All @@ -27,6 +36,7 @@ set(ccmath_internal_utility_headers

set(ccmath_internal_headers
${ccmath_internal_helpers_headers}
${ccmath_internal_predef_headers}
${ccmath_internal_setup_headers}
${ccmath_internal_typetraits_headers}
${ccmath_internal_utility_headers}
Expand Down Expand Up @@ -61,7 +71,17 @@ set(ccmath_detail_compare_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/detail/compare/signbit.hpp
)

set(ccmath_detail_exponential_details_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/detail/exponential/details/log_float_impl.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/detail/exponential/details/log_double_impl.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/detail/exponential/details/log_data.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/detail/exponential/details/log2_float_impl.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/detail/exponential/details/log2_double_impl.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/detail/exponential/details/log2_data.hpp
)

set(ccmath_detail_exponential_headers
${ccmath_detail_exponential_details_headers}
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/detail/exponential/exp.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/detail/exponential/exp2.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/detail/exponential/expm1.hpp
Expand Down Expand Up @@ -172,6 +192,7 @@ set(ccmath_root_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/special.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/trig.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/ccmath.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/numbers.hpp
)

set(ccmath_headers
Expand Down
7 changes: 0 additions & 7 deletions ext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ if (CCMATH_BUILD_TEST)
endif()



#find_package(Threads REQUIRED)

add_library(${PROJECT_NAME} INTERFACE)
add_library(${INTERNAL_PROJ_DEFAULT_NAME}::ext ALIAS ${PROJECT_NAME})

Expand All @@ -45,7 +42,3 @@ if(CCMATH_BUILD_TEST)
)
endif ()

# TODO: May not actually require this. Later decide if I want to remove it.
target_link_libraries(${PROJECT_NAME} INTERFACE
Threads::Threads
)
33 changes: 33 additions & 0 deletions include/ccmath/detail/compare/isgreater.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,40 @@

#pragma once

#include <type_traits>

namespace ccm
{
/**
* @brief Checks if the first argument is greater than the second.
* @tparam T Type of the values to compare.
* @param x A floating-point or integer value.
* @param y A floating-point or integer value.
* @return true if the first argument is greater than the second, false otherwise.
*/
template <typename T>
inline constexpr bool isgreater(T x, T y) noexcept
{
return x > y;
}

/**
* @brief Checks if the first argument is greater than the second.
* @tparam T Type of the left-hand side.
* @tparam U Type of the right-hand side.
* @param x Value of the left-hand side of the comparison.
* @param y Value of the right-hand side of the comparison.
* @return true if the first argument is greater than the second, false otherwise.
*/
template <typename T, typename U>
inline constexpr bool isgreater(T x, U y) noexcept
{
// Find the common type of the two arguments
using shared_type = std::common_type_t<T, U>;

// Then cast the arguments to the common type and call the single argument version
return static_cast<shared_type>(isgreater<shared_type>(static_cast<shared_type>(x), static_cast<shared_type>(y)));
}
} // namespace ccm

/// @ingroup compare
33 changes: 33 additions & 0 deletions include/ccmath/detail/compare/isgreaterequal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,40 @@

#pragma once

#include <type_traits>

namespace ccm
{
/**
* @brief Checks if the first argument is greater than or equal to the second.
* @tparam T Type of the values to compare.
* @param x A floating-point or integer value.
* @param y A floating-point or integer value.
* @return true if the first argument is greater than or equal to the second, false otherwise.
*/
template <typename T>
inline constexpr bool isgreaterequal(T x, T y) noexcept
{
return x >= y;
}

/**
* @brief Checks if the first argument is greater than or equal to the second.
* @tparam T Type of the left-hand side.
* @tparam U Type of the right-hand side.
* @param x Value of the left-hand side of the comparison.
* @param y Value of the right-hand side of the comparison.
* @return true if the first argument is greater than or equal to the second, false otherwise.
*/
template <typename T, typename U>
inline constexpr bool isgreaterequal(T x, U y) noexcept
{
// Find the common type of the two arguments
using shared_type = std::common_type_t<T, U>;

// Then cast the arguments to the common type and call the single argument version
return static_cast<shared_type>(isgreaterequal<shared_type>(static_cast<shared_type>(x), static_cast<shared_type>(y)));
}
} // namespace ccm

/// @ingroup compare
33 changes: 33 additions & 0 deletions include/ccmath/detail/compare/isless.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,40 @@

#pragma once

#include <type_traits>

namespace ccm
{
/**
* @brief Checks if the first argument is less than the second.
* @tparam T Type of the values to compare.
* @param x A floating-point or integer value.
* @param y A floating-point or integer value.
* @return true if the first argument is less than the second, false otherwise.
*/
template <typename T>
inline constexpr bool isless(T x, T y) noexcept
{
return x < y;
}

/**
* @brief Checks if the first argument is less than the second.
* @tparam T Type of the left-hand side.
* @tparam U Type of the right-hand side.
* @param x Value of the left-hand side of the comparison.
* @param y Value of the right-hand side of the comparison.
* @return true if the first argument is less than the second, false otherwise.
*/
template <typename T, typename U>
inline constexpr bool isless(T x, U y) noexcept
{
// Find the common type of the two arguments
using shared_type = std::common_type_t<T, U>;

// Then cast the arguments to the common type and call the single argument version
return static_cast<shared_type>(isless<shared_type>(static_cast<shared_type>(x), static_cast<shared_type>(y)));
}
} // namespace ccm

/// @ingroup compare
33 changes: 33 additions & 0 deletions include/ccmath/detail/compare/islessequal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,40 @@

#pragma once

#include <type_traits>

namespace ccm
{
/**
* @brief Checks if the first argument is less than or equal to the second.
* @tparam T Type of the values to compare.
* @param x A floating-point or integer value.
* @param y A floating-point or integer value.
* @return true if the first argument is less than or equal to the second, false otherwise.
*/
template <typename T>
inline constexpr bool islessequal(T x, T y) noexcept
{
return x <= y;
}

/**
* @brief Checks if the first argument is less than or equal to the second.
* @tparam T Type of the left-hand side.
* @tparam U Type of the right-hand side.
* @param x Value of the left-hand side of the comparison.
* @param y Value of the right-hand side of the comparison.
* @return true if the first argument is less than or equal to the second, false otherwise.
*/
template <typename T, typename U>
inline constexpr bool islessequal(T x, U y) noexcept
{
// Find the common type of the two arguments
using shared_type = std::common_type_t<T, U>;

// Then cast the arguments to the common type and call the single argument version
return static_cast<shared_type>(islessequal<shared_type>(static_cast<shared_type>(x), static_cast<shared_type>(y)));
}
} // namespace ccm

/// @ingroup compare
Loading

0 comments on commit fa136d5

Please sign in to comment.