Report a bug
If you spot a problem with this page, click here to create a Github issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.sparse.blas.dot

Authors:
Ilya Yaroshenko
  • dot
    Unqual!(CommonType!(T1, T2)) dot(V1 : Series!(I1*, T1*), V2 : Series!(I2*, T2*), T1, T2, I1, I2)(V1 x, V2 y);

    D dot(D, V1 : Series!(I1*, T1*), V2 : Series!(I2*, T2*), T1, T2, I1, I2)(V1 x, V2 y);
    Dot product of two vectors
    Parameters:
    V1 xsparse vector
    V2 ysparse vector
    Returns:
    scalar xᵀ × y
    Examples:
    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);
    
  • dot
    Unqual!(CommonType!(T1, ForeachType!V2)) dot(V1 : Series!(I1*, T1*), T1, I1, V2)(V1 x, V2 y)
    if (isDynamicArray!V2 || isSlice!V2);

    D dot(D, V1 : Series!(I1*, T1*), T1, I1, V2)(V1 x, V2 y)
    if (isDynamicArray!V2 || isSlice!V2);
    Dot product of two vectors.
    Parameters:
    V1 xsparse vector
    V2 ydense vector
    Returns:
    scalar x × y
    Examples:
    import std.typecons: No;
    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);