Skip to content

Commit

Permalink
chore: more doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
morenol committed Nov 25, 2024
1 parent bc591d6 commit def877c
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 30 deletions.
2 changes: 0 additions & 2 deletions src/algorithm/neighbour/fastpair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ impl<'a, T: RealNumber + FloatNumber, M: Array2<T>> FastPair<'a, T, M> {
Ok(init)
}

///
/// Initialise `FastPair` by passing a `Array2`.
/// Build a FastPairs data-structure from a set of (new) points.
///
fn init(&mut self) {
// basic measures
let len = self.samples.shape().0;
Expand Down
8 changes: 4 additions & 4 deletions src/linalg/basic/arrays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ pub trait Array2<T: Debug + Display + Copy + Sized>: MutArrayView2<T> + Sized +
}
}
}
///
/// merge 1d arrays
fn merge_1d<'a>(&'a self, arrays: &'a [&'a dyn ArrayView1<T>], axis: u8, append: bool) -> Self {
assert!(
axis == 1 || axis == 0,
Expand Down Expand Up @@ -1362,7 +1362,7 @@ pub trait Array2<T: Debug + Display + Copy + Sized>: MutArrayView2<T> + Sized +
}
}
}
///
/// Stack arrays in sequence vertically
fn v_stack(&self, other: &dyn ArrayView2<T>) -> Self {
let (nrows, ncols) = self.shape();
let (other_nrows, other_ncols) = other.shape();
Expand All @@ -1378,7 +1378,7 @@ pub trait Array2<T: Debug + Display + Copy + Sized>: MutArrayView2<T> + Sized +
0,
)
}
///
/// Stack arrays in sequence horizontally
fn h_stack(&self, other: &dyn ArrayView2<T>) -> Self {
let (nrows, ncols) = self.shape();
let (other_nrows, other_ncols) = other.shape();
Expand Down Expand Up @@ -1407,7 +1407,7 @@ pub trait Array2<T: Debug + Display + Copy + Sized>: MutArrayView2<T> + Sized +
fn col_iter<'a>(&'a self) -> Box<dyn Iterator<Item = Box<dyn ArrayView1<T> + 'a>> + 'a> {
Box::new((0..self.shape().1).map(move |r| self.get_col(r)))
}
///
/// take elements from 2d array
fn take(&self, index: &[usize], axis: u8) -> Self {
let (nrows, ncols) = self.shape();

Expand Down
2 changes: 1 addition & 1 deletion src/linear/bg_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub trait BiconjugateGradientSolver<'a, T: FloatNumber, X: Array2<T>> {
y.copy_from(&x.xa(true, a));
}

///
/// Extract the diagonal from a matrix
fn diag(a: &X) -> Vec<T> {
let (nrows, ncols) = a.shape();
let n = nrows.min(ncols);
Expand Down
5 changes: 0 additions & 5 deletions src/linear/lasso_optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ impl<T: FloatNumber, X: Array2<T>> InteriorPointOptimizer<T, X> {
Ok(w)
}

///
fn sumlogneg(f: &X) -> T {
let (n, _) = f.shape();
let mut sum = T::zero();
Expand All @@ -220,11 +219,9 @@ impl<T: FloatNumber, X: Array2<T>> InteriorPointOptimizer<T, X> {
}
}

///
impl<'a, T: FloatNumber, X: Array2<T>> BiconjugateGradientSolver<'a, T, X>
for InteriorPointOptimizer<T, X>
{
///
fn solve_preconditioner(&self, a: &'a X, b: &[T], x: &mut [T]) {
let (_, p) = a.shape();

Expand All @@ -234,7 +231,6 @@ impl<'a, T: FloatNumber, X: Array2<T>> BiconjugateGradientSolver<'a, T, X>
}
}

///
fn mat_vec_mul(&self, _: &X, x: &Vec<T>, y: &mut Vec<T>) {
let (_, p) = self.ata.shape();
let x_slice = Vec::from_slice(x.slice(0..p).as_ref());
Expand All @@ -246,7 +242,6 @@ impl<'a, T: FloatNumber, X: Array2<T>> BiconjugateGradientSolver<'a, T, X>
}
}

