Skip to content

Commit

Permalink
Apply formatting to all files not conforming to our clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinzii committed Apr 2, 2024
1 parent f4d8bac commit fc247d1
Show file tree
Hide file tree
Showing 46 changed files with 505 additions and 534 deletions.
2 changes: 1 addition & 1 deletion include/ccmath/basic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
#include "ccmath/math/basic/fmod.hpp"
#include "ccmath/math/basic/max.hpp"
#include "ccmath/math/basic/min.hpp"
#include "ccmath/math/basic/nan.hpp"
#include "ccmath/math/basic/remainder.hpp"
#include "ccmath/math/basic/remquo.hpp"
#include "ccmath/math/basic/nan.hpp"
54 changes: 27 additions & 27 deletions include/ccmath/math/basic/abs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

#pragma once

#include "ccmath/math/compare/isnan.hpp"
#include "ccmath/internal/predef/unlikely.hpp"
#include "ccmath/math/compare/isinf.hpp"
#include <array>
#include <limits>
#include "ccmath/internal/predef/unlikely.hpp"
#include "ccmath/math/compare/isinf.hpp"
#include "ccmath/math/compare/isnan.hpp"

namespace ccm
{
Expand All @@ -25,8 +25,8 @@ namespace ccm
template <typename T, std::enable_if_t<!std::is_integral_v<T> && !std::is_unsigned_v<T>, bool> = true>
constexpr T abs(T num) noexcept
{
// If num is NaN, return a quiet NaN.
if (CCM_UNLIKELY(ccm::isnan<T>(num))) { return std::numeric_limits<T>::quiet_NaN(); }
// If num is NaN, return a quiet NaN.
if (CCM_UNLIKELY(ccm::isnan<T>(num))) { return std::numeric_limits<T>::quiet_NaN(); }

// If num is equal to ±zero, return +zero.
if (static_cast<T>(0) == num) { return static_cast<T>(0); }
Expand Down Expand Up @@ -82,16 +82,16 @@ namespace ccm
}

/**
* @brief Computes the absolute value of a number.
* @tparam Integer Integer type.
* @param x Integer value.
* @return If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.
*/
* @brief Computes the absolute value of a number.
* @tparam Integer Integer type.
* @param x Integer value.
* @return If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.
*/
template <typename Integer, std::enable_if_t<std::is_integral_v<Integer>, bool> = true>
constexpr double fabs(Integer num) noexcept
{
return abs<double>(static_cast<double>(num));
}
{
return abs<double>(static_cast<double>(num));
}

/**
* @brief Computes the absolute value of a number.
Expand All @@ -114,24 +114,24 @@ namespace ccm
}

/**
* @brief Computes the absolute value of a number.
* @param x Integer value.
* @return If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.
*/
* @brief Computes the absolute value of a number.
* @param x Integer value.
* @return If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.
*/
inline constexpr long labs(long num) noexcept
{
return abs<long>(num);
}
{
return abs<long>(num);
}

/**
* @brief Computes the absolute value of a number.
* @param x Integer value.
* @return If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.
*/
* @brief Computes the absolute value of a number.
* @param x Integer value.
* @return If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.
*/
inline constexpr long long llabs(long long num) noexcept
{
return abs<long long>(num);
}
{
return abs<long long>(num);
}
} // namespace ccm

/// @ingroup basic
8 changes: 4 additions & 4 deletions include/ccmath/math/basic/fdim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#pragma once

#include "ccmath/math/compare/isnan.hpp"
#include "ccmath/internal/predef/unlikely.hpp"
#include <limits>
#include <type_traits>
#include "ccmath/internal/predef/unlikely.hpp"
#include "ccmath/math/compare/isnan.hpp"

