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

◆ dot

auto kyosu::dot = eve::functor<dot_t>
inlineconstexpr

object computing the elementwise dot product of the vector of the first half parameters by thevector of the last half.

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
// Regular overloads
constexpr auto dot(auto value... xs, auto value... ys) noexcept; // 1
constexpr auto dot(kumi::tuple xs, kumi::tuple ys) noexcept; // 2
constexpr auto dot[kahan](/*any of the above overloads*/) noexcept; // 3
}
constexpr auto dot
object computing the elementwise dot product of the vector of the first half parameters by thevector ...
Definition dot.hpp:97
Main KYOSU namespace.
Definition cinf.hpp:13

Parameters

  • z0, z1: Values to process.

Return value

  1. dot product. \(\sum_s x_s\bar{y}_s\).
  2. use the content of the tuples
  3. kahan algorithms are used to improve accuracy.

External references

Example

#include <eve/wide.hpp>
#include <iostream>
#include <kyosu/kyosu.hpp>
int main()
{
using kyosu::dot;
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 << " -> " << dot(e0, e1) << "\n";
we_t we0(e0);
we_t we1(e1);
std::cout << we0 << ", " << we1 << " -> " << dot(we0, we1) << "\n";
std::cout << "Complex: " << "\n";
c_t c0(1, 5);
c_t c1(5, 9);
std::cout << c0 << ", " << c1 << " -> " << dot(c0, c1) << "\n";
wc_t wc0(c0);
wc_t wc1(c1);
std::cout << wc0 << ", " << wc1 << " -> " << dot(wc0, wc1) << "\n";
std::cout << "Quaternion: " << "\n";
q_t q0(1, 5, 2, 3);
q_t q1(5, 9, 6, 7);
std::cout << q0 << ", " << q1 << " -> " << dot(q0, q1) << "\n";
wq_t wq0(q0);
wq_t wq1(q1);
std::cout << wq0 << ", " << wq1 << " -> " << dot(wq0, wq1) << "\n";
std::cout << wq0 << ", " << q1 << " -> " << dot(wq0, q1) << "\n";
std::cout << wq0 << ", " << c1 << " -> " << dot(wq0, c1) << "\n";
std::cout << wq0 << ", " << e1 << " -> " << dot(wq0, e1) << "\n";
std::cout << q0 << ", " << we1 << " -> " << dot(q0, we1) << "\n";
kumi::tuple s{wc0, wc1, 2 * wc1};
kumi::tuple t{wc1, wc0, wc0};
std::cout << "kyosu::dot( s, t) == " << kyosu::dot(s, t) << std::endl;
std::cout << "kyosu::dot(wc0, wc1, 2*wc1, wc1, wc0, wc0) == " << kyosu::dot(wc0, wc1, 2 * wc1, wc1, wc0, wc0)
<< std::endl;
kumi::tuple st{wc0, wc1, 2 * wc1, wc1, wc0, wc0};
std::cout << "kyosu::dot(st) == " << kyosu::dot(st) << std::endl;
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