///
fn mat_t_vec_mul(&self, a: &X, x: &Vec<T>, y: &mut Vec<T>) {
self.mat_vec_mul(a, x, y);
}
Expand Down
4 changes: 0 additions & 4 deletions src/neighbors/knn_regressor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,21 @@ pub struct KNNRegressor<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>, D:
impl<TX: Number, TY: Number, X: Array2<TX>, Y: Array1<TY>, D: Distance<Vec<TX>>>
KNNRegressor<TX, TY, X, Y, D>
{
///
fn y(&self) -> &Y {
self.y.as_ref().unwrap()
}

///
fn knn_algorithm(&self) -> &KNNAlgorithm<TX, D> {
self.knn_algorithm
.as_ref()
.expect("Missing parameter: KNNAlgorithm")
}

///
fn weight(&self) -> &KNNWeightFunction {
self.weight.as_ref().expect("Missing parameter: weight")
}

#[allow(dead_code)]
///
fn k(&self) -> usize {
self.k.unwrap()
}
Expand Down
3 changes: 0 additions & 3 deletions src/optimization/first_order/gradient_descent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub struct GradientDescent {
pub g_atol: f64,
}

///
impl Default for GradientDescent {
fn default() -> Self {
GradientDescent {
Expand All @@ -27,9 +26,7 @@ impl Default for GradientDescent {
}
}

///
impl<T: FloatNumber> FirstOrderOptimizer<T> for GradientDescent {
///
fn optimize<'a, X: Array1<T>, LS: LineSearchMethod<T>>(
&self,
f: &'a F<'_, T, X>,
Expand Down
9 changes: 0 additions & 9 deletions src/optimization/first_order/lbfgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ pub struct LBFGS {
pub m: usize,
}

///
impl Default for LBFGS {
///
fn default() -> Self {
LBFGS {
max_iter: 1000,
Expand All @@ -52,7 +50,6 @@ impl Default for LBFGS {
}

impl LBFGS {
///
fn two_loops<T: FloatNumber + RealNumber, X: Array1<T>>(&self, state: &mut LBFGSState<T, X>) {
let lower = state.iteration.max(self.m) - self.m;
let upper = state.iteration;
Expand Down Expand Up @@ -94,7 +91,6 @@ impl LBFGS {
state.s.mul_scalar_mut(-T::one());
}

///
fn init_state<T: FloatNumber + RealNumber, X: Array1<T>>(&self, x: &X) -> LBFGSState<T, X> {
LBFGSState {
x: x.clone(),
Expand All @@ -118,7 +114,6 @@ impl LBFGS {
}
}

///
fn update_state<'a, T: FloatNumber + RealNumber, X: Array1<T>, LS: LineSearchMethod<T>>(
&self,
f: &'a F<'_, T, X>,
Expand Down Expand Up @@ -160,7 +155,6 @@ impl LBFGS {
df(&mut state.x_df, &state.x);
}

///
fn assess_convergence<T: FloatNumber, X: Array1<T>>(
&self,
state: &mut LBFGSState<T, X>,
Expand Down Expand Up @@ -194,7 +188,6 @@ impl LBFGS {
g_converged || x_converged || state.counter_f_tol > self.successive_f_tol
}

///
fn update_hessian<T: FloatNumber, X: Array1<T>>(
&self,
_: &DF<'_, X>,
Expand Down Expand Up @@ -233,9 +226,7 @@ struct LBFGSState<T: FloatNumber, X: Array1<T>> {
alpha: T,
}

///
impl<T: FloatNumber + RealNumber> FirstOrderOptimizer<T> for LBFGS {
///
fn optimize<'a, X: Array1<T>, LS: LineSearchMethod<T>>(
&self,
f: &F<'_, T, X>,
Expand Down
2 changes: 0 additions & 2 deletions src/optimization/line_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ impl<T: Float> Default for Backtracking<T> {
}
}

///
impl<T: Float> LineSearchMethod<T> for Backtracking<T> {
///
fn search(
&self,
f: &(dyn Fn(T) -> T),
Expand Down

0 comments on commit def877c

Please sign in to comment.