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

Tchebytchev 2 #1292

Merged
merged 33 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ea04609
tchebychev polynomials in polynomial
jtlap Mar 10, 2022
e78bc43
beginning tests of tchebytchev
jtlap Mar 11, 2022
e489efc
tchebytchev_u beginning
jtlap Mar 11, 2022
fa6aac6
chebytchev_u.hpp
jtlap Mar 27, 2022
a61c4fa
tcheb successor
jtlap Apr 10, 2022
911b8a3
tvhebeval+three_fma
jtlap Apr 12, 2022
ed6af71
horner and reverse_horner
jtlap Apr 12, 2022
c68cad9
newton
jtlap Apr 12, 2022
796fc2a
horner comensated
jtlap Apr 13, 2022
b11cb91
tchebytchev second kind
jtlap Apr 14, 2022
186d903
tchrbytchev successor
jtlap Apr 14, 2022
3c3ac4f
tchebeval
jtlap Apr 14, 2022
a6d989e
rm spurious files
jtlap Apr 28, 2022
b0673b4
some cleaning
jtlap May 1, 2022
757f5f2
horner reverse_horner tchebytchev cpp
jtlap May 2, 2022
47d8ae0
newton
jtlap May 3, 2022
07a879a
incorrect assert in newton
jtlap May 3, 2022
f1e8c39
incorrect assert in newton
jtlap May 3, 2022
cf6469f
bad test
jtlap May 3, 2022
6ab7566
ulp pb
jtlap May 3, 2022
4f4bada
missing include
jtlap May 3, 2022
febd477
typo in three_fma
jtlap May 3, 2022
9ce8879
typo in three_fma
jtlap May 3, 2022
867e59a
temporarily no references to three_fma
jtlap May 3, 2022
6540c69
completing apply_over3
jtlap May 3, 2022
9db512c
try not using input_range in horner
jtlap May 3, 2022
984fd18
error in two_prod
jtlap May 3, 2022
1853c68
suppressing include of ranges
jtlap May 3, 2022
53ac21b
suppressing use of std::ranges
jtlap May 4, 2022
b03de77
getting rid of stdgit stranges
jtlap May 4, 2022
e02886c
joel remarks
jtlap May 22, 2022
c8798d3
comp -> compensated
jtlap May 23, 2022
661cd34
comp -> compensated
jtlap May 23, 2022
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
20 changes: 20 additions & 0 deletions include/eve/detail/apply_over.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,24 @@ namespace eve::detail
}
else return f(v);
}


template<typename Obj, simd_value T>
EVE_FORCEINLINE auto apply_over3(Obj f, T const & v, T const &w, T const & z)
{
if constexpr(has_emulated_abi_v<T> ) return map(f, v, w, z);
else if constexpr(has_aggregated_abi_v<T>)
{
auto [vlo, vhi] = v.slice();
auto [wlo, whi] = w.slice();
auto [zlo, zhi] = z.slice();
auto [nhi, xhi, dxhi] = f(vhi, whi, zhi);
auto [nlo, xlo, dxlo] = f(vlo, wlo, zlo);
return kumi::make_tuple ( eve::combine( nlo, nhi)
, eve::combine( xlo, xhi)
, eve::combine( dxlo, dxhi)
);
}
else return f(v, w, z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@
//==================================================================================================
#pragma once


#include <eve/module/core/detail/tchebeval.hpp>
#include <eve/module/polynomial/diff/tchebytchev.hpp>
10 changes: 10 additions & 0 deletions include/eve/function/tchebytchev.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//==================================================================================================
/*
EVE - Expressive Vector Engine
Copyright : EVE Contributors & Maintainers
SPDX-License-Identifier: MIT
*/
//==================================================================================================
#pragma once

#include <eve/module/polynomial/regular/tchebytchev.hpp>
56 changes: 56 additions & 0 deletions include/eve/module/core/decorator/comp.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//==================================================================================================
/*
EVE - Expressive Vector Engine
Copyright : EVE Contributors & Maintainers
SPDX-License-Identifier: MIT
*/
//==================================================================================================
#pragma once

#include <eve/detail/overload.hpp>

namespace eve
{
template<auto Param> struct diff_;
//================================================================================================
//================================================================================================
// Function decorators mark-up used in function overloads
struct comp_
{
template<auto N> static constexpr auto combine( decorated<diff_<N>()> const& ) noexcept
{
return decorated<diff_<N>(comp_)>{};
}
};

using comp_type = decorated<comp_()>;
//================================================================================================
//! @addtogroup core
//! @{
//! @var comp
//!
//! @brief Higher-order @callable imbuing more more accuracy onto other @callable{s}.
//!
//! #### Synopsis
//!
//! if comp(eve::fname) is to be called then
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
//! #include <eve/module/core.hpp>
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//! must be included.
//!
//! #### Members Functions
//!
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
//! auto operator()(eve::callable auto const& f ) const noexcept;
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//! @param f
//! An instance of eve::callable
//!
//! @return
//! A @callable performing the same kind of operation but ensuring a higher accuracy.
//!
//! @}
//================================================================================================
[[maybe_unused]] inline constexpr comp_type const comp = {};
jfalcou marked this conversation as resolved.
Show resolved Hide resolved
}
1 change: 1 addition & 0 deletions include/eve/module/core/decorator/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//==================================================================================================
#pragma once

#include <eve/module/core/decorator/comp.hpp>
#include <eve/module/core/decorator/cyl.hpp>
#include <eve/module/core/decorator/fuzzy.hpp>
#include <eve/module/core/decorator/kind.hpp>
Expand Down
63 changes: 63 additions & 0 deletions include/eve/module/core/decorator/kind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,67 @@ namespace eve
//! @}
//================================================================================================
inline constexpr q_kind_type const q_kind = {};

jfalcou marked this conversation as resolved.
Show resolved Hide resolved
//================================================================================================
//================================================================================================
// Function decorators mark-up used in function overloads
struct kind_1_
{
template<auto N> static constexpr auto combine( decorated<diff_<N>()> const& ) noexcept
{
return decorated<diff_<N>(kind_1_)>{};
}
};

using kind_1_type = decorated<kind_1_()>;
//================================================================================================
//! @addtogroup polynomial
//! @{
//! @var kind_1
//!
//! @brief Higher-order @callable imbuing kind_1 behaviour onto other @callable{s}.
//!
//! #### Synopsis
//!
//! @param f
//! An instance of eve::callable
//!
//! @return
//! A @callable performing the kind_1 algorithm choice
//!
//! @}
//================================================================================================
inline constexpr kind_1_type const kind_1 = {};

//================================================================================================
//================================================================================================
// Function decorators mark-up used in function overloads
struct kind_2_
{
template<auto N> static constexpr auto combine( decorated<diff_<N>()> const& ) noexcept
{
return decorated<diff_<N>(kind_2_)>{};
}
};

using kind_2_type = decorated<kind_2_()>;
//================================================================================================
//! @addtogroup polynomial
//! @{
//! @var kind_2
//!
//! @brief Higher-order @callable imbuing kind_2 behaviour onto other @callable{s}.
//!
//! #### Synopsis
//!
//! @param f
//! An instance of eve::callable
//!
//! @return
//! A @callable performing the kind_2 algorithm choice
//!
//! @}
//================================================================================================
inline constexpr kind_2_type const kind_2 = {};

}
1 change: 0 additions & 1 deletion include/eve/module/core/detail/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@
#include <eve/module/core/detail/multi_div.hpp>
#include <eve/module/core/detail/multi_mul.hpp>
#include <eve/module/core/detail/next_kernel.hpp>
#include <eve/module/core/detail/tchebeval.hpp>
1 change: 1 addition & 0 deletions include/eve/module/core/regular/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
#include <eve/module/core/regular/sqr.hpp>
#include <eve/module/core/regular/sqrt.hpp>
#include <eve/module/core/regular/sub.hpp>
#include <eve/module/core/regular/three_fma.hpp>
#include <eve/module/core/regular/trunc.hpp>
#include <eve/module/core/regular/two_add.hpp>
#include <eve/module/core/regular/two_prod.hpp>
Expand Down
39 changes: 39 additions & 0 deletions include/eve/module/core/regular/impl/three_fma.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//==================================================================================================
/*
EVE - Expressive Vector Engine
Copyright : EVE Contributors & Maintainers
SPDX-License-Identifier: MIT
*/
//==================================================================================================
#pragma once

#include <eve/module/core/regular/if_else.hpp>
#include <eve/concept/value.hpp>
#include <eve/detail/apply_over.hpp>
#include <eve/detail/kumi.hpp>
#include <eve/detail/implementation.hpp>
#include <eve/module/core/regular/is_not_finite.hpp>
#include <eve/module/core/regular/two_prod.hpp>
#include <eve/module/core/regular/two_add.hpp>
#include <eve/platform.hpp>

namespace eve::detail
{
template<floating_real_value T>
EVE_FORCEINLINE kumi::tuple<T, T, T>
three_fma_(EVE_SUPPORTS(cpu_)
jfalcou marked this conversation as resolved.
Show resolved Hide resolved
, const T& a
, const T& b
, const T& c) noexcept
{
if constexpr(has_native_abi_v<T>)
{
auto x = numeric(fma)(a, b, c);
auto [u1, u2] = two_prod(a, b);
auto [a1, z2] = two_add(b, u2);
auto [b1, b2] = two_add(u1, a1);
return {x, (b1-x)+b2, z2};
}
else return apply_over3(three_fma, a, b, c);
}
}
48 changes: 48 additions & 0 deletions include/eve/module/core/regular/impl/threefma.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//==================================================================================================
/*
EVE - Expressive Vector Engine
Copyright : EVE Contributors & Maintainers
SPDX-License-Identifier: MIT
*/
//==================================================================================================
#pragma once

#include <eve/module/core/regular/if_else.hpp>
#include <eve/concept/value.hpp>
#include <eve/detail/apply_over.hpp>
#include <eve/detail/kumi.hpp>
#include <eve/detail/implementation.hpp>
#include <eve/module/core/regular/is_not_finite.hpp>
#include <eve/module/core/regular/two_split.hpp>
#include <eve/platform.hpp>

namespace eve::detail
{
template<floating_real_value T>
EVE_FORCEINLINE kumi::tuple<T, T>
two_prod_(EVE_SUPPORTS(cpu_)
, const T& a
, const T& b) noexcept
{
if constexpr(has_native_abi_v<T>)
{
if constexpr(eve::platform::supports_fma3)
{
auto r0 = a*b;
auto r1 = fms(a, b, r0);
return {r0, r1};
}
else
{
auto [a1, a2] = two_split(a);
auto [b1, b2] = two_split(b);
T r0 = a*b;
T r1 = a2*b2 -(((r0-a1*b1)-a2*b1)-a1*b2);
if constexpr(eve::platform::supports_invalids)
r1 = if_else(is_not_finite(r0), eve::zero, r1);
return {r0, r1};
}
}
else return apply_over2(two_prod, a, b);
}
}
67 changes: 67 additions & 0 deletions include/eve/module/core/regular/three_fma.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//==================================================================================================
/*
EVE - Expressive Vector Engine
Copyright : EVE Contributors & Maintainers
SPDX-License-Identifier: MIT
*/
//==================================================================================================
#pragma once

#include <eve/detail/overload.hpp>

namespace eve
{
//================================================================================================
//! @addtogroup core
//! @{
//! @var three_fma
//!
//! @brief Callable object computing the three_fma operation.
//!
//! **Required header:** `#include <eve/module/core.hpp>`
//!
//! #### Members Functions
//!
//! | Member | Effect |
//! |:-------------|:-----------------------------------------------------------|
//! | `operator()` | the three_fma operation |
//!
//! ---
//!
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
//! template< value T, value U, value V > auto operator()( T x, U y, V z ) const noexcept requires compatible< T, U >;
//! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//!
//! **Parameters**
//!
//!`x`, `y`, `z`: [values](@ref eve::value).
//!
//! **Return value**
//!
//!computes [elementwise](@ref glossary_elementwise) a triple of values `[a, b, c]` such that:
//!
//!* `a` is `x*y+z`
//!* `b`, c`is are values such that (`a`\f$\oplus\f$`b`) \f$\oplus\f$`c`is exactly to `x`\f$\otimes\f$`y\f$\oplus\f$`y`
//!
//!where \f$\oplus\f$ (resp. \f$\otimes\f$) adds (resp. multiplies) its two parameters with infinite precision.
//!
//! ---
//!
//! #### Supported decorators
//!
//! no decorators are supported
//!
//! #### Example
//!
//! @godbolt{doc/core/three_fma.cpp}
//!
//! @}
//================================================================================================

namespace tag { struct three_fma_; }
template<> struct supports_conditional<tag::three_fma_> : std::false_type {};

EVE_MAKE_CALLABLE(three_fma_, three_fma);
}

#include <eve/module/core/regular/impl/three_fma.hpp>
Loading