Skip to content

Commit

Permalink
fix(matrices): inject default output handling code
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Dec 30, 2018
1 parent b5adea6 commit 0b07ac8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/matrices/src/internal/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { compile } from "@thi.ng/vectors3/internal/codegen";
import {
ARGS_VN,
ARGS_VV,
compile,
DEFAULT_OUT
} from "@thi.ng/vectors3/internal/codegen";
import { MATH, MATH_N } from "@thi.ng/vectors3/internal/templates";
import { MultiMatOpMM, MultiMatOpMN } from "../api";

const DEFAULT_SIZES = [6, 9, 16];

export const defMath =
(fn: MultiMatOpMM, op: string, sizes = DEFAULT_SIZES) =>
sizes.map((n) => fn.add(n, compile(n, MATH(op), "o,a,b", undefined, "o")));
sizes.map((n) => fn.add(n, compile(n, MATH(op), ARGS_VV, undefined, "o", "", DEFAULT_OUT)));

export const defMathN =
(fn: MultiMatOpMN, op: string, sizes = DEFAULT_SIZES) =>
sizes.map((n) => fn.add(n, compile(n, MATH_N(op), "o,a,n", "o,a", "o")));
sizes.map((n) => fn.add(n, compile(n, MATH_N(op), ARGS_VN, "o,a", "o", "", DEFAULT_OUT)));

0 comments on commit 0b07ac8

Please sign in to comment.