E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ fracscale

auto eve::fracscale = functor<fracscale_t>
inlineconstexpr

The call is equivalent to a0-roundscale(a0,scale)

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto fracscale(floating_value auto x, index_t<scale>) noexcept; // 1
constexpr auto fracscale(floating_value auto x, integral_value scale) noexcept; // 1
// Semantic option
constexpr auto fracscale[downward](/*any of the above overloads*/) noexcept; // 2
constexpr auto fracscale[upward](/*any of the above overloads*/) noexcept; // 2
constexpr auto fracscale[to_nearest](/*any of the above overloads*/) noexcept; // 2
constexpr auto fracscale[toward_zero](/*any of the above overloads*/) noexcept; // 2
}
The concept floating_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:116
The concept integral_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:51
constexpr auto fracscale
strict_elementwise_callable object computing the reduced part of the scaled input.
Definition fracscale.hpp:82
EVE Main Namespace.
Definition abi.hpp:18

Parameters

  • x: real floating value.
  • scale : int or std::integral_constant of int type limited to the range [0, 15].

Return value

  1. Returns the elementwise reduced part of the scaled input. The number of fraction bits retained is specified by scale. By default the internal rounding after scaling is done to nearest integer. The call fracscale(x, scale) is equivalent to x-eveldexp(eve::nearest(eve::ldexp(x,scale), -scale))
  2. with o denoting one of these options the call is equivalent to x-everoundscale[o](x, scale)

Example

// revision 0
#include <eve/module/core.hpp>
#include <iostream>
int main()
{
eve::wide wf0(0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f);
wf0+= 1.2345678;
eve::wide wu0{0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u};
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wu0 = " << wu0 << "\n";
std::cout << "-> fracscale(wf0, index_t<0>()) = " << eve::fracscale(wf0, eve::index_t<0>()) << "\n";
std::cout << "-> fracscale(wf0, 2*wi) = " << eve::fracscale(wf0, wu0) << "\n";
std::cout << "-> fracscale[downward](wf0, index_t<0>()) = " << eve::fracscale[eve::downward](wf0, eve::index_t<0>()) << "\n";
std::cout << "-> fracscale[upward](wf0, index_t<0>()) = " << eve::fracscale[eve::upward](wf0, eve::index_t<0>()) << "\n";
std::cout << "-> fracscale[to_nearest](wf0, index_t<0>()) = " << eve::fracscale[eve::to_nearest](wf0, eve::index_t<0>()) << "\n";
std::cout << "-> fracscale[toward_zero](wf0, index_t<0>()) = " << eve::fracscale[eve::toward_zero](wf0, eve::index_t<0>()) << "\n";
}
Wrapper for SIMD registers.
Definition wide.hpp:70