Skip to content

Commit 96cd2fe

Browse files
committed
Lagrange-Interpolator: Name amendments for clarity + remove MulAssign (See PR note)
1 parent eefdcd1 commit 96cd2fe

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
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

crates/RustQuant_math/src/interpolation/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub use lagrange_interpolator::*;
2626
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2727

2828
/// Trait describing requirements to be interpolated.
29-
pub trait InterpolationValue: num::Num + AddAssign + MulAssign + std::fmt::Debug + Copy + Clone + Sized {}
29+
pub trait InterpolationValue: num::Num + AddAssign + std::fmt::Debug + Copy + Clone + Sized {}
3030

3131
/// Trait describing requirements to be an index of interpolation.
3232
pub trait InterpolationIndex:

0 commit comments

Comments
 (0)