E.V.E
v2023.02.15
Loading...
Searching...
No Matches
◆
gcd
eve::gcd = functor<gcd_t>
inline
constexpr
Header file
#include <eve/module/combinatorial.hpp>
Callable Signatures
namespace
eve
{
// Regular overload
template
<
int
egral_value T0,
int
egral_value T1>
constexpr
common_value_t<T0, T1>
gcd
(
T0
p,
T1
n
)
noexcept
;
// 1
// Lanes masking
constexpr
auto
gcd
[
conditional_expr
auto
c
](
integral_value
auto
p,
integral_value
auto
n
)
noexcept
;
// 2
constexpr
auto
gcd
[
logical_value
auto
m
](
integral_value
auto
p,
integral_value
auto
n
)
noexcept
;
// 2
}
eve::conditional_expr
Specifies that a type is a Conditional Expression.
Definition
conditional.hpp:28
eve::integral_value
The concept integral_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition
value.hpp:51
eve::logical_value
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition
value.hpp:134
eve::gcd
constexpr auto gcd
elementwise_callable object computing the greatest common divisor of the inputs.
Definition
gcd.hpp:76
eve::translate_t
typename decltype(detail::as_translated_type(as< T >{}))::type translate_t
Returns the final translated type of T.
Definition
translation.hpp:107
eve
EVE Main Namespace.
Definition
abi.hpp:19
Parameters
p
,
n
:
integral values
.
c
:
Conditional expression
masking the operation.
m
:
Logical value
masking the operation.
Return value
If both p and n are zero, returns zero. Otherwise, returns the greatest common divisor of |p| and |n|.
The operation is performed conditionnaly
.
External references
Wikipedia: Least common multiple
C++ standard reference: lcm
Example
#include <eve/eve.hpp>
#include <eve/module/combinatorial.hpp>
#include <iostream>
int
main
() {
eve::wide<float>
wf0
([](
auto
i,
auto
c
)->
float
{
return
(i-
c
/2);});
eve::wide<float>
wf1
([](
auto
i,
auto
)->
float
{
return
10*i; });
eve::wide
n
{93, 25, 32, 368, 216, 43, 18, 25};
eve::wide
p{42, 30, 27, 1024, 36, 12, 51, 44};
std::cout <<
"<- wf0 = "
<<
wf0
<<
"\n"
;
std::cout <<
"<- wf1 = "
<<
wf1
<<
"\n"
;
std::cout <<
"<- n = "
<<
n
<<
"\n"
;
std::cout <<
"<- p = "
<< p <<
"\n"
;
std::cout <<
"-> gcd(wf0, wf1) = "
<<
eve::gcd
(
wf0
,
wf1
) <<
"\n"
;
std::cout <<
"-> gcd[ignore_last(2)](wf0, wf1)= "
<<
eve::gcd
[
eve::ignore_last
(2)](
wf0
,
wf1
) <<
"\n"
;
std::cout <<
"-> gcd[wf0 != -2.0f](wf0, wf1) = "
<<
eve::gcd
[
wf0
!= -2.0f](
wf0
,
wf1
) <<
"\n"
;
std::cout <<
"-> gcd(p, n) = "
<<
eve::gcd
(p,
n
) <<
"\n"
;
}
eve::ignore_last
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition
conditional.hpp:320
eve::wide
Wrapper for SIMD registers.
Definition
wide.hpp:94
eve