dot

Dot product of two vectors

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

Parameters

x V1

sparse vector

y V2

sparse vector

Return Value

Type: D

scalar xᵀ × y

Examples

import mir.series;

auto x = series([0u, 3, 5, 9, 100], [1, 3, 4, 9, 10]);
auto y = series([1u, 3, 4, 9], [1, 10, 100, 1000]);
// x = [1, 0, 0,  3, 0, 4, 0, 0, 0, 9, ... ,10]
// y = [0, 1, 0, 10, 0, 0, 0, 0, 0, 1000]
assert(dot(x, y) == 9030);
assert(dot!double(x, y) == 9030);

Meta