@langchain/core
Version:
Core LangChain.js abstractions and schemas
19 lines (18 loc) • 512 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.innerProduct = void 0;
/**
*Returns the Inner Product similarity between vectors a and b
* @link [Inner Product Similarity algorithm](https://www.naun.org/main/NAUN/ijmmas/mmmas-49.pdf)
* @param a - first vector
* @param b - second vector
*
*/
function innerProduct(a, b) {
let ans = 0;
for (let i = 0; i < a.length; i++) {
ans += a[i] * b[i];
}
return ans;
}
exports.innerProduct = innerProduct;