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

◆ if_else

kyosu::if_else = {}
inlineconstexpr

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

Defined in Header

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
constexpr auto if_else(auto x, auto y, auto z ) noexcept;
}
constexpr tags::callable_if_else if_else
Select a value between two arguments based on a logical mask.
Definition: if_else.hpp:72
Main KYOSU namespace.
Definition: types.hpp:14

Parameters

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

Return value

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

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
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< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition: quaternion.hpp:27
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition: complex.hpp:27