xen-dev-utils
Version:
Utility functions used by the Scale Workshop ecosystem
27 lines (26 loc) • 966 B
TypeScript
export interface NumberArray {
[key: number]: number;
length: number;
}
/**
* Calculate the inner (dot) product of two arrays of real numbers.
* @param a The first array of numbers.
* @param b The second array of numbers.
* @returns The dot product.
*/
export declare function dot(a: NumberArray, b: NumberArray): number;
/**
* Calculate the inner (dot) product of two arrays of real numbers.
* The resulting terms are summed accurately using Shewchuk's algorithm.
* @param a The first array of numbers.
* @param b The second array of numbers.
* @returns The dot product.
*/
export declare function dotPrecise(a: NumberArray, b: NumberArray): number;
/**
* Calculate the norm (vector length) of an array of real numbers.
* @param array The array to measure.
* @param type Type of measurement.
* @returns The length of the vector.
*/
export declare function norm(array: NumberArray, type?: 'euclidean' | 'L2' | 'taxicab' | 'maximum'): number;