dot(): number
Computes the dot product of two arrays.
Takes two arrays of equal length and computes their dot product (sum of element-wise products).
Dot product of two 1D arrays
Dot product of two 1D arrays
import { assertEquals, assertThrows } from "jsr:@std/assert"; assertEquals(dot([5, 6, 3], [0.5, -3, 2.3]), -8.600000000000001);
Dot product of two arrays with negative numbers
Dot product of two arrays with negative numbers
import { assertEquals, assertThrows } from "jsr:@std/assert"; assertEquals(dot([-1, -2, -3], [-4, -5, -6]), 32);
Dot product of two identical arrays
Dot product of two identical arrays
import { assertEquals, assertThrows } from "jsr:@std/assert"; assertEquals(dot([1, 2, 3], [1, 2, 3]), 14);