Skip to main content

recognize_dot

Function recognize_dot 

Source
pub fn recognize_dot(
    stmts: &[Stmt<'_>],
    interner: &Interner,
) -> Result<DotSpec, DotReject>
Expand description

Recognize a dot product anywhere in a LOGOS statement list:

Let mutable s be 0.
Let mutable i be 0.
While i is less than n:
    Set s to s + item (i + 1) of a * item (i + 1) of b.
    Set i to i + 1.

A dot product is the zip sum whose term is the product of two reads: the loop is counted, the accumulator starts at zero right before it, both operands are read at the same unit-stride index, and the body holds nothing else but immutable index or product names. The search returns the refusal of the loop that came closest when nothing matches.