Skip to content

Commit

Permalink
Implements exp
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap authored Aug 25, 2023
1 parent 80c7368 commit 7c05692
Show file tree
Hide file tree
Showing 15 changed files with 700 additions and 26 deletions.
52 changes: 26 additions & 26 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@ concurrency:

jobs:

windows:
runs-on: [windows-2022]
strategy:
fail-fast: false
matrix:
cfg:
- { tool: "-T ClangCL", config: Debug }
- { tool: "-T ClangCL", config: Release }
# - { tool: , config: Debug }
# - { tool: , config: Release }
steps:
- name: Fetch current branch
uses: actions/checkout@v3
- name: Running CMake for MSVC
run: |
mkdir build && cd build
cmake -G "Visual Studio 17 2022" ${{ matrix.cfg.tool }} -A x64 ..
- name: Compiling Unit Tests
run: |
cd build
cmake --build . --target kyosu-test --config ${{ matrix.cfg.config }} --parallel 2
cmake --build . --target kyosu-test --config Release --parallel 2
- name: Running Tests
run: |
cd build
ctest -C ${{ matrix.cfg.config }} --output-on-failure
# windows:
# runs-on: [windows-2022]
# strategy:
# fail-fast: false
# matrix:
# cfg:
# - { tool: "-T ClangCL", config: Debug }
# - { tool: "-T ClangCL", config: Release }
# # - { tool: , config: Debug }
# # - { tool: , config: Release }
# steps:
# - name: Fetch current branch
# uses: actions/checkout@v3
# - name: Running CMake for MSVC
# run: |
# mkdir build && cd build
# cmake -G "Visual Studio 17 2022" ${{ matrix.cfg.tool }} -A x64 ..
# - name: Compiling Unit Tests
# run: |
# cd build
# cmake --build . --target kyosu-test --config ${{ matrix.cfg.config }} --parallel 2
# cmake --build . --target kyosu-test --config Release --parallel 2
# - name: Running Tests
# run: |
# cd build
# ctest -C ${{ matrix.cfg.config }} --output-on-failure

linux:
runs-on: [ubuntu-latest]
Expand Down
4 changes: 4 additions & 0 deletions include/kyosu/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <kyosu/functions/conj.hpp>
#include <kyosu/functions/dec.hpp>
#include <kyosu/functions/dist.hpp>
#include <kyosu/functions/exp.hpp>
#include <kyosu/functions/floor.hpp>
#include <kyosu/functions/frac.hpp>
#include <kyosu/functions/if_else.hpp>
Expand All @@ -33,12 +34,15 @@
#include <kyosu/functions/is_not_finite.hpp>
#include <kyosu/functions/is_not_infinite.hpp>
#include <kyosu/functions/is_not_nan.hpp>
#include <kyosu/functions/is_not_real.hpp>
#include <kyosu/functions/is_real.hpp>
#include <kyosu/functions/jpart.hpp>
#include <kyosu/functions/kpart.hpp>
#include <kyosu/functions/lerp.hpp>
#include <kyosu/functions/minus.hpp>
#include <kyosu/functions/nearest.hpp>
#include <kyosu/functions/oneminus.hpp>
#include <kyosu/functions/pure.hpp>
#include <kyosu/functions/purepart.hpp>
#include <kyosu/functions/real.hpp>
#include <kyosu/functions/reldist.hpp>
Expand Down
76 changes: 76 additions & 0 deletions include/kyosu/functions/exp.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//======================================================================================================================
/*
Kyosu - Complex Without Complexes
Copyright : KYOSU Contributors & Maintainers
SPDX-License-Identifier: BSL-1.0
*/
//======================================================================================================================
#pragma once

#include <kyosu/details/invoke.hpp>
#include <eve/module/math.hpp>

namespace kyosu::tags
{
struct callable_exp : eve::elementwise
{
using callable_tag_type = callable_exp;

KYOSU_DEFERS_CALLABLE(exp_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::exp(v); }

template<typename T>
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target))
{
return eve::tag_invoke(*this, target);
}

template<typename... T>
eve::unsupported_call<callable_exp(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var exp
//! @brief Computes the exponential of the argument.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr T exp(T z) noexcept;
//! template<eve::ordered_value T> constexpr T exp(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! Returns the exponential of the argument.
//!
//! For real inputs the call reduces to identity.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/exp.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_exp exp = {};
}
73 changes: 73 additions & 0 deletions include/kyosu/functions/is_not_real.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//======================================================================================================================
/*
Kyosu - Complex Without Complexes
Copyright : KYOSU Contributors & Maintainers
SPDX-License-Identifier: BSL-1.0
*/
//======================================================================================================================
#pragma once

#include <kyosu/details/invoke.hpp>

namespace kyosu::tags
{
struct callable_is_not_real : eve::elementwise
{
using callable_tag_type = callable_is_not_real;

KYOSU_DEFERS_CALLABLE(is_not_real_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::false_(eve::as(v)); }

template<typename T>
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target))
{
return eve::tag_invoke(*this, target);
}

template<typename... T>
eve::unsupported_call<callable_is_not_real(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var is_not_real
//! @brief test if the parameter is not_real.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr auto is_not_real(T z) noexcept;
//! template<eve::ordered_value T> constexpr auto is_not_real(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! Returns elementwise true is any of the non real parts of the argument is not zero.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/is_not_real.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_is_not_real is_not_real = {};
}
73 changes: 73 additions & 0 deletions include/kyosu/functions/is_real.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//======================================================================================================================
/*
Kyosu - Complex Without Complexes
Copyright : KYOSU Contributors & Maintainers
SPDX-License-Identifier: BSL-1.0
*/
//======================================================================================================================
#pragma once

#include <kyosu/details/invoke.hpp>

namespace kyosu::tags
{
struct callable_is_real : eve::elementwise
{
using callable_tag_type = callable_is_real;

KYOSU_DEFERS_CALLABLE(is_real_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::true_(eve::as(v)); }

template<typename T>
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target))
{
return eve::tag_invoke(*this, target);
}

template<typename... T>
eve::unsupported_call<callable_is_real(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var is_real
//! @brief test if the parameter is real.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr auto is_real(T z) noexcept;
//! template<eve::ordered_value T> constexpr auto is_real(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! Returns elementwise true is all the non real parts of the argument are zero.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/is_real.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_is_real is_real = {};
}
83 changes: 83 additions & 0 deletions include/kyosu/functions/pure.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//======================================================================================================================
/*
Kyosu - Complex Without Complexes
Copyright : KYOSU Contributors & Maintainers
SPDX-License-Identifier: BSL-1.0
*/
//======================================================================================================================
#pragma once

#include <kyosu/details/invoke.hpp>

namespace kyosu::tags
{
struct callable_pure
{
using callable_tag_type = callable_pure;

KYOSU_DEFERS_CALLABLE(pure_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::zero(as(v)); }

template<typename T>
KYOSU_FORCEINLINE auto operator()(T const& target) const noexcept -> decltype(eve::tag_invoke(*this, target))
{
return eve::tag_invoke(*this, target);
}

template<typename T>
KYOSU_FORCEINLINE auto operator()(T& target) const noexcept -> decltype(eve::tag_invoke(*this, target))
{
return eve::tag_invoke(*this, target);
}

template<typename... T>
eve::unsupported_call<callable_pure(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var imag
//! @brief Extracts the imaginary part of a value.
//!
//! **Defined in Header**
//!
//! @code
//! #include <kyosu/functions.hpp>
//! @endcode
//!
//! @groupheader{Callable Signatures}
//!
//! @code
//! namespace kyosu
//! {
//! template<kyosu::concepts::cayley_dickson T> constexpr auto& pure(T& z) noexcept;
//! template<kyosu::concepts::cayley_dickson T> constexpr auto pure(T const& z) noexcept;
//! template<eve::ordered_value T> constexpr T pure(T const& z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Original value.
//!
//! **Return value**
//!
//! Returns the imaginary part of its argument. For real inputs, the call returns 0. It is an alias of `imag`.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/imag.cpp}
//======================================================================================================================
inline constexpr tags::callable_pure pure = {};

//======================================================================================================================
//! @}
//======================================================================================================================
}
1 change: 1 addition & 0 deletions include/kyosu/types/cayley_dickson.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <kyosu/types/traits.hpp>
#include <kyosu/types/impl/arithmetic.hpp>
#include <kyosu/types/impl/predicates.hpp>
#include <kyosu/types/impl/math.hpp>
#include <bit>

namespace kyosu
Expand Down
Loading

0 comments on commit 7c05692

Please sign in to comment.