UNPKG

simsimd

Version:

Portable mixed-precision BLAS-like vector math library for x86 and ARM

85 lines (84 loc) 5.5 kB
/** * @brief Computes the squared Euclidean distance between two vectors. * @param {Float64Array|Float32Array|Int8Array|Uint8Array} a - The first vector. * @param {Float64Array|Float32Array|Int8Array|Uint8Array} b - The second vector. * @returns {number} The squared Euclidean distance between vectors a and b. */ export declare const sqeuclidean: (a: Float64Array | Float32Array | Int8Array | Uint8Array, b: Float64Array | Float32Array | Int8Array | Uint8Array) => number; /** * @brief Computes the Euclidean distance between two vectors. * @param {Float64Array|Float32Array|Int8Array|Uint8Array} a - The first vector. * @param {Float64Array|Float32Array|Int8Array|Uint8Array} b - The second vector. * @returns {number} The Euclidean distance between vectors a and b. */ export declare const euclidean: (a: Float64Array | Float32Array | Int8Array | Uint8Array, b: Float64Array | Float32Array | Int8Array | Uint8Array) => number; /** * @brief Computes the cosine distance between two vectors. * @param {Float64Array|Float32Array|Int8Array|Uint8Array} a - The first vector. * @param {Float64Array|Float32Array|Int8Array|Uint8Array} b - The second vector. * @returns {number} The cosine distance between vectors a and b. */ export declare const cosine: (a: Float64Array | Float32Array | Int8Array | Uint8Array, b: Float64Array | Float32Array | Int8Array | Uint8Array) => number; /** * @brief Computes the inner product of two vectors (same as dot product). * @param {Float64Array|Float32Array|Int8Array|Uint8Array} a - The first vector. * @param {Float64Array|Float32Array|Int8Array|Uint8Array} b - The second vector. * @returns {number} The inner product of vectors a and b. */ export declare const inner: (a: Float64Array | Float32Array | Int8Array | Uint8Array, b: Float64Array | Float32Array | Int8Array | Uint8Array) => number; /** * @brief Computes the dot product of two vectors (same as inner product). * @param {Float64Array|Float32Array|Int8Array|Uint8Array} a - The first vector. * @param {Float64Array|Float32Array|Int8Array|Uint8Array} b - The second vector. * @returns {number} The dot product of vectors a and b. */ export declare const dot: (a: Float64Array | Float32Array | Int8Array | Uint8Array, b: Float64Array | Float32Array | Int8Array | Uint8Array) => number; /** * @brief Computes the bitwise Hamming distance between two vectors. * @param {Uint8Array} a - The first vector. * @param {Uint8Array} b - The second vector. * @returns {number} The Hamming distance between vectors a and b. */ export declare const hamming: (a: Uint8Array, b: Uint8Array) => number; /** * @brief Computes the bitwise Jaccard distance between two vectors. * @param {Uint8Array} a - The first vector. * @param {Uint8Array} b - The second vector. * @returns {number} The Jaccard distance between vectors a and b. */ export declare const jaccard: (a: Uint8Array, b: Uint8Array) => number; /** * @brief Computes the Kullback-Leibler divergence between two vectors. * @param {Float64Array|Float32Array} a - The first vector. * @param {Float64Array|Float32Array} b - The second vector. * @returns {number} The Kullback-Leibler divergence between vectors a and b. */ export declare const kullbackleibler: (a: Float64Array | Float32Array, b: Float64Array | Float32Array) => number; /** * @brief Computes the Jensen-Shannon divergence between two vectors. * @param {Float64Array|Float32Array} a - The first vector. * @param {Float64Array|Float32Array} b - The second vector. * @returns {number} The Jensen-Shannon divergence between vectors a and b. */ export declare const jensenshannon: (a: Float64Array | Float32Array, b: Float64Array | Float32Array) => number; /** * Quantizes a floating-point vector into a binary vector (1 for positive values, 0 for non-positive values) and packs the result into a Uint8Array, where each element represents 8 binary values from the original vector. * This function is useful for preparing data for bitwise distance computations, such as Hamming or Jaccard indices. * * @param {Float32Array | Float64Array | Int8Array} vector The floating-point vector to be quantized and packed. * @returns {Uint8Array} A Uint8Array where each byte represents 8 binary quantized values from the input vector. */ export declare const toBinary: (vector: Float32Array | Float64Array | Int8Array) => Uint8Array; declare const _default: { dot: (a: Float64Array | Float32Array | Int8Array | Uint8Array, b: Float64Array | Float32Array | Int8Array | Uint8Array) => number; inner: (a: Float64Array | Float32Array | Int8Array | Uint8Array, b: Float64Array | Float32Array | Int8Array | Uint8Array) => number; sqeuclidean: (a: Float64Array | Float32Array | Int8Array | Uint8Array, b: Float64Array | Float32Array | Int8Array | Uint8Array) => number; euclidean: (a: Float64Array | Float32Array | Int8Array | Uint8Array, b: Float64Array | Float32Array | Int8Array | Uint8Array) => number; cosine: (a: Float64Array | Float32Array | Int8Array | Uint8Array, b: Float64Array | Float32Array | Int8Array | Uint8Array) => number; hamming: (a: Uint8Array, b: Uint8Array) => number; jaccard: (a: Uint8Array, b: Uint8Array) => number; kullbackleibler: (a: Float64Array | Float32Array, b: Float64Array | Float32Array) => number; jensenshannon: (a: Float64Array | Float32Array, b: Float64Array | Float32Array) => number; toBinary: (vector: Float32Array | Float64Array | Int8Array) => Uint8Array; }; export default _default;