Skip to content

Commit cb81caf

Browse files
committed
Lagrange-Interpolator: Name amendments for clarity
1 parent eefdcd1 commit cb81caf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/RustQuant_math/src/interpolation/lagrange_interpolator.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ where
6969
})
7070
}
7171

72-
fn cardinal_function(&self, point: IndexType, pivot: IndexType, index: usize) -> ValueType {
73-
let mut lagrange_basis: ValueType = ValueType::one();
72+
fn lagrange_basis(&self, point: IndexType, node: IndexType, index: usize) -> ValueType {
73+
let mut basis: ValueType = ValueType::one();
7474
for (i, x) in self.xs.iter().enumerate() {
7575
if i != index {
76-
lagrange_basis *= (point - *x) / (pivot - *x);
76+
basis *= (point - *x) / (node - *x);
7777
}
7878
}
79-
lagrange_basis
79+
basis
8080
}
8181

8282
fn lagrange_polynomial(&self, point: IndexType) -> ValueType {
8383
let mut polynomial: ValueType = ValueType::zero();
8484
for (i, (x, y)) in self.xs.iter().zip(&self.ys).enumerate() {
85-
polynomial += *y * self.cardinal_function(point, *x, i);
85+
polynomial += *y * self.lagrange_basis(point, *x, i);
8686

8787
}
8888
polynomial

0 commit comments

Comments
 (0)