Skip to content

Commit

Permalink
More documentation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap committed Sep 24, 2023
1 parent b16f126 commit 65412d3
Show file tree
Hide file tree
Showing 83 changed files with 1,694 additions and 390 deletions.
2 changes: 1 addition & 1 deletion include/kyosu/complex/lrising_factorial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace kyosu::tags
template<eve::ordered_value T1, eve::ordered_value T2>
static KYOSU_FORCEINLINE auto deferred_call(auto, T1 const& v, T2 const& w) noexcept {
auto fn = callable_lrising_factorial{};
return fn(v, w); }
return fn(complex(v), complex(w)); }

template<typename T1, typename T2>
KYOSU_FORCEINLINE auto operator()(T1 const& target1, T2 const& target2) const noexcept -> decltype(eve::tag_invoke(*this, target1, target2))
Expand Down
78 changes: 0 additions & 78 deletions include/kyosu/complex/polar.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion include/kyosu/complex/rising_factorial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace kyosu::tags
template<eve::ordered_value T1, eve::ordered_value T2>
static KYOSU_FORCEINLINE auto deferred_call(auto, T1 const& v, T2 const& w) noexcept {
auto fn = callable_rising_factorial{};
return fn(v, w); }
return fn(complex(v), complex(w)); }

template<typename T1, typename T2>
KYOSU_FORCEINLINE auto operator()(T1 const& target1, T2 const& target2) const noexcept -> decltype(eve::tag_invoke(*this, target1, target2))
Expand Down
3 changes: 2 additions & 1 deletion include/kyosu/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
#include <kyosu/complex/log_abs_gamma.hpp>
#include <kyosu/complex/log_gamma.hpp>
#include <kyosu/complex/lrising_factorial.hpp>
#include <kyosu/complex/polar.hpp>
#include <kyosu/complex/rising_factorial.hpp>
#include <kyosu/complex/tgamma.hpp>
#include <kyosu/functions/to_polar.hpp>
Expand All @@ -152,8 +151,10 @@

#include <kyosu/functions/from_angle_axis.hpp>
#include <kyosu/functions/from_cylindrical.hpp>
#include <kyosu/functions/from_cylindricospherical.hpp>
#include <kyosu/functions/from_euler.hpp>
#include <kyosu/functions/from_multipolar.hpp>
#include <kyosu/functions/from_rotation_matrix.hpp>
#include <kyosu/functions/from_semipolar.hpp>
#include <kyosu/functions/from_spherical.hpp>
#include <kyosu/functions/rot_angle.hpp>
Expand Down
9 changes: 5 additions & 4 deletions include/kyosu/functions/convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace kyosu
//! @addtogroup functions
//! @{
//! @var convert
//! @brief Select a value between two arguments based on a logical mask
//! @brief convert to a target typek
//!
//! **Defined in Header**
//!
Expand All @@ -55,14 +55,15 @@ namespace kyosu
//! @code
//! namespace kyosu
//! {
//! template<eve::value T, eve::value U, eve::value V>
//! constexpr auto convert(T x, U, y, V z ) noexcept;
//! template<eve::value T, eve::value U, eve::value U>
//! constexpr auto convert(T x, eve::as<U> ) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `z` : Value to process.
//! * `x` : Value to process.
//! * `U``: target scalar type to convert to.
//!
//! **Return value**
//!
Expand Down
21 changes: 11 additions & 10 deletions include/kyosu/functions/from_angle_axis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,29 @@ namespace kyosu::tags

KYOSU_DEFERS_CALLABLE(from_angle_axis_);

template<eve::ordered_value V, eve::ordered_value U>
template<eve::ordered_value V, typename U>
static KYOSU_FORCEINLINE auto deferred_call(auto
, V const & angle
, std::span<U, 3> axis) noexcept
, V angle
, U axis) noexcept
{
auto q = quaternion(U(0), axis[0], axis[1], axis[2]);
using e_t = decltype(axis[0]+angle);
auto q = quaternion(e_t(0), e_t(axis[0]), e_t(axis[1]), e_t(axis[2]));
auto [s, c] = eve::sincos(angle*eve::half(eve::as(angle)));
return c+s*q;
}

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

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

Expand Down Expand Up @@ -83,7 +84,7 @@ namespace kyosu
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/quaternion/regular/conversions.cpp}
//! @godbolt{doc/from_angle_axis.cpp}
//! @}
//================================================================================================
inline constexpr tags::callable_from_angle_axis from_angle_axis = {};
Expand Down
2 changes: 1 addition & 1 deletion include/kyosu/functions/from_cylindrical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace kyosu
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/quaternion/regular/conversions.cpp}
//! @godbolt{doc/from_cylindrical.cpp}
//! @}
//================================================================================================
inline constexpr tags::callable_from_cylindrical from_cylindrical = {};
Expand Down
14 changes: 7 additions & 7 deletions include/kyosu/functions/from_cylindricospherical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ namespace kyosu::tags

template<eve::ordered_value V, eve::ordered_value U, eve::ordered_value W, eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto
, V const & r
, U const & angle
, W const & h1
, T const & h2) noexcept
, V const & t
, U const & radius
, W const & longitude
, T const & latitude) noexcept
{
auto [slat, clat] = eve::sincos(latitude);
auto [slon, clon] = eve::sincos(longitude);
auto f = r*clat;
return kyosu::quaternion(t, f*clon, f*slon, r*slat);
auto f = radius*clat;
return kyosu::quaternion(t, f*clon, f*slon, radius*slat);
}

template<typename T0, typename T1, typename T2, typename T3>
Expand Down Expand Up @@ -91,7 +91,7 @@ namespace kyosu
//!
//! #### Example
//!
//! @godbolt{doc/conversions.cpp}
//! @godbolt{doc/from_cylindrospherical.cpp}
//!
//! @}
//================================================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@

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

KYOSU_DEFERS_CALLABLE(from_multipolar_);
KYOSU_DEFERS_CALLABLE(from_cylindrospherical_);

template<eve::ordered_value V, eve::ordered_value U, eve::ordered_value W, eve::ordered_value T>
static KYOSU_FORCEINLINE auto deferred_call(auto
, V const & rho1
, U const & theta1
, W const & rho2
, T const & theta2) noexcept
, V const & t
, U const & radius
, W const & longitude
, T const & latitude) noexcept
{
auto [slat, clat] = eve::sincos(latitude);
auto [slon, clon] = eve::sincos(longitude);
auto f = r*clat;
return kyosu::quaternion(t, f*clon, f*slon, r*slat);
auto f = radius*clat;
return kyosu::quaternion(t, f*clon, f*slon, radius*slat);
}

template<typename T0, typename T1, typename T2, typename T3>
Expand All @@ -43,24 +43,25 @@ namespace kyosu::tags
}

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

namespace kyosu
{
//================================================================================================
//================================================================================================
//! @addtogroup quaternion
//! @{
//! @var from_multipolar
//!
//! @brief Callable object computing a quaternion from its multipolar representation.
//! @var from_cylindrospherical
//!
//! This function build quaternions in a way similar to the way polar builds complex numbers
//! from a multipolar representation of an \f$\mathbb{R}^4\f$ element.
//! @brief Callable object computing a quaternion from its cylindrospherical representation.
//!
//! from_multipolar the two \f$\mathbb{C}\f$ components of the quaternion are given in polar coordinates
//! cylindrospherical is specific to quaternions. It is often interesting to consider
//! \f$\mathbb{H}\f$ as the cartesian product of \f$\mathbb{R}\f$ by \f$\mathbb{R3}\f$
//! (the quaternionic multiplication has then a special form, as given here).
//! This function therefore builds a quaternion from this representation, with the \f$\mathbb{R3}\f$ component given
//! in usual \f$\mathbb{R3}\f$ spherical coordinates.
//!
//! **Defined in header**
//!
Expand All @@ -73,14 +74,14 @@ namespace kyosu
//! @code
//! namespace eve
//! {
//! auto from_multipolar( auto rho1, auto theta1 auto rho2, auto theta2) const noexcept;
//! auto from_cylindrospherical(auto t, auto radius, auto longitude, auto latitude) const noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//!`rho1`, `rho2`: the moduli
//! 'theta1', 'theta2': the angles in radian
//! * `t`, `radius`: the moduli
//! * `longitude`, `latitude`: angles in radian
//!
//! **Return value**
//!
Expand All @@ -90,9 +91,9 @@ namespace kyosu
//!
//! #### Example
//!
//! @godbolt{doc/quaternion/regular/conversions.cpp}
//! @godbolt{doc/from_cylindrospherical.cpp}
//!
//! @}
//================================================================================================
inline constexpr tags::callable_from_multipolar from_multipolar = {};
inline constexpr tags::callable_from_cylindrospherical from_cylindrospherical = {};
}
2 changes: 1 addition & 1 deletion include/kyosu/functions/from_euler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ namespace kyosu
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/quaternion/regular/from_euler.cpp}
//! @godbolt{doc/from_euler.cpp}
//! @}
//================================================================================================
inline constexpr tags::callable_from_euler from_euler = {};
Expand Down
2 changes: 1 addition & 1 deletion include/kyosu/functions/from_multipolar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace kyosu
//!
//! #### Example
//!
//! @godbolt{doc/quaternion/regular/conversions.cpp}
//! @godbolt{doc/from_multipolar.cpp}
//!
//! @}
//================================================================================================
Expand Down
2 changes: 1 addition & 1 deletion include/kyosu/functions/from_polar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace kyosu
//!
//! #### Example
//!
//! @godbolt{doc/quaternion/regular/from_polar.cpp}
//! @godbolt{doc/from_polar.cpp}
//!
//! @}
//================================================================================================
Expand Down
21 changes: 9 additions & 12 deletions include/kyosu/functions/from_rotation_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,21 @@ namespace kyosu::tags
auto r20pr02 = r[2][0] + r[0][2];
auto r12pr21 = r[1][2] + r[2][1];

