UNPKG

@thi.ng/vectors

Version:

Optimized 2d/3d/4d and arbitrary length vector operations, support for memory mapping/layouts

44 lines 1.56 kB
import type { ReadonlyVec, Vec, VecOpVN, VecOpVV, VecOpVVN, VecOpVVV } from "./api.js"; /** * Takes a vec op `fn`, output array (or null) and a combination of the * following inputs: * * - 2 arrays of vectors * - 1 array of vectors & 1 scalar * - 3 arrays of vectors * - 2 arrays of vectors & 1 scalar * * Then applies `fn` to each input and writes result into output array, * returns `out` (or new array if `out` was given as null). * * @example * ```ts tangle:../export/map-vectors.ts * import { add2, addN2, mapVectors, mixN2 } from "@thi.ng/vectors"; * * console.log( * mapVectors(addN2, [], [[1, 2], [10, 20]], 100) * ); * // [ [ 101, 102 ], [ 110, 120 ] ] * * console.log( * mapVectors(add2, [], [[1, 2], [10, 20]], [[100, 200], [1000, 2000]]) * ); * // [ [ 101, 202 ], [ 1010, 2020 ] ] * * console.log( * mapVectors(mixN2, null, [[1, 2], [100, 200]], [[10, 20], [1000, 2000]], 0.5) * ); * // [ [ 5.5, 11 ], [ 550, 1100 ] ] * ``` * * @param fn - * @param out - * @param a - * @param b - * @param c - */ export declare function mapVectors(fn: VecOpVV, out: Vec[] | null, a: ReadonlyVec[], b: ReadonlyVec[]): Vec[]; export declare function mapVectors(fn: VecOpVN, out: Vec[] | null, a: ReadonlyVec[], n: number): Vec[]; export declare function mapVectors(fn: VecOpVVV, out: Vec[] | null, a: ReadonlyVec[], b: ReadonlyVec[], c: ReadonlyVec[]): Vec[]; export declare function mapVectors(fn: VecOpVVN, out: Vec[] | null, a: ReadonlyVec[], b: ReadonlyVec[], c: number): Vec[]; //# sourceMappingURL=map-vectors.d.ts.map