MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / l1_norm_delta

Function l1_norm_delta

nodedb/src/engine/graph/algo/simd.rs:86–93  ·  view source on GitHub ↗

L1 norm of element-wise difference.

(a: &[f64], b: &[f64])

Source from the content-addressed store, hash-verified

84
85 /// L1 norm of element-wise difference.
86 pub fn l1_norm_delta(a: &[f64], b: &[f64]) -> f64 {
87 let n = a.len().min(b.len());
88 let mut sum = 0.0f64;
89 for i in 0..n {
90 sum += (a[i] - b[i]).abs();
91 }
92 sum
93 }
94
95 /// Sum of a[i] where mask[i] is true.
96 pub fn dangling_sum(a: &[f64], mask: &[bool]) -> f64 {

Callers

nothing calls this directly

Calls 4

l1_norm_delta_innerFunction · 0.85
lenMethod · 0.45
addMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected