aboutsummaryrefslogtreecommitdiff
path: root/src/vector.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/vector.rs')
-rw-r--r--src/vector.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/vector.rs b/src/vector.rs
index dfd2d71..c058490 100644
--- a/src/vector.rs
+++ b/src/vector.rs
@@ -68,3 +68,16 @@ pub fn scalar_product(a : &FileVector, b : &FileVector) -> u64 {
}
c
}
+
+pub fn match_vector(query : &FileVector, v : &FileVector) -> u64 {
+ let mut c = 0;
+ for (i, x) in query.iter() {
+ let s = x * (v.get(i).unwrap_or(&0));
+ if s == 0 {
+ return 0
+ } else {
+ c += s;
+ }
+ }
+ c
+}