E.V.E
v2023.02.15
Loading...
Searching...
No Matches

Detailed Description

These functions allows performing logarithm computations

Variables

constexpr auto eve::log = functor<log_t>
 elementwise_callable object computing the natural logarithm: \(\log x\).
constexpr auto eve::log10 = functor<log10_t>
 elementwise_callable object computing the base 10 logarithm: \(\log_{10} x\).
constexpr auto eve::log1p = functor<log1p_t>
 elementwise_callable object computing the natural logarithm of \(1+x\): \(\log(1+x)\).
constexpr auto eve::log2 = functor<log2_t>
 elementwise_callable object computing the base 2 logarithm: \(\log_2 x\).
constexpr auto eve::log_abs = functor<log_abs_t>
 Callable object computing the natural logarithm of the absolute value of the input.
constexpr auto eve::logspace_add = functor<logspace_add_t>
 tuple_callable object computing the logspace_add operation: \(\log\left(\sum_{i = 0}^n e^{\log x_i}\right)\)
constexpr auto eve::logspace_sub = functor<logspace_sub_t>
 tuple_callable object computing the logspace_sub operation: \(\log\left(e^{\log x_0}-\sum_{i = 1}^n e^{\log x_i}\right)\).

Variable Documentation

◆ log

auto eve::log = functor<log_t>
inlineconstexpr

