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

◆ cbrt

kyosu::cbrt = eve::functor<cbrt_t>
inlineconstexpr

Computes the the kth cubic root of the argument.

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
// regular call
constexpr auto cbrt(complex_like z, auto k) noexcept;
constexpr auto cbrt(complex_like z) noexcept;
}
constexpr auto k
Computes the complex number k i.e. quaternion(0, 0, 0, 1) in the chosen type.
Definition: k.hpp:78
constexpr auto cbrt
Computes the the kth cubic root of the argument.
Definition: cbrt.hpp:79
Main KYOSU namespace.
Definition: cinf.hpp:13

Parameters

  • z: Value to process. floating or complex.
  • n: nth root
  • `k : kth nth root

Return value

 - if the first parameter is floating the call will act as if they were converted to complex before call.
 - the kth cubic root of z, is. `exp((log(z)+2*k*i*pi)/3)`. If not present k is taken as 0. (k is always taken modulo 3).

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
using kyosu::cbrt;
using wi_t = eve::wide<unsigned int, eve::fixed<4>>;
using wf_t = eve::wide<float , eve::fixed<4>>;
wi_t wk = eve::iota(eve::as<wi_t>())+1;
wf_t wf{5.0f, 2.3f, -1.2f, 0.0f};
std::cout << "wk " << wk << std::endl;
std::cout << "wf " << wf << std::endl;
std::cout << "kyosu::cbrt(16.0, wk) " << kyosu::cbrt(16.0, wk) << std::endl;
std::cout << "kyosu::cbrt(wf, wk) " << kyosu::cbrt(wf, wk) << std::endl;
std::cout << "kyosu::cbrt(wf) " << kyosu::cbrt(wf)<< std::endl;
return 0;
}
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition: complex.hpp:27