CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB Recovery Status: - Successfully recovered brainy.ts from compiled JavaScript - All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.) - Neural subsystem intact (562KB embedded patterns, NLP working) - Augmentation pipeline operational (20+ augmentations) - HNSW clustering system complete - Triple Intelligence compiled (needs constructor fix) - Test suite validates functionality Changes preserved: - 898 files with changes from last 3 days - 144,475 insertions - All augmentation improvements - All test coverage enhancements - Complete v3.0 feature set This is a LOCAL checkpoint only - contains recovered work after corruption incident. Created backup in .backups/brainy-full-20250910-151314.tar.gz Branch: recovery-checkpoint-20250910-151433 Date: Wed Sep 10 03:18:04 PM PDT 2025
42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
/**
|
|
* Distance functions for vector similarity calculations
|
|
* Optimized pure JavaScript implementations using enhanced array methods
|
|
* Faster than GPU for small vectors (384 dims) due to no transfer overhead
|
|
*/
|
|
import { DistanceFunction, Vector } from '../coreTypes.js';
|
|
/**
|
|
* Calculates the Euclidean distance between two vectors
|
|
* Lower values indicate higher similarity
|
|
* Optimized using array methods for Node.js 23.11+
|
|
*/
|
|
export declare const euclideanDistance: DistanceFunction;
|
|
/**
|
|
* Calculates the cosine distance between two vectors
|
|
* Lower values indicate higher similarity
|
|
* Range: 0 (identical) to 2 (opposite)
|
|
* Optimized using array methods for Node.js 23.11+
|
|
*/
|
|
export declare const cosineDistance: DistanceFunction;
|
|
/**
|
|
* Calculates the Manhattan (L1) distance between two vectors
|
|
* Lower values indicate higher similarity
|
|
* Optimized using array methods for Node.js 23.11+
|
|
*/
|
|
export declare const manhattanDistance: DistanceFunction;
|
|
/**
|
|
* Calculates the dot product similarity between two vectors
|
|
* Higher values indicate higher similarity
|
|
* Converted to a distance metric (lower is better)
|
|
* Optimized using array methods for Node.js 23.11+
|
|
*/
|
|
export declare const dotProductDistance: DistanceFunction;
|
|
/**
|
|
* Batch distance calculation using optimized JavaScript
|
|
* More efficient than GPU for small vectors due to no memory transfer overhead
|
|
*
|
|
* @param queryVector The query vector to compare against all vectors
|
|
* @param vectors Array of vectors to compare against
|
|
* @param distanceFunction The distance function to use
|
|
* @returns Promise resolving to array of distances
|
|
*/
|
|
export declare function calculateDistancesBatch(queryVector: Vector, vectors: Vector[], distanceFunction?: DistanceFunction): Promise<number[]>;
|