Function in prelude::math auto-imported

dot

fn dot<V, T>(V a, V b) -> T
Source: compiler/src/builtin_docs/prelude/math.hy

Returns the dot product of two vectors of the same length.

a and b are both tuples or both fixed arrays ([T; N]) of the same numeric element type (int, float or byte) and length. The result is the sum of the element-wise products, of the element type. * on tuples and arrays is element-wise, not a dot product.

Parameters#

NameType
aV
bV

Returns#

T

Examples#

use tests::assert;
assert!(dot((1, 2, 3), (4, 5, 6)) == 32);
assert!(dot([1.5, 2.0], [2.0, 4.0]) == 11.0);

See also#

  • int
  • float
  • byte
  • sin: Returns the sine of x (in radians).
  • cos: Returns the cosine of x (in radians).
  • tan: Returns the tangent of x (in radians).
  • sqrt: Returns the square root of x.
  • floor: Returns the largest whole number less than or equal to x, as a float.
↑ ↓ navigate ↵ open