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

◆ lcm

eve::lcm = functor<lcm_t>
inlineconstexpr

Callable Signatures

#include <eve/module/combinatorial.hpp>

Callable Signatures

namespace eve
{
// Regular overload
template <value T0, value T1> constexpr common_value_t<T0, T1> lcm(T0 p, T1 n) noexcept; // 1
// Lanes masking
constexpr auto lcm[conditional_expr auto c](value auto p, value auto n) noexcept; // 2
constexpr auto lcm[logical_value auto m](value auto p, value auto n) noexcept; // 2
}
Specifies that a type is a Conditional Expression.
Definition: conditional.hpp:27
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition: value.hpp:107
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition: value.hpp:33
constexpr auto lcm
elementwise_callable object computing the least common multiple of the inputs.
Definition: lcm.hpp:80
EVE Main Namespace.
Definition: abi.hpp:18
typename eve::detail::common_value_impl< void, Ts... >::type common_value_t
Computes the SIMD-compatible common type between all Ts.
Definition: common_value.hpp:69

Parameters

  • p, n: values.
  • c: Conditional expression masking the operation.
  • m: Logical value masking the operation.

Return value

  1. Returns the least common multiple of |p| and |n|.
  2. The operation is performed conditionnaly
Warning
p and n can be of any values type, but when the types are not integral the least common multiple is defined only if p and n elements are flint. If any of the arguments is not flint the result is undefined.

External references

Example

// revision 1
#include <eve/module/combinatorial.hpp>
#include <iostream>
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};
int main(){
std::cout << "<- wf0 = " << wf0 << "\n";
std::cout << "<- wf1 = " << wf1 << "\n";
std::cout << "<- n = " << n << "\n";
std::cout << "<- p = " << p << "\n";
std::cout << "-> lcm(wf0, wf1) = " << eve::lcm(wf0, wf1) << "\n";
std::cout << "-> lcm[ignore_last(2)](wf0, wf1)= " << eve::lcm[eve::ignore_last(2)](wf0, wf1) << "\n";
std::cout << "-> lcm[wf0 != -2.0f](wf0, wf1) = " << eve::lcm[wf0 != -2.0f](wf0, wf1) << "\n";
std::cout << "-> lcm(p, n) = " << eve::lcm(p, n) << "\n";
}
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition: conditional.hpp:304
Wrapper for SIMD registers.
Definition: wide.hpp:71