Skip to content

Commit

Permalink
sec csc
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap committed Aug 29, 2023
1 parent a4e7ca6 commit 53afa21
Show file tree
Hide file tree
Showing 12 changed files with 561 additions and 23 deletions.
4 changes: 4 additions & 0 deletions include/kyosu/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <kyosu/functions/cosh.hpp>
#include <kyosu/functions/cot.hpp>
#include <kyosu/functions/coth.hpp>
#include <kyosu/functions/csc.hpp>
#include <kyosu/functions/csch.hpp>
#include <kyosu/functions/dec.hpp>
#include <kyosu/functions/dist.hpp>
#include <kyosu/functions/exp.hpp>
Expand Down Expand Up @@ -62,6 +64,8 @@
#include <kyosu/functions/real.hpp>
#include <kyosu/functions/rec.hpp>
#include <kyosu/functions/reldist.hpp>
#include <kyosu/functions/sec.hpp>
#include <kyosu/functions/sech.hpp>
#include <kyosu/functions/sin.hpp>
#include <kyosu/functions/sincos.hpp>
#include <kyosu/functions/sinh.hpp>
Expand Down
74 changes: 74 additions & 0 deletions include/kyosu/functions/csc.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//======================================================================================================================
/*
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_csc : eve::elementwise
{
using callable_tag_type = callable_csc;

KYOSU_DEFERS_CALLABLE(csc_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::csc(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_csc(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var csc
//! @brief Computes the cosecant 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 csc(T z) noexcept;
//! template<eve::ordered_value T> constexpr T csc(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! Returns the cosecant of the argument.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/csc.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_csc csc = {};
}
74 changes: 74 additions & 0 deletions include/kyosu/functions/csch.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//======================================================================================================================
/*
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_csch : eve::elementwise
{
using callable_tag_type = callable_csch;

KYOSU_DEFERS_CALLABLE(csch_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::csch(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_csch(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var csch
//! @brief Computes the hyperbolic cscant 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 csch(T z) noexcept;
//! template<eve::ordered_value T> constexpr T csch(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! Returns the hyperbolic cscant of the argument.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/csch.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_csch csch = {};
}
74 changes: 74 additions & 0 deletions include/kyosu/functions/sec.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//======================================================================================================================
/*
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_sec : eve::elementwise
{
using callable_tag_type = callable_sec;

KYOSU_DEFERS_CALLABLE(sec_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sec(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_sec(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var sec
//! @brief Computes the secant 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 sec(T z) noexcept;
//! template<eve::ordered_value T> constexpr T sec(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! Returns the secant of the argument.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/sec.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_sec sec = {};
}
74 changes: 74 additions & 0 deletions include/kyosu/functions/sech.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//======================================================================================================================
/*
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_sech : eve::elementwise
{
using callable_tag_type = callable_sech;

KYOSU_DEFERS_CALLABLE(sech_);

template<eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto, T const& v) noexcept { return eve::sech(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_sech(T&&...)> operator()(T&&... x) const
requires(!requires { eve::tag_invoke(*this, KYOSU_FWD(x)...); }) = delete;
};
}

namespace kyosu
{
//======================================================================================================================
//! @addtogroup functions
//! @{
//! @var sech
//! @brief Computes the hyperbolic secant 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 sech(T z) noexcept;
//! template<eve::ordered_value T> constexpr T sech(T z) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//!
//! **Return value**
//!
//! Returns the hyperbolic secant of the argument.
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/sech.cpp}
//! @}
//======================================================================================================================
inline constexpr tags::callable_sech sech = {};
}
46 changes: 23 additions & 23 deletions include/kyosu/types/impl/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,21 @@ namespace kyosu::_
auto v = kyosu::pure(z);
auto s = kyosu::real(z);
auto z1 = (eve::acos(s/az)/abs(v))*v+eve::log(az);
auto tmp = kyosu::if_else( kyosu::is_real(z)
, kyosu::log(kyosu::real(z))
, z1
);
return tmp;
// auto tmp = kyosu::if_else( kyosu::is_real(z)
// , kyosu::log(kyosu::real(z))
// , z1
// );
// return tmp;

return kyosu::if_else( kyosu::is_eqz(z)
, eve::minf(eve::as(az))
, tmp
);

// return kyosu::if_else( kyosu::is_eqz(z)
// return kyosu::if_else( kyosu::is_eqz(z)
// , eve::minf(eve::as(az))
// , z1
// , tmp
// );

return kyosu::if_else( kyosu::is_eqz(z)
, eve::minf(eve::as(az))
, z1
);
}
}

Expand Down Expand Up @@ -248,21 +248,21 @@ namespace kyosu::_
auto v = kyosu::pure(z);
auto s = kyosu::real(incz);
auto z1 = (eve::acos(s/az)/abs(v))*v+ eve::half(eve::as<e_t>())*eve::log1p(az2);
auto tmp = kyosu::if_else( kyosu::is_real(z)
, kyosu::log(kyosu::real(z))
, z1
);
return tmp;

return kyosu::if_else( kyosu::is_eqz(z)
, eve::minf(eve::as(az))
, tmp
);
// auto tmp = kyosu::if_else( kyosu::is_real(z)
// , kyosu::log(kyosu::real(z))
// , z1
// );
// return tmp;

// return kyosu::if_else( kyosu::is_eqz(z)
// , eve::minf(eve::as(az))
// , z1
// , tmp
// );

return kyosu::if_else( kyosu::is_eqz(z)
, eve::minf(eve::as(az))
, z1
);
}
}
}
Loading

0 comments on commit 53afa21

Please sign in to comment.