namespace ccm
{
Expand All @@ -25,8 +25,8 @@ namespace ccm
template <typename T, std::enable_if_t<std::is_floating_point_v<T>, int> = 0>
inline constexpr T fdim(T x, T y)
{
if (CCM_UNLIKELY(ccm::isnan(x))) { return x; }
if (CCM_UNLIKELY(ccm::isnan(y))) { return y; }
if (CCM_UNLIKELY(ccm::isnan(x))) { return x; }
if (CCM_UNLIKELY(ccm::isnan(y))) { return y; }
if (x <= y) { return static_cast<T>(+0.0); }
if ((y < static_cast<T>(0.0)) && (x > (std::numeric_limits<T>::max() + y))) { return std::numeric_limits<T>::infinity(); }
return x - y;
Expand Down
25 changes: 14 additions & 11 deletions include/ccmath/math/basic/fma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace ccm
inline constexpr T new_fma(T x, T y, T z) noexcept
{
if constexpr (std::is_same_v<T, float>) { return ccm::internal::impl::fma_float_impl(x, y, z); }
else { return ccm::internal::impl::fma_double_impl(x, y, z); }
else { return ccm::internal::impl::fma_double_impl(x, y, z); }
}

/**
Expand All @@ -38,16 +38,19 @@ namespace ccm
template <typename T, std::enable_if_t<!std::is_integral_v<T>, bool> = true>
inline constexpr T fma(T x, T y, T z) noexcept
{
// Handle infinity
if (CCM_UNLIKELY((x == static_cast<T>(0) && ccm::isinf(y)) || (y == T{0} && ccm::isinf(x)))) { return std::numeric_limits<T>::quiet_NaN(); }
if (CCM_UNLIKELY(x * y == std::numeric_limits<T>::infinity() && z == -std::numeric_limits<T>::infinity())) { return std::numeric_limits<T>::infinity(); }

// Handle NaN
if (CCM_UNLIKELY(ccm::isnan(x) || ccm::isnan(y))) { return std::numeric_limits<T>::quiet_NaN(); }
if (CCM_UNLIKELY(ccm::isnan(z) && (x * y != 0 * std::numeric_limits<T>::infinity() || x * y != std::numeric_limits<T>::infinity() * 0)))
{
return std::numeric_limits<T>::quiet_NaN();
}
// Handle infinity
if (CCM_UNLIKELY((x == static_cast<T>(0) && ccm::isinf(y)) || (y == T{0} && ccm::isinf(x)))) { return std::numeric_limits<T>::quiet_NaN(); }
if (CCM_UNLIKELY(x * y == std::numeric_limits<T>::infinity() && z == -std::numeric_limits<T>::infinity()))
{
return std::numeric_limits<T>::infinity();
}

// Handle NaN
if (CCM_UNLIKELY(ccm::isnan(x) || ccm::isnan(y))) { return std::numeric_limits<T>::quiet_NaN(); }
if (CCM_UNLIKELY(ccm::isnan(z) && (x * y != 0 * std::numeric_limits<T>::infinity() || x * y != std::numeric_limits<T>::infinity() * 0)))
{
return std::numeric_limits<T>::quiet_NaN();
}

// We have to hope the compiler optimizes this. Currently there is no builtin fma that works with static_assert.
return (x * y) + z;
Expand Down
2 changes: 1 addition & 1 deletion include/ccmath/math/basic/fmod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace ccm
}

} // namespace impl
} // namespace
} // namespace
/// @endcond

/**
Expand Down
10 changes: 5 additions & 5 deletions include/ccmath/math/basic/impl/fma_double_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#pragma once

#include "ccmath/internal/predef/unlikely.hpp"
#include "ccmath/internal/support/bits.hpp"
#include <cstdint>
#include <limits>
#include "ccmath/internal/predef/unlikely.hpp"
#include "ccmath/internal/support/bits.hpp"

namespace ccm::internal
{
Expand All @@ -20,12 +20,12 @@ namespace ccm::internal
namespace impl
{
inline constexpr double fma_double_impl(double x, double y, double z) noexcept
{
{

//#pragma STDC FENV_ACCESS ON
// #pragma STDC FENV_ACCESS ON

return 0;
}
}
} // namespace impl
} // namespace
} // namespace ccm::internal
36 changes: 16 additions & 20 deletions include/ccmath/math/basic/impl/fma_float_impl.hpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
/*
* Copyright (c) 2024-Present Ian Pike
* Copyright (c) 2024-Present ccmath contributors
*
* This library is provided under the MIT License.
* See LICENSE for more information.
*/
* Copyright (c) 2024-Present Ian Pike
* Copyright (c) 2024-Present ccmath contributors
*
* This library is provided under the MIT License.
* See LICENSE for more information.
*/

#pragma once

namespace ccm::internal
{
namespace
{
namespace impl
{
inline constexpr double fma_float_impl(double x, double y, double z) noexcept
{
namespace
{
namespace impl
{
inline constexpr double fma_float_impl(double x, double y, double z) noexcept
{





return 0;
}
} // namespace impl
} // namespace
return 0;
}
} // namespace impl
} // namespace
} // namespace ccm::internal
10 changes: 5 additions & 5 deletions include/ccmath/math/basic/impl/fma_ldouble_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#pragma once

#include "ccmath/internal/predef/unlikely.hpp"
#include "ccmath/internal/support/bits.hpp"
#include <cstdint>
#include <limits>
#include "ccmath/internal/predef/unlikely.hpp"
#include "ccmath/internal/support/bits.hpp"

namespace ccm::internal
{
Expand All @@ -20,12 +20,12 @@ namespace ccm::internal
namespace impl
{
inline constexpr double fma_double_impl(double x, double y, double z) noexcept
{
{

//#pragma STDC FENV_ACCESS ON
// #pragma STDC FENV_ACCESS ON

return 0;
}
}
} // namespace impl
} // namespace
} // namespace ccm::internal
Loading

0 comments on commit fc247d1

Please sign in to comment.