E.V.E
v2023.02.15

◆ manhattan

eve::manhattan = {}
inlineconstexpr

Computes the manhattan norm ( \(l_1\)) of its arguments.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template< eve::value... Ts >
auto manhattan(Ts ... xs) noexcept;
}
Definition: value.hpp:31
constexpr callable_manhattan_ manhattan
Computes the manhattan norm ( ) of its arguments.
Definition: manhattan.hpp:72
Definition: abi.hpp:18

Parameters

Return value

The value of the sum of the absolute value of the arguments is returned.

Example

#include <eve/module/core.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
wide_ft pf = {-1.0f, 2.0f, -3.0f, -32768.0f};
wide_ft qf = {-4, 3, -2, -12};
std::cout << "---- simd" << '\n'
<< "<- pf = " << pf << '\n'
<< "<- qf = " << qf << '\n'
<< "-> eve::manhattan(pf, qf) = " << eve::manhattan(pf, qf) << '\n';
float xf = -32768.0f;
float yf = 2.0f;
std::cout << "---- scalar" << '\n'
<< "<- xf = " << xf << '\n'
<< "<- yf = " << yf << '\n'
<< "-> eve::manhattan(xf, yf) = " << eve::manhattan(xf, yf) << '\n';
auto k = kumi::tuple{pf, qf, pf+qf, 1.0f};
std::cout << "---- multi parameters" << '\n'
<< " -> manhattan(k) = " << eve::manhattan(k) << '\n'
<< " -> manhattan(kumi::tuple{pf, pf, 1.0f}) = " << eve::manhattan( kumi::tuple{pf, qf, 1}) << '\n'
<< " -> manhattan(kumi::tuple{1, pf, pf}) = " << eve::manhattan( kumi::tuple{1, pf, qf}) << '\n'
<< " -> manhattan(kumi::tuple{pf, 1.0f) = " << eve::manhattan( kumi::tuple{pf, 1.0f}) << '\n'
<< " -> manhattan(kumi::tuple{1.0f, pf) = " << eve::manhattan( kumi::tuple{1.0f, pf}) << '\n';
return 0;
}
Wrapper for SIMD registers.
Definition: wide.hpp:65

Semantic Modifiers

  • Masked Call

    The call eve::manhattan[mask](x, ...) provides a masked version of manhattan which is equivalent to if_else(mask, eve::manhattan(x, ...), x)

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft pf = {-1.0f, 2.0f, -3.0f, -32768.0f};
    wide_ft qf = {-4, 3, -2, -12};
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "<- qf = " << qf << '\n'
    << "-> eve::manhattan[pf > 0](pf, qf) = " << eve::manhattan[pf > 0](pf, qf) << '\n';
    return 0;
    }
  • eve::pedantic

    The call eve::pedantic(eve::manhattan)(...) computes a pedantic version of eve::manhattan. returning \(\infty\) as soon as one of its parameter is infinite, regardless of possible Nan values.

    Example

    #include <eve/module/core.hpp>
    #include <eve/wide.hpp>
    #include <iostream>
    int main()
    {
    wide_ft pf = {-1.0f, 2.0f, -3.0f, eve::inf(eve::as<float>())};
    wide_ft qf = {-4 , 3 , -2 , eve::nan(eve::as<float>())};
    std::cout << "---- simd" << '\n'
    << "<- pf = " << pf << '\n'
    << "<- qf = " << qf << '\n'
    << "-> pedantic(manhattan)(pf, qf) = " << eve::pedantic(eve::manhattan)(pf, qf) << '\n';
    return 0;
    }
    constexpr callable_nan_ nan
    Computes the IEEE NaN constant.
    Definition: nan.hpp:53
    constexpr callable_inf_ inf
    Computes the infinity ieee value.
    Definition: inf.hpp:58
    constexpr pedantic_type const pedantic
    Higher-order Callable Object imbuing more standard semantic onto other Callable Objects.
    Definition: pedantic.hpp:56
    Lightweight type-wrapper.
    Definition: as.hpp:29