E.V.E
v2022.09.01

◆ gcd

eve::gcd = {}
inlineconstexpr

Computes the greatest common divisor of the inputs.

Defined in header

#include <eve/module/combinatorial.hpp>

Callable Signatures

namespace eve
{
template< eve::real_value T, eve::real_value U >
T gcd(T p, U n) noexcept;
}
constexpr callable_gcd_ gcd
Computes the greatest common divisor of the inputs.
Definition: gcd.hpp:61
Definition: all_of.hpp:22

Parameters

p, n: Real values.

Return value

If both p and n are zero, returns zero. Otherwise, returns the greatest common divisor of |p| and |n|.

Warning
p and n can be of any real values type, but when the types are not integral the greatest common divisor is defined only if p and n elements are [flint](eve::is_flint). If any of the arguments is not flint the result is undefined.

Example

#include <eve/module/combinatorial.hpp>
#include <eve/wide.hpp>
#include <iostream>
int
main()
{
w_t pi = {93, 25, 32, 368}, qi = {42, 30, 27, 1024};
std::cout << "---- simd" << '\n'
<< " <- pi = " << pi << '\n'
<< " <- qi = " << qi << '\n'
<< " -> gcd(pi, qi) = " << eve::gcd(pi, qi) << '\n';
std::uint32_t xi = 18, yi = 60;
std::cout << "---- scalar" << '\n'
<< " xi = " << xi << '\n'
<< " yi = " << yi << '\n'
<< " -> gcd(xi, yi) = " << eve::gcd(xi, yi) << '\n';
return 0;
}
constexpr callable_pi_ pi
Callable object computing the constant .
Definition: pi.hpp:49
Wrapper for SIMD registers.
Definition: wide.hpp:65