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

◆ manhattan

auto kyosu::manhattan = eve::functor<manhattan_t>
inlineconstexpr

Computes the sum of the absolute values of all terms of all the parameters.

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
// Regular overloads
constexpr auto manhattan(auto ... xs) noexcept; // 1
constexpr auto manhattan(eve::non_empty_product_type auto const& tup) noexcept; // 2
// Lanes masking
constexpr auto manhattan[conditional_expr auto c](/*any of the above overloads*/) noexcept; // 3
constexpr auto manhattan[logical_value auto m](/*any of the above overloads*/) noexcept; // 3
constexpr auto manhattan[saturated](/*any of the above overloads*/) noexcept; // 4
constexpr auto manhattan[pedantic](/*any of the above overloads*/) noexcept; // 5
constexpr auto manhattan[kahan](/*any of the above overloads*/) noexcept; // 6
}
constexpr auto manhattan
Computes the sum of the absolute values of all terms of all the parameters.
Definition manhattan.hpp:80
Main KYOSU namespace.
Definition cinf.hpp:13

Parameters

  • xs...: Values to process.

Return value

  1. The value of the sum of the values (the \(l_1\) norm) of the \(l_1\) norm of its arguments is returned.
  2. same as 1. on the tuple elements.
  3. The operation is performed conditionnaly
  4. internally uses saturated options.
  5. returns \(\infty\) as soon as one of its parameter is infinite, regardless of possible Nan values.
  6. uses kahan like compensated algorithm for better accuracy.
Note
This is NOT lpnorm(1, x0, xs...) which is the \(l_1\) norm of \(l_2\) norm of its arguments.

External references

Example

#include <eve/wide.hpp>
#include <iostream>
#include <kyosu/kyosu.hpp>
int main()
{
using e_t = float;
using we_t = eve::wide<float, eve::fixed<2>>;
using wc_t = eve::wide<kyosu::complex_t<float>, eve::fixed<2>>;
using wq_t = eve::wide<kyosu::quaternion_t<float>, eve::fixed<2>>;
std::cout << "Real: " << "\n";
e_t e0(1);
e_t e1(2);
std::cout << e0 << ", " << e1 << " -> " << manhattan(e0, e1) << "\n";
we_t we0(e0);
we_t we1(e1);
std::cout << we0 << ", " << we1 << " -> " << manhattan(we0, we1) << "\n";
std::cout << "Complex: " << "\n";
c_t c0(5);
c_t c1(5, 9);
std::cout << c0 << ", " << c1 << " -> " << manhattan(c0, c1) << "\n";
wc_t wc0(c0);
wc_t wc1(c1);
std::cout << wc0 << ", " << wc1 << " -> " << manhattan(wc0, wc1) << "\n";
std::cout << "Quaternion: " << "\n";
q_t q0(5, 2, 3);
q_t q1(5, 9, 6, 7);
std::cout << q0 << ", " << q1 << " -> " << manhattan(q0, q1) << "\n";
wq_t wq0(q0);
wq_t wq1(q1);
std::cout << wq0 << ", " << wq1 << " -> " << manhattan(wq0, wq1) << "\n";
return 0;
}
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition complex.hpp:27
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition quaternion.hpp:24