MCPcopy Index your code
hub / github.com/forloopcodes/contextplus / cosine

Function cosine

src/core/embeddings.ts:316–325  ·  view source on GitHub ↗
(a: number[], b: number[])

Source from the content-addressed store, hash-verified

314}
315
316function cosine(a: number[], b: number[]): number {
317 let dot = 0, normA = 0, normB = 0;
318 for (let i = 0; i < a.length; i++) {
319 dot += a[i] * b[i];
320 normA += a[i] * a[i];
321 normB += b[i] * b[i];
322 }
323 const denom = Math.sqrt(normA) * Math.sqrt(normB);
324 return denom === 0 ? 0 : dot / denom;
325}
326
327function splitCamelCase(text: string): string[] {
328 return text

Callers 1

searchMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected