@thi.ng/vectors
Version:
Optimized 2d/3d/4d and arbitrary length vector operations, support for memory mapping/layouts
38 lines • 1.05 kB
TypeScript
import type { ReadonlyVec, Vec } from "./api.js";
/**
* Takes an array of vectors (of uniform dimensions) and computes the
* componentwise medians (in accordance to the Manhattan-distance formulation of
* the k-medians problem). Writes result to `out` (or a new vector).
*
* @example
* ```ts tangle:../export/median.ts
* import { median } from "@thi.ng/vectors";
*
* console.log(
* median([], [[3, 10, 400], [4, 30, 100], [1, 40, 200], [2, 20, 300]])
* );
* // [ 3, 30, 300 ]
* ```
*
* @param out -
* @param src -
*/
export declare const median: (out: Vec | null, src: ReadonlyVec[]) => Vec<number>;
/**
* Computes the median component value of given vector. If |v| is even, returns
* the mean of the two center values. Returns 0 if vector is empty.
*
* @example
* ```ts tangle:../export/vmedian.ts
* import { vmedian } from "@thi.ng/vectors";
*
* console.log(
* vmedian([10, 20, 5, 15])
* );
* // 10
* ```
*
* @param a -
*/
export declare const vmedian: (a: ReadonlyVec) => number;
//# sourceMappingURL=median.d.ts.map