Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring version 0.1.1 into main #12

Merged
merged 78 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f115662
Add support for builtin detection
Rinzii Mar 1, 2024
1f8a61f
Update comments to be more eye catching
Rinzii Mar 1, 2024
918cc5f
Add clang-cl and apple clang support
Rinzii Mar 1, 2024
0b2bdfe
push work up
Rinzii Mar 1, 2024
2588ab6
push work up
Rinzii Mar 1, 2024
0a6a1cc
Fix bug with MSVC where not checking for nan
Rinzii Mar 1, 2024
37a6cff
Remove msvc specific code in favor of generic approach
Rinzii Mar 1, 2024
1398eb1
Prepare for 0.1.0 release.
Rinzii Mar 2, 2024
9b871f6
Add doxygen docs
Rinzii Mar 2, 2024
a07a344
Finalize min/max
Rinzii Mar 2, 2024
bb99a4c
Add todo for later work on remquo
Rinzii Mar 2, 2024
0a587d7
Cleanup main for 0.1.0 release
Rinzii Mar 2, 2024
03a0068
Bring standard back to C++17
Rinzii Mar 2, 2024
bec535c
Minor cleanup to cmake list
Rinzii Mar 2, 2024
c6923da
Prep files for v0.1.0 release
Rinzii Mar 2, 2024
0e7168d
Clean up conflicts
Rinzii Mar 2, 2024
0593ffc
Prepare for 0.1.0 release.
Rinzii Mar 2, 2024
f21bad8
Add doxygen docs
Rinzii Mar 2, 2024
df69b06
Finalize min/max
Rinzii Mar 2, 2024
796ca0e
Add todo for later work on remquo
Rinzii Mar 2, 2024
f62558c
Cleanup main for 0.1.0 release
Rinzii Mar 2, 2024
0f84b0a
Bring standard back to C++17
Rinzii Mar 2, 2024
35a7efa
Minor cleanup to cmake list
Rinzii Mar 2, 2024
7e297c6
Prep files for v0.1.0 release
Rinzii Mar 2, 2024
6bc4cd4
Add helper macros
Rinzii Mar 2, 2024
98e4948
Bring everything in
Rinzii Mar 2, 2024
7aa69eb
Merge remote-tracking branch 'origin/dev' into dev
Rinzii Mar 2, 2024
1246c74
Remove artifacts that mistakenly got pushed to main
Rinzii Mar 2, 2024
78778a0
Implement isgreater
Rinzii Mar 3, 2024
39413fe
Implement isgreaterequal
Rinzii Mar 3, 2024
bf4290c
Implement isless
Rinzii Mar 3, 2024
540b6e9
Implement islessequal
Rinzii Mar 3, 2024
494f0fb
Implement islessgreater
Rinzii Mar 3, 2024
98b9147
Implement isnormal
Rinzii Mar 3, 2024
63224c9
Implement isunordered
Rinzii Mar 3, 2024
0da5455
Add test cases for all new compare functions
Rinzii Mar 3, 2024
fc59cdd
Add boilerplate code for future unit tests
Rinzii Mar 3, 2024
b0296f1
Update progress
Rinzii Mar 3, 2024
11b1322
A lot of work done so far on log
Rinzii Mar 3, 2024
21213da
Merge remote-tracking branch 'origin/dev' into dev
Rinzii Mar 3, 2024
bafc897
log now far more efficient and accurate
Rinzii Mar 3, 2024
45418ad
Update readme progress
Rinzii Mar 3, 2024
03adbba
Continue work on log for double
Rinzii Mar 3, 2024
338553d
remove unnecessary include
Rinzii Mar 3, 2024
07c8765
remove msvc section of unlikely
Rinzii Mar 3, 2024
0e0599c
improve variable names
Rinzii Mar 3, 2024
9789dba
remove old log impl
Rinzii Mar 3, 2024
6445956
Cleanup double implementation of log
Rinzii Mar 3, 2024
36de4fe
cleanup of log details and add more comments.
Rinzii Mar 3, 2024
30d3051
Finalize work on log function
Rinzii Mar 3, 2024
3523153
Update current progress
Rinzii Mar 3, 2024
c1c2659
Fix bug with ±0 in log
Rinzii Mar 3, 2024
834e484
Update test cases to cover all major edge cases
Rinzii Mar 3, 2024
4cc8535
Move to correct folder
Rinzii Mar 4, 2024
931fa69
Add headers for log and log2
Rinzii Mar 4, 2024
ae68a13
Remove dependency on Threads
Rinzii Mar 4, 2024
f68bc93
Initial addition of Contribution Guide
Rinzii Mar 4, 2024
3414aaf
Cleanup README and add extra information
Rinzii Mar 4, 2024
24786e2
Update project version to v0.1.1
Rinzii Mar 4, 2024
4481133
Add top12 bits function for upcoming work
Rinzii Mar 4, 2024
b7f0efa
Finalize work with log function
Rinzii Mar 4, 2024
4de20f6
Initial working revision of log2
Rinzii Mar 4, 2024
22fba25
Push current work. Need to revise log2 to resolve bugs later.
Rinzii Mar 4, 2024
d4421ca
Initial implementation of lerp
Rinzii Mar 5, 2024
5494fcc
Fix scope bug
Rinzii Mar 5, 2024
849fbba
remove the direct use of cmath.
Rinzii Mar 9, 2024
6f10a00
Update include to use cfloat instead of float.h
Rinzii Mar 9, 2024
f5ee2a7
Cleanup macros and fix minor bugs
Rinzii Mar 9, 2024
0405f86
Fix bug where we were improperly assigning a correct value to the wro…
Rinzii Mar 9, 2024
c2cd877
Update docs to mention not accounting for big-endian
Rinzii Mar 9, 2024
79bc35c
Add comment to mention we are mirroring impl from cmath
Rinzii Mar 9, 2024
fc0d38f
Remove MSVC fallback that was inconsistent with every other impl
Rinzii Mar 9, 2024
e7bc089
Add additional helpers for future work
Rinzii Mar 9, 2024
339d3d5
Add test for static_assert support and some additional tests
Rinzii Mar 9, 2024
09ed3cd
Finalize implementation of log2
Rinzii Mar 9, 2024
b19c675
Remove static_assert for now
Rinzii Mar 9, 2024
b101a17
Update README.md
Rinzii Mar 9, 2024
90321ec
Merge remote-tracking branch 'origin/main' into dev
Rinzii Mar 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading