| Server IP : 217.160.0.212 / Your IP : 216.73.216.141 Web Server : Apache System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /usr/include/xsimd/arch/generic/ |
Upload File : |
/***************************************************************************
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
* Martin Renou *
* Copyright (c) QuantStack *
* Copyright (c) Serge Guelton *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/
#ifndef XSIMD_GENERIC_ROUNDING_HPP
#define XSIMD_GENERIC_ROUNDING_HPP
#include "./xsimd_generic_details.hpp"
namespace xsimd
{
namespace kernel
{
using namespace types;
// ceil
template <class A, class T>
inline batch<T, A> ceil(batch<T, A> const& self, requires_arch<generic>) noexcept
{
batch<T, A> truncated_self = trunc(self);
return select(truncated_self < self, truncated_self + 1, truncated_self);
}
// floor
template <class A, class T>
inline batch<T, A> floor(batch<T, A> const& self, requires_arch<generic>) noexcept
{
batch<T, A> truncated_self = trunc(self);
return select(truncated_self > self, truncated_self - 1, truncated_self);
}
// round
template <class A, class T>
inline batch<T, A> round(batch<T, A> const& self, requires_arch<generic>) noexcept
{
auto v = abs(self);
auto c = ceil(v);
auto cp = select(c - 0.5 > v, c - 1, c);
return select(v > constants::maxflint<batch<T, A>>(), self, copysign(cp, self));
}
// trunc
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
inline batch<T, A> trunc(batch<T, A> const& self, requires_arch<generic>) noexcept
{
return self;
}
template <class A>
inline batch<float, A> trunc(batch<float, A> const& self, requires_arch<generic>) noexcept
{
return select(abs(self) < constants::maxflint<batch<float, A>>(), to_float(to_int(self)), self);
}
template <class A>
inline batch<double, A> trunc(batch<double, A> const& self, requires_arch<generic>) noexcept
{
return select(abs(self) < constants::maxflint<batch<double, A>>(), to_float(to_int(self)), self);
}
}
}
#endif