dot

dot(x, y) â‹…(x,y)

Compute the dot product. For complex vectors, the first vector is conjugated.

Examples

  1. Compute the dot product of two vectors:

    julia> x = [1, 2, 3];
    julia> y = [4, 5, 6];
    julia> dot(x, y)
    32

    This example calculates the dot product of the vectors x and y.

  2. Handle complex vectors:
    julia> x = [1+2im, 2-3im, 3+4im];
    julia> y = [4-5im, 5+6im, 6-7im];
    julia> dot(x, y)
    -62 + 35im

    When dealing with complex vectors, the dot function conjugates the first vector before computing the dot product.

Common mistake example:

julia> x = [1, 2, 3];
julia> y = [4, 5];
julia> dot(x, y)
ERROR: DimensionMismatch("dot product arguments have lengths 3 and 2")

In this example, the dimensions of the vectors x and y do not match. The dot function requires the vectors to have the same length. Make sure the input vectors are of the same dimension to avoid this error.

See Also

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: