1#![warn(missing_debug_implementations)]
2#![warn(missing_docs)]
3
4pub mod backtracking_steepest;
7pub mod fixed_step_steepest;
8
9use std::ops::Mul;
10
11use derive_more::Display;
12use derive_num_bounded::{derive_into_inner, derive_new_from_lower_bounded_partial_ord};
13use num_traits::{bounds::LowerBounded, real::Real};
14
15#[cfg(feature = "serde")]
16use serde::{Deserialize, Serialize};
17
18#[derive(Clone, Copy, Debug, thiserror::Error, PartialEq)]
21#[error("problem length does not match state length")]
22pub struct MismatchedLengthError;
23
24#[derive(Clone, Copy, Debug, Display, PartialEq, Eq, PartialOrd, Ord)]
27#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
28pub struct StepSize<A>(A);
29
30derive_new_from_lower_bounded_partial_ord!(StepSize<A: Real>);
31derive_into_inner!(StepSize<A>);
32
33impl<A> LowerBounded for StepSize<A>
34where
35 A: Real,
36{
37 fn min_value() -> Self {
38 Self(A::zero() + A::epsilon())
39 }
40}
41
42impl<A> Mul<A> for StepSize<A>
43where
44 A: Mul<Output = A>,
45{
46 type Output = A;
47
48 fn mul(self, rhs: A) -> Self::Output {
49 self.0 * rhs
50 }
51}