kyosu v0.1.0
Complex Without Complexes
Loading...
Searching...
No Matches

◆ if_else

auto kyosu::if_else = eve::functor<if_else_t>
inlineconstexpr

Select a value between two arguments based on a logical mask.

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
constexpr auto if_else(auto x, auto y, auto z ) noexcept;
}
constexpr auto if_else
Select a value between two arguments based on a logical mask.
Definition if_else.hpp:70
Main KYOSU namespace.
Definition cinf.hpp:13

Parameters

  • x: logical mask.
  • y, z: values to be selected.

Return value

  • elementwise y or z according the truth value of x.

Example

#include <eve/wide.hpp>
#include <iostream>
#include <kyosu/kyosu.hpp>
int main()
{
auto c = kyosu::complex_t<float>(3.5f, -2.9f);
auto q = kyosu::quaternion_t<float>(1.f, 2.f, 3.f, 4.f);
auto t = 1.0f;
auto r = kyosu::if_else(t > 2.0f, q, c);
std::cout << r << std::endl;
return 0;
}
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition complex.hpp:27
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition quaternion.hpp:24