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

◆ log

kyosu::log = {}
inlineconstexpr

Computes the natural logarithm of the argument.

Defined in Header

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
template<eve::floating_ordered_value T> constexpr T log(T z) noexcept; //1
template<kyosu::concepts::complex T> constexpr T log(T z) noexcept; //2
template<kyosu::concepts::cayley_dickson T> constexpr T log(T z) noexcept; //2
}
constexpr tags::callable_log log
Computes the natural logarithm of the argument.
Definition: log.hpp:101
Main KYOSU namespace.
Definition: types.hpp:14

Parameters

  • z: Value to process.

Return value

  1. a real typed input z is treated as if kyosu::complex(z) was entered.
  2. Returns elementwise the natural logarithm of the input in the range of a strip in the interval \(i\times[-\pi, \pi]\) along the imaginary axis and mathematically unbounded along the real axis. .
    • The function is continuous onto the branch cut along the negative real axis, taking into account the sign of imaginary part
    • for every z: kyosu::log(kyosu::conj(z)) == kyosu::conj(kyosu::log(z))
    • If z is \(-0\), the result is \(-\infty+i \pi \)
    • If z is \(+0\), the result is \(-\infty\)
    • If z is \(x+i \infty\) (for any finite x), the result is \(+\infty+i \pi/2\)
    • If z is \(x+i NaN\) (for any finite x), the result is \(NaN+i NaN\)
    • If z is \(-\infty+i y\) (for any finite positive y), the result is \(+\infty+i \pi \)
    • If z is \(+\infty+i y\) (for any finite positive y), the result is \(+\infty\)
    • If z is \(-\infty+i \infty\), the result is \(+\infty+i 3\pi/4\)
    • If z is \(+\infty+i \infty\), the result is \(+\infty+i \pi/4\)
    • If z is \(\pm\infty+i NaN\), the result is \(+\infty+i NaN\)
    • If z is \(NaN+i y\) (for any finite y), the result is \(NaN+i NaN\)
    • If z is \(NaN+i \infty\), the result is \(+\infty+i NaN\)
    • If z is \(NaN+i NaN\), the result is \(NaN+i NaN\)
  3. log(z) is semantically equivalent to log(abs(z))+sign(pure(z))*arg(z)

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
using kyosu::log;
using e_t = float;
using we_t = eve::wide<e_t, eve::fixed<2>>;
using wc_t = eve::wide<c_t, eve::fixed<2>>;
using wq_t = eve::wide<q_t, eve::fixed<2>>;
std::cout << "Real: \n";
e_t e(2.9f);
we_t we = we_t(e);
std::cout << e << " -> " << log(e) << "\n";
std::cout << we << " -> " << log(we) << "\n";
std::cout << log(c_t(e))<< "\n";
std::cout << log(q_t(e))<< "\n";
std::cout << log(wc_t(e))<< "\n";
std::cout << log(wq_t(e))<< "\n";
std::cout << "Complex: \n";
c_t c(3.5f,-2.9f);
wc_t wc = wc_t(c);
std::cout << c << " -> " << log(c) << "\n";
std::cout << wc << " -> " << log(wc) << "\n";
std::cout << log(q_t(c))<< "\n";
std::cout << log(wq_t(c))<< "\n";
std::cout << "Quaternion: \n";
q_t q(3.5f,-2.9f, 2.1f, 3.2f);
wq_t wq = wq_t(q);
std::cout << q << " -> " << log(q) << "\n";
std::cout << wq << " -> " << log(wq) << "\n";
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