dot

Forms the dot product of two vectors. Uses unrolled loops for strides equal to one.

  1. F dot(Slice!(Iterator1, N, kind1) x, Slice!(Iterator2, N, kind2) y)
  2. auto dot(Slice!(Iterator1, N, kind1) x, Slice!(Iterator2, N, kind2) y)
    @fastmath
    dot
    (
    SliceKind kind1
    SliceKind kind2
    size_t N
    Iterator1
    Iterator2
    )
    (
    Slice!(Iterator1, N, kind1) x
    ,
    Slice!(Iterator2, N, kind2) y
    )

Parameters

x Slice!(Iterator1, N, kind1)

first n-dimensional tensor

y Slice!(Iterator2, N, kind2)

second n-dimensional tensor BLAS: SDOT, DDOT, SDSDOT, DSDOT, CDOTC, ZDOTC

Return Value

Type: auto

dot product conj(xᐪ) × y

Examples

SDOT, DDOT

import mir.ndslice.allocation: slice;
auto x = slice!double(4);
auto y = slice!double(4);
x[] = [0, 1, 2, 3];
y[] = [4, 5, 6, 7];
assert(dot(x, y) == 5 + 12 + 21);

SDOT, DDOT

import mir.ndslice.allocation: slice;
auto x = slice!double(4);
auto y = slice!double(4);
x[] = [0, 1, 2, 3];
y[] = [4, 5, 6, 7];
assert(dot(x, y) == 5 + 12 + 21);

SDSDOT, DSDOT

import mir.ndslice.allocation: slice;
auto x = slice!float(4);
auto y = slice!float(4);
x[] = [0, 1, 2, 3];
y[] = [4, 5, 6, 7];
assert(dot!real(x, y) == 5 + 12 + 21); // 80-bit FP for x86 CPUs

CDOTU, ZDOTU

import mir.ndslice.allocation: slice;

auto x = slice!cdouble(2);
auto y = slice!cdouble(2);
x[] = [0 + 1i, 2 + 3i];
y[] = [4 + 5i, 6 + 7i];
version(LDC) // DMD Internal error: backend/cgxmm.c 628
assert(dot(x, y) == (0 + 1i) * (4 + 5i) + (2 + 3i) * (6 + 7i));

Meta