mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 06:54:58 +00:00
Update extramath.js
This commit is contained in:
parent
25bedaf938
commit
58bf6b5ee9
|
@ -43,6 +43,17 @@ function cos(A, B) {
|
|||
return similarity;
|
||||
}
|
||||
|
||||
// Cartesian product: https://en.wikipedia.org/wiki/Cartesian_product
|
||||
function cartesianProduct(arr) {
|
||||
return arr.reduce(function(a,b){
|
||||
return a.map(function(x){
|
||||
return b.map(function(y){
|
||||
return x.concat([y]);
|
||||
})
|
||||
}).reduce(function(a,b){ return a.concat(b) },[])
|
||||
}, [[]])
|
||||
}
|
||||
|
||||
exports.DTM = DTM;
|
||||
exports.cos = cos;
|
||||
exports.measureSimilarity = function(s1, s2) {
|
||||
|
@ -52,8 +63,9 @@ exports.measureSimilarity = function(s1, s2) {
|
|||
var mat = dtm.toArray();
|
||||
return cos(mat[0], mat[1]);
|
||||
};
|
||||
exports.cartesianProduct = cartesianProduct;
|
||||
|
||||
exports.VERSIONINFO = "ExtraMath module (extramath.js) version 0.0.3";
|
||||
exports.VERSIONINFO = "ExtraMath module (extramath.js) version 0.0.4";
|
||||
exports.AUTHOR = "catswords@protonmail.com";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user