From 9cda00279683d61a811867d57142d154b5df1c02 Mon Sep 17 00:00:00 2001 From: bluthej Date: Wed, 21 May 2025 23:50:22 +0200 Subject: [PATCH 1/3] Fix a few typos in rk module and add links --- src/ivp/rk.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/ivp/rk.rs b/src/ivp/rk.rs index 81c07ad..ecb8e58 100644 --- a/src/ivp/rk.rs +++ b/src/ivp/rk.rs @@ -13,7 +13,7 @@ use num_traits::{FromPrimitive, One, Zero}; use std::marker::PhantomData; /// This trait defines a Runge-Kutta solver -/// The RungeKutta struct takes an implemetation of this trait +/// The [`RungeKutta`] struct takes an implementation of this trait /// as a type argument since the algorithm is the same for /// all the methods, just the order and these functions /// need to be different. @@ -21,25 +21,25 @@ pub trait RungeKuttaCoefficients { /// The real field associated with the solver's Field. type RealField: RealField; - /// Returns a vec of coeffecients to multiply the time step by when getting - /// intermediate results. Upper-left portion of Butch Tableaux + /// Returns a vec of coefficients to multiply the time step by when getting + /// intermediate results. Upper-left portion of Butcher Tableaux fn t_coefficients() -> Option>; /// Returns the coefficients to use on the k_i's when finding another - /// k_i. Upper-right portion of the Butch Tableax. Should be + /// k_i. Upper-right portion of the Butcher Tableaux. Should be /// an NxN-1 matrix, where N is the order of the Runge-Kutta Method (Or order+1 for /// adaptive methods) fn k_coefficients() -> Option>; /// Coefficients to use when calculating the final step to take. /// These are the weights of the weighted average of k_i's. Bottom - /// portion of the Butch Tableaux. For adaptive methods, this is the first + /// portion of the Butcher Tableaux. For adaptive methods, this is the first /// row of the bottom portion. fn avg_coefficients() -> Option>; /// Coefficients to use on /// the k_i's to find the error between the two orders - /// of Runge-Kutta methods. In the Butch Tableaux, this is + /// of Runge-Kutta methods. In the Butcher Tableaux, this is /// the first row of the bottom portion minus the second row. fn error_coefficients() -> Option>; } @@ -192,7 +192,7 @@ where } /// Will overwrite any previously set value - /// If the provided minimum is greatear than a previously set maximum, then the maximum + /// If the provided minimum is greater than a previously set maximum, then the maximum /// is set to this value as well. fn with_minimum_dt(mut self, min: Self::RealField) -> Result { if min <= ::zero() { @@ -527,9 +527,9 @@ impl RungeKuttaCoefficients<6> for RKCoefficients45 { /// Runge-Kutta-Fehlberg method for solving an IVP. /// -/// Defines the Butch Tableaux for a 5(4) order adaptive -/// runge-kutta method. Uses RungeKutta to do the actual solving. -/// Provides an implementation of the IVPSolver trait. +/// Defines the Butcher Tableaux for a 5(4) order adaptive +/// runge-kutta method. Uses [`RungeKutta`] to do the actual solving. +/// Provides an implementation of the [`IVPSolver`] trait. /// /// # Examples /// ``` @@ -622,9 +622,9 @@ impl RungeKuttaCoefficients<4> for RK23Coefficients { /// Bogacki-Shampine method for solving an IVP. /// -/// Defines the Butch Tableaux for a 5(4) order adaptive -/// runge-kutta method. Uses RungeKutta to do the actual solving. -/// Provides an implementation of the IVPSolver trait. +/// Defines the Butcher Tableaux for a 5(4) order adaptive +/// Runge-Kutta method. Uses [`RungeKutta`] to do the actual solving. +/// Provides an implementation of the [`IVPSolver`] trait. /// /// # Examples /// ``` From 895c0f51c3317b599b74b911568033dfd97a5939 Mon Sep 17 00:00:00 2001 From: bluthej Date: Wed, 21 May 2025 23:54:51 +0200 Subject: [PATCH 2/3] Escape square brackets in doc comments --- src/interp/mod.rs | 2 +- src/interp/spline.rs | 4 ++-- src/optimize/mod.rs | 2 +- src/polynomial/mod.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/interp/mod.rs b/src/interp/mod.rs index b4e7829..937c8c7 100644 --- a/src/interp/mod.rs +++ b/src/interp/mod.rs @@ -13,7 +13,7 @@ pub use spline::*; /// Create a Lagrange interpolating polynomial. /// -/// Create an nth degree polynomial matching the n points (xs[i], ys[i]) +/// Create an nth degree polynomial matching the n points (xs\[i\], ys\[i\]) /// using Neville's iterated method for Lagrange polynomials. The result will /// match no derivatives. /// diff --git a/src/interp/spline.rs b/src/interp/spline.rs index 46e414d..e43daa7 100644 --- a/src/interp/spline.rs +++ b/src/interp/spline.rs @@ -61,7 +61,7 @@ where /// `xs` x points. Must be real because cubic splines keep track of ranges within /// which it interpolates. Must be sorted. /// -/// `ys` y points. Can be complex. ys[i] must match with xs[i]. +/// `ys` y points. Can be complex. ys\[i\] must match with xs\[i\]. /// /// `tol` the tolerance of the polynomials /// @@ -178,7 +178,7 @@ where /// `xs` x points. Must be real because cubic splines keep track of ranges within /// which it interpolates. Must be sorted. /// -/// `ys` y points. Can be complex. ys[i] must match with xs[i]. +/// `ys` y points. Can be complex. ys\[i\] must match with xs\[i\]. /// /// `(f_0, f_n)` The derivative values at the end points. /// diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index d073a09..21ee1db 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -384,7 +384,7 @@ where /// Uses an analytic jacobian.Keeps iterating until /// the differences between the sum of the square residuals of two iterations /// is under tol. Jacobian should be a function that returns a column vector -/// where jacobian[i] is the partial derivative of f with respect to param[i]. +/// where jacobian\[i\] is the partial derivative of f with respect to param\[i\]. /// /// # Errors /// Returns an error if curve fit fails. diff --git a/src/polynomial/mod.rs b/src/polynomial/mod.rs index c91e9dc..d455a2a 100644 --- a/src/polynomial/mod.rs +++ b/src/polynomial/mod.rs @@ -87,7 +87,7 @@ where self.coefficients.len() - 1 } - /// Returns the coefficients in the correct order to recreate the polynomial with Polynomial::from_slice(data: &[N]); + /// Returns the coefficients in the correct order to recreate the polynomial with [`Polynomial::from_slice`] pub fn get_coefficients(&self) -> Vec { let mut cln = self.coefficients.clone(); cln.reverse(); From eb883a3ab898441e946d6bfbf1040eff0822e3e1 Mon Sep 17 00:00:00 2001 From: bluthej Date: Thu, 22 May 2025 00:09:55 +0200 Subject: [PATCH 3/3] Add missing links to docs --- src/ivp.rs | 12 ++++++------ src/ivp/adams.rs | 6 +++--- src/ivp/bdf.rs | 8 ++++---- src/ivp/rk.rs | 8 ++++---- src/optimize/mod.rs | 6 +++--- src/polynomial/mod.rs | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/ivp.rs b/src/ivp.rs index ae76b6d..0d0e721 100644 --- a/src/ivp.rs +++ b/src/ivp.rs @@ -14,8 +14,8 @@ pub mod adams; pub mod bdf; pub mod rk; -/// Status returned from the IVPStepper -/// Used by the IVPIterator struct to correctly step through +/// Status returned from the [`IVPStepper`] +/// Used by the [`IVPIterator`] struct to correctly step through /// the IVP solution. #[derive(Error, Clone, Debug)] pub enum IVPStatus { @@ -90,14 +90,14 @@ impl From for IVPError { } } -/// A type alias for a Result of a IVPStepper step +/// A type alias for a Result of a [`IVPStepper`] step /// Ok is a tuple of the time and solution at that time /// Err is an IVPError pub type Step = Result<(R, BVector), IVPStatus>; /// Implementing this trait is providing the main functionality of /// an initial value problem solver. This should be used only when -/// implementing an IVPSolver, users should use the solver via the IVPSolver +/// implementing an [`IVPSolver`], users should use the solver via the [`IVPSolver`] /// trait's interface. pub trait IVPStepper: Sized where @@ -128,7 +128,7 @@ where /// Build up the solver using the parameter builder functions and then use solve. /// /// This is used as a builder pattern, setting parameters of the solver. -/// IVPSolver implementations should implement a step function that +/// [`IVPSolver`] implementations should implement a step function that /// returns an IVPStatus, then a blanket impl will allow it to be used as an /// IntoIterator for the user to iterate over the results. pub trait IVPSolver<'a, D: Dimension>: Sized @@ -284,7 +284,7 @@ where } /// The struct that actually solves an IVP with Euler's method -/// Is the associated IVPStepper for Euler (the IVPSolver) +/// Is the associated [`IVPStepper`] for Euler (the IVPSolver) /// You should use Euler and not this type directly pub struct EulerSolver<'a, N, D, T, F> where diff --git a/src/ivp/adams.rs b/src/ivp/adams.rs index 4e7883b..5082c3d 100644 --- a/src/ivp/adams.rs +++ b/src/ivp/adams.rs @@ -14,7 +14,7 @@ use std::collections::VecDeque; use std::marker::PhantomData; /// This trait defines an Adams predictor-corrector solver -/// The Adams struct takes an implemetation of this trait +/// The [`Adams`] struct takes an implemetation of this trait /// as a type argument since the algorithm is the same for /// all the predictor correctors, just the order and these functions /// need to be different. @@ -602,7 +602,7 @@ impl AdamsCoefficients<5> for AdamsCoefficients5 { /// 5th order Adams predictor-corrector method for solving an IVP. /// /// Defines the predictor and corrector coefficients, as well as -/// the error coefficient. Uses Adams for the actual solving. +/// the error coefficient. Uses [`Adams`] for the actual solving. /// /// # Examples /// ``` @@ -661,7 +661,7 @@ impl AdamsCoefficients<3> for AdamsCoefficients3 { /// 3rd order Adams predictor-corrector method for solving an IVP. /// /// Defines the predictor and corrector coefficients, as well as -/// the error coefficient. Uses Adams for the actual solving. +/// the error coefficient. Uses [`Adams`] for the actual solving. /// /// # Examples /// ``` diff --git a/src/ivp/bdf.rs b/src/ivp/bdf.rs index 79f34ba..633910a 100644 --- a/src/ivp/bdf.rs +++ b/src/ivp/bdf.rs @@ -14,7 +14,7 @@ use std::collections::VecDeque; use std::marker::PhantomData; /// This trait defines an BDF solver -/// The BDF struct takes an implemetation of this trait +/// The [`BDF`] struct takes an implemetation of this trait /// as a type argument since the algorithm is the same for /// all the orders, just the constants are different. pub trait BDFCoefficients { @@ -68,7 +68,7 @@ where /// The solver for any BDF predictor-corrector /// Users should not use this type directly, and should /// instead get it from a specific BDF method struct -/// (wrapped in an IVPIterator) +/// (wrapped in an [`IVPIterator`]) pub struct BDFSolver<'a, N, D, const O: usize, T, F> where D: Dimension, @@ -676,7 +676,7 @@ impl BDFCoefficients<7> for BDF6Coefficients { /// solving an initial value problem. /// /// Defines the higher and lower order coefficients. Uses -/// BDFInfo for the actual solving. +/// [`BDFInfo`] for the actual solving. /// /// # Examples /// ``` @@ -733,7 +733,7 @@ impl BDFCoefficients<3> for BDF2Coefficients { /// solving an initial value problem. /// /// Defines the higher and lower order coefficients. Uses -/// BDFInfo for the actual solving. +/// [`BDFInfo`] for the actual solving. /// /// # Examples /// ``` diff --git a/src/ivp/rk.rs b/src/ivp/rk.rs index ecb8e58..a1a2e2c 100644 --- a/src/ivp/rk.rs +++ b/src/ivp/rk.rs @@ -70,8 +70,8 @@ where /// The solver for any Runge-Kutta method /// Users should not use this type directly, and should -/// instead get it from a specific RungeKutta struct -/// (wrapped in an IVPIterator) +/// instead get it from a specific [`RungeKutta`] struct +/// (wrapped in an [`IVPIterator`]) pub struct RungeKuttaSolver<'a, N, D, const O: usize, T, F> where D: Dimension, @@ -95,7 +95,7 @@ where dt: N, state: BVector, - // Per-order constants set by RungeKuttaCoefficients + // Per-order constants set by [`RungeKuttaCoefficients`] t_coefficients: BSVector, k_coefficients: BSMatrix, avg_coefficients: BSVector, @@ -528,7 +528,7 @@ impl RungeKuttaCoefficients<6> for RKCoefficients45 { /// Runge-Kutta-Fehlberg method for solving an IVP. /// /// Defines the Butcher Tableaux for a 5(4) order adaptive -/// runge-kutta method. Uses [`RungeKutta`] to do the actual solving. +/// Runge-Kutta method. Uses [`RungeKutta`] to do the actual solving. /// Provides an implementation of the [`IVPSolver`] trait. /// /// # Examples diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index 21ee1db..a83bd15 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -8,7 +8,7 @@ use num_traits::{FromPrimitive, One, Zero}; /// Returns an error if the linear fit fails. (`xs.len() != ys.len()`) /// /// # Panics -/// Panics if a `usize` can not be transformed into the generic type. +/// Panics if a [`usize`] cannot be transformed into the generic type. pub fn linear_fit(xs: &[N], ys: &[N]) -> Result, String> where N: ComplexField + FromPrimitive + Copy, @@ -244,7 +244,7 @@ where /// Fit a curve using the Levenberg-Marquardt algorithm. /// /// Uses finite differences of h to calculate the jacobian. If jacobian -/// can be found analytically, then use `curve_fit_jac`. Keeps iterating until +/// can be found analytically, then use [`curve_fit_jac`]. Keeps iterating until /// the differences between the sum of the square residuals of two iterations /// is under tol. /// @@ -390,7 +390,7 @@ where /// Returns an error if curve fit fails. /// /// # Panics -/// Panics if a u8 can not be converted to the generic type. +/// Panics if a [`u8`] can not be converted to the generic type. pub fn curve_fit_jac( mut f: F, xs: &[N], diff --git a/src/polynomial/mod.rs b/src/polynomial/mod.rs index d455a2a..6a37fe8 100644 --- a/src/polynomial/mod.rs +++ b/src/polynomial/mod.rs @@ -5,7 +5,7 @@ use num_traits::{FromPrimitive, One, Zero}; use std::collections::VecDeque; use std::{any::TypeId, f64, iter::FromIterator, ops}; -/// Polynomial on a ComplexField. +/// Polynomial on a [`ComplexField`]. #[derive(Debug, Clone)] pub struct Polynomial where