Skip to main content

recognize_outer

Function recognize_outer 

Source
pub fn recognize_outer(
    stmts: &[Stmt<'_>],
    interner: &Interner,
) -> Result<OuterSpec, OuterReject>
Expand description

Recognize an outer product anywhere in a LOGOS statement list:

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

Both loops are counted; the store is C[i·n + j] (row-major against the inner trip count), A is read at a unit stride of i alone and B of j alone; and the bodies hold nothing else but immutable index or product names. C[idx] := C[idx] + A·B is refused by name: it is a rank-1 update.