dot

Dot product of two vectors.

  1. Unqual!(CommonType!(T1, T2)) dot(V1 x, V2 y)
  2. D dot(V1 x, V2 y)
  3. Unqual!(CommonType!(T1, ForeachType!V2)) dot(V1 x, V2 y)
    Unqual!(CommonType!(T1, ForeachType!V2))
    dot
    (
    V1 : Series!(I1*, T1*)
    T1
    I1
    V2
    )
    (
    V1 x
    ,
    V2 y
    )
    if (
    isDynamicArray!V2 ||
    isSlice!V2
    )
  4. D dot(V1 x, V2 y)

Parameters

x V1

sparse vector

y V2

dense vector

Return Value

Type: Unqual!(CommonType!(T1, ForeachType!V2))

scalar x × y

Examples

import mir.series;

auto x = [0u, 3, 5, 9, 10].series([1.0, 3, 4, 9, 13]);
auto y = [0.0, 1.0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
// x: [1, 0, 0, 3, 0, 4, 0, 0, 0, 9, 13,  0,  0,  0]
// y: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
auto r = 0 + 3 * 3 + 4 * 5 + 9 * 9 + 13 * 10;
assert(dot(x, y) == r);
assert(dot(x, y.sliced) == r);
assert(dot(x, y.slicedField) == r);

Meta