elementwise_callable object computing the natural logarithm: \(\log x\).

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto log(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto log[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto log[logical_value auto m](floating_value auto x) noexcept; // 2
}
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept floating_value<T> is satisfied if and only if T satisfies eve::value and the element type...
Definition value.hpp:116
The concept logical_value<T> is satisfied if and only if T satisfies eve::value and the element type ...
Definition value.hpp:134
constexpr auto log
elementwise_callable object computing the natural logarithm: .
Definition log.hpp:79
EVE Main Namespace.
Definition abi.hpp:19

Parameters

Return value

  1. Returns the elementwise the natural logarithm of x: \(\log x\).
    • If the element is \(\pm0\), \(-\infty\) is returned.
    • If the element is \(1\), \(+0\) is returned.
    • If the element is \(\infty\), \(\infty\) is returned.
    • If the element is less than 0, NaN is returned.
  2. The operation is performed conditionally.

External references

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wf = {0.0f, -0.0f, -1.0f, 1.0f, 2.0f,
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> log(wf) = " << eve::log(wf) << "\n";
std::cout << "-> log[ignore_last(2)](wf)= " << eve::log[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> log[wf != 2.0f](wf) = " << eve::log[wf != 2.0f](wf) << "\n";
}
constexpr auto nan
Computes the IEEE quiet NaN constant.
Definition nan.hpp:67
constexpr auto inf
Computes the infinity ieee value.
Definition inf.hpp:67
Lightweight type-wrapper.
Definition as.hpp:29
Conditional expression ignoring the k last lanes from a eve::simd_value.
Definition conditional.hpp:361
Wrapper for SIMD registers.
Definition wide.hpp:94

◆ log10

auto eve::log10 = functor<log10_t>
inlineconstexpr

elementwise_callable object computing the base 10 logarithm: \(\log_{10} x\).

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto log10(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto log10[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto log10[logical_value auto m](floating_value auto x) noexcept; // 2
}
constexpr auto log10
elementwise_callable object computing the base 10 logarithm: .
Definition log10.hpp:78

Parameters

Return value

  1. Returns the elementwise the base 10 logarithm of x In particular, for floating inputs:
    • If the element is \(\pm0\), \(-\infty\) is returned.
    • If the element is \(1\), \(+0\) is returned.
    • If the element is \(\infty\), \(\infty\) is returned.
    • If the element is less than 0, NaN is returned.
  2. The operation is performed conditionally.

External references

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wf = {0.0f, -0.0f, -1.0f, 1.0f, 2.0f,
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> log10(wf) = " << eve::log10(wf) << "\n";
std::cout << "-> log10[ignore_last(2)](wf)= " << eve::log10[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> log10[wf != 2.0f](wf) = " << eve::log10[wf != 2.0f](wf) << "\n";
}

◆ log1p

auto eve::log1p = functor<log1p_t>
inlineconstexpr

elementwise_callable object computing the natural logarithm of \(1+x\): \(\log(1+x)\).

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto log1p(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto log1p[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto log1p[logical_value auto m](floating_value auto x) noexcept; // 2
}
constexpr auto log1p
elementwise_callable object computing the natural logarithm of : .
Definition log1p.hpp:74

Parameters

Return value

  1. Returns the elementwise the natural logarithm of 1+x This function is more accurate than the expression log(1+x) if x is close to zero. In particular:
    • If the element is \(\pm0\), \(-\infty\) is returned.
    • If the element is \(\pm0\), \(+0\) is returned.
    • If the element is \(\infty\), \(\infty\) is returned.
    • If the element is less than -1, NaN is returned.

External references

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wf = {0.0f, -0.0f, -1.0f, 1.0f, 2.0f,
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> log1p(wf) = " << eve::log1p(wf) << "\n";
std::cout << "-> log1p[ignore_last(2)](wf)= " << eve::log1p[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> log1p[wf != 2.0f](wf) = " << eve::log1p[wf != 2.0f](wf) << "\n";
}
constexpr auto eps
Computes a constant to the machine epsilon.
Definition eps.hpp:74

◆ log2

auto eve::log2 = functor<log2_t>
inlineconstexpr

elementwise_callable object computing the base 2 logarithm: \(\log_2 x\).

Callable Signatures

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto log2(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto log2[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto log2[logical_value auto m](floating_value auto x) noexcept; // 2
}
constexpr auto log2
elementwise_callable object computing the base 2 logarithm: .
Definition log2.hpp:90

Parameters

Return value

  1. Returns the elementwise the base 2 logarithm of x In particular, for floating inputs:
    • If the element is \(\pm0\), \(-\infty\) is returned.
    • If the element is \(1\), \(+0\) is returned.
    • If the element is \(\infty\), \(\infty\) is returned.
    • If the element is less than 0, NaN is returned.
  2. The operation is performed conditionally.

External references

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wf = {0.0f, -0.0f, -1.0f, 1.0f, 2.0f,
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> log2(wf) = " << eve::log2(wf) << "\n";
std::cout << "-> log2[ignore_last(2)](wf)= " << eve::log2[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> log2[wf != 2.0f](wf) = " << eve::log2[wf != 2.0f](wf) << "\n";
}

◆ log_abs

auto eve::log_abs = functor<log_abs_t>
inlineconstexpr

Callable object computing the natural logarithm of the absolute value of the input.

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overload
constexpr auto log_abs(floating_value auto x) noexcept; // 1
// Lanes masking
constexpr auto log_abs[conditional_expr auto c](floating_value auto x) noexcept; // 2
constexpr auto log[logical_value auto m](floating_value auto x) noexcept; // 2
}
constexpr auto log_abs
Callable object computing the natural logarithm of the absolute value of the input.
Definition log_abs.hpp:66

Parameters

Return value

  1. Returns elementwise the natural logarithm of the absolute value of the input.
  2. The operation is performed conditionally.

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide wf = {0.0f, -0.0f, -1.0f, 1.0f, 2.0f,
std::cout << "<- wf = " << wf << "\n";
std::cout << "-> log_abs(wf) = " << eve::log_abs(wf) << "\n";
std::cout << "-> log_abs[ignore_last(2)](wf)= " << eve::log_abs[eve::ignore_last(2)](wf) << "\n";
std::cout << "-> log_abs[wf != 2.0f](wf) = " << eve::log_abs[wf != 2.0f](wf) << "\n";
}

◆ logspace_add

auto eve::logspace_add = functor<logspace_add_t>
inlineconstexpr

tuple_callable object computing the logspace_add operation: \(\log\left(\sum_{i = 0}^n e^{\log x_i}\right)\)

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto logspace_add(floating_value auto x, floating_value auto ... xs) noexcept; // 1
constexpr auto logspace_add(eve::non_empty_product_type auto const& tup) noexcept; // 2
// Lanes masking
constexpr auto logspace_add[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto logspace_add[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
}
constexpr auto logspace_add
tuple_callable object computing the logspace_add operation:
Definition logspace_add.hpp:88

Parameters

Return value

  1. The call logspace_add(x, xs...) is semantically equivalent to log(exp(log(x)) + + exp(log(xs))...) without causing unnecessary overflows or throwing away too much accuracy.
  2. equivalent to the call on the elements of the tuple.
  3. The operation is performed conditionally

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide pf = {0.0, 2.0, 3.0, 30.0};
eve::wide qf = {0.0, 1.0, 1.0, 29.56};
eve::wide rf = {0.0, 0.5, 10.0,25.35};
kumi::tuple wt{pf, qf};
std::cout << "<- pf = " << pf << "\n";
std::cout << "<- qf = " << qf << "\n";
std::cout << "<- rf = " << rf << "\n";
std::cout << "<- wt = " << wt << "\n";
std::cout << "-> logspace_add(pf, qf) = " << eve::logspace_add(pf, qf) << "\n";
std::cout << "-> logspace_add(wt) = " << eve::logspace_add(wt) << "\n";
std::cout << "-> logspace_add[ignore_last(2)](pf, qf)= " << eve::logspace_add[eve::ignore_last(2)](pf, qf) << "\n";
std::cout << "-> logspace_add[pf != 3.0](pf, qf) = " << eve::logspace_add[pf != 3.0](pf, qf) << "\n";
std::cout << "-> logspace_add(pf, qf, rf) = " << eve::logspace_add(pf, qf, rf) << "\n";
}

◆ logspace_sub

auto eve::logspace_sub = functor<logspace_sub_t>
inlineconstexpr

tuple_callable object computing the logspace_sub operation: \(\log\left(e^{\log x_0}-\sum_{i = 1}^n e^{\log x_i}\right)\).

Defined in Header

#include <eve/module/math.hpp>

Callable Signatures

namespace eve
{
// Regular overloads
constexpr auto logspace_sub(floating_value auto x, floating_value auto ... xs) noexcept; // 1
constexpr auto logspace_sub(eve::non_empty_product_type auto const& tup) noexcept; // 2
// Lanes masking
constexpr auto logspace_sub[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto logspace_sub[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
}
constexpr auto logspace_sub
tuple_callable object computing the logspace_sub operation: .
Definition logspace_sub.hpp:91

Parameters

Return value

  1. The call logspace_sub(x, xs...) is semantically equivalent tolog(exp(log(x)) - exp(log(xs))...). without causing unnecessary overflows or throwing away too much accuracy, but its use is not recommended on low precision types as float16_t
  2. equivalent to the call on the elements of the tuple.
  3. The operation is performed conditionally

Example

// revision 1
#include <eve/module/math.hpp>
#include <iostream>
int main()
{
eve::wide pf = {0.0, 2.0, 3.0, 30.0};
eve::wide qf = {0.0, 1.0, 1.0, 29.56};
eve::wide rf = {0.0, 0.5, 2.0,25.35};
kumi::tuple wt{pf, qf};
std::cout << "<- pf = " << pf << "\n";
std::cout << "<- qf = " << qf << "\n";
std::cout << "<- rf = " << rf << "\n";
std::cout << "<- wt = " << wt << "\n";
std::cout << "-> logspace_sub(pf, qf) = " << eve::logspace_sub(pf, qf) << "\n";
std::cout << "-> logspace_sub(wt) = " << eve::logspace_sub(wt) << "\n";
std::cout << "-> logspace_sub[ignore_last(2)](pf, qf)= " << eve::logspace_sub[eve::ignore_last(2)](pf, qf) << "\n";
std::cout << "-> logspace_sub[pf != 3.0](pf, qf) = " << eve::logspace_sub[pf != 3.0](pf, qf) << "\n";
std::cout << "-> logspace_sub(pf, qf, rf) = " << eve::logspace_sub(pf, qf, rf) << "\n";
}