auto h = half(as(r11pr22));
auto q0 = eve::sqrt(eve::if_else(is_gtz(qq0m1), eve::inc(qq0m1), (eve::sqr(r21mr12)+sqr(r02mr20)+eve::sqr(r10mr01))/(3-qq0m1)))*h;
auto q1 = eve::sqrt(eve::if_else(is_gtz(qq1m1), eve::inc(qq1m1), (eve::sqr(r21mr12)+sqr(r01pr10)+eve::sqr(r20pr02))/(3-qq1m1)))*h;
auto q2 = eve::sqrt(eve::if_else(is_gtz(qq2m1), eve::inc(qq2m1), (eve::sqr(r02mr20)+sqr(r01pr10)+eve::sqr(r12pr21))/(3-qq2m1)))*h;
auto q3 = eve::sqrt(eve::if_else(is_gtz(qq3m1), eve::inc(qq3m1), (eve::sqr(r10mr01)+sqr(r20pr02)+eve::sqr(r12pr21))/(3-qq3m1)))*h;
auto h = eve::half(eve::as(r11pr22));
auto q0 = eve::sqrt(eve::if_else(eve::is_gtz(qq0m1), eve::inc(qq0m1), (eve::sqr(r21mr12)+sqr(r02mr20)+eve::sqr(r10mr01))/(3-qq0m1)))*h;
auto q1 = eve::sqrt(eve::if_else(eve::is_gtz(qq1m1), eve::inc(qq1m1), (eve::sqr(r21mr12)+sqr(r01pr10)+eve::sqr(r20pr02))/(3-qq1m1)))*h;
auto q2 = eve::sqrt(eve::if_else(eve::is_gtz(qq2m1), eve::inc(qq2m1), (eve::sqr(r02mr20)+sqr(r01pr10)+eve::sqr(r12pr21))/(3-qq2m1)))*h;
auto q3 = eve::sqrt(eve::if_else(eve::is_gtz(qq3m1), eve::inc(qq3m1), (eve::sqr(r10mr01)+sqr(r20pr02)+eve::sqr(r12pr21))/(3-qq3m1)))*h;
using e_t = decltype(r11pr22);
return quaternion(q0, q1, q2, q3);
}

template<typename T0, typename T1, typename T2, typename T3>
KYOSU_FORCEINLINE auto operator()(T0 const& target0,
T1 const& target1,
T2 const& target2,
T3 const& target3
template<typename T0>
KYOSU_FORCEINLINE auto operator()(T0 const& target0
) const noexcept
-> decltype(eve::tag_invoke(*this, target0, target1, target2, target3))
-> decltype(eve::tag_invoke(*this, target0))
{
return eve::tag_invoke(*this, target0, target1, target2, target3);
return eve::tag_invoke(*this, target0);
}

template<typename... T>
Expand Down
2 changes: 1 addition & 1 deletion include/kyosu/functions/from_semipolar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ namespace kyosu
//!
//! @groupheader{Example}
//!
//! @godbolt{doc/quaternion/regular/conversions.cpp}
//! @godbolt{doc/from_semipolar.cpp}
//! @}
//================================================================================================
inline constexpr tags::callable_from_semipolar from_semipolar = {};
Expand Down
Loading

0 comments on commit 65412d3

Please sign in to comment.