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

◆ nthroot

kyosu::nthroot = eve::functor<nthroot_t>
inlineconstexpr

Computes the the kth nth root of the argument.

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
// regular call
constexpr auto nthroot(complex_like z, auto n, auto k) noexcept;
constexpr auto nthroot(complex_like z, auto n) noexcept;
// semantic modifyers
constexpr auto nthroot[real_only](/*any previous overload*/) 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 nthroot
Computes the the kth nth root of the argument.
Definition: nthroot.hpp:110
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, unless the option real_only is used
   in which case the parameter must be a floating_value,  the real part of the result will the same as an eve::nthroot and the result will be
   fnan if no real solution exists.
 - the kth nth root of z, is. `exp((log(z)+2*k*i*pi)/n)`. If not present k is taken as 0.

Example

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