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

◆ roundscale

auto eve::roundscale = functor<roundscale_t>
inlineconstexpr

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto roundscale(floating_value auto x, index_t<scale>) noexcept; // 1
constexpr auto roundscale(floating_value auto x, integral_value scale) noexcept; // 1
// Semantic option
constexpr auto roundscale[downward](/*any of the above overloads*/) noexcept; // 2
constexpr auto roundscale[upward](/*any of the above overloads*/) noexcept; // 2
constexpr auto roundscale[to_nearest](/*any of the above overloads*/) noexcept; // 2
constexpr auto roundscale[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 roundscale
strict_elementwise_callable object computing the scaled input rounding.
Definition roundscale.hpp:80
EVE Main Namespace.
Definition abi.hpp:18

Parameters

  • x: floating value.
  • scale : inttegal value or integral_constant of integral type.

Return value

  1. Returns the elementwise 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 roundscale(x, scale) is equivalent to ldexp(eve::nearest(ldexp(x,scale), -scale))
  2. with o denoting one of these options the call is equivalent to ldexp(round[o](ldexp(x,scale), -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 << "-> roundscale(wf0, index_t<0>()) = " << eve::roundscale(wf0, eve::index_t<0>()) << "\n";
std::cout << "-> roundscale(wf0, 2*wi) = " << eve::roundscale(wf0, wu0) << "\n";
std::cout << "-> roundscale[downward](wf0, index_t<0>()) = " << eve::roundscale[eve::downward](wf0, eve::index_t<0>()) << "\n";
std::cout << "-> roundscale[upward](wf0, index_t<0>()) = " << eve::roundscale[eve::upward](wf0, eve::index_t<0>()) << "\n";
std::cout << "-> roundscale[to_nearest](wf0, index_t<0>()) = " << eve::roundscale[eve::to_nearest](wf0, eve::index_t<0>()) << "\n";
std::cout << "-> roundscale[toward_zero](wf0, index_t<0>()) = " << eve::roundscale[eve::toward_zero](wf0, eve::index_t<0>()) << "\n";
}
Wrapper for SIMD registers.
Definition wide.hpp:86