@thi.ng/tensors
Version:
0D/1D/2D/3D/4D tensors with extensible polymorphic operations and customizable storage
13 lines (12 loc) • 382 B
JavaScript
import { defError } from "@thi.ng/errors/deferror";
import { equals } from "@thi.ng/vectors/equals";
const IllegalShapeError = defError(() => "illegal shape");
const illegalShape = (shape) => {
throw new IllegalShapeError(shape);
};
const ensureShape = (t, shape) => !equals(t.shape, shape) && illegalShape(t.shape);
export {
IllegalShapeError,
ensureShape,
illegalShape
};