Skip to content

Commit b71347f

Browse files
committed
documentation improvements
1 parent 9642e12 commit b71347f

File tree

2 files changed

+50
-14
lines changed

2 files changed

+50
-14
lines changed

src/lib.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
//! sides has been added to this library. This is a powerful technique for suitable
1313
//! problems and is explained at the end of this introductory chapter.
1414
//!
15+
//! ## Parallel Computations
16+
//!
17+
//! Since version 0.11.0, support for parallelizing some of the more expensive
18+
//! computations has been added. See the
19+
//! [`LevMarProblemBuilder::new_parallel`](crate::solvers::levmar::LevMarProblemBuilder::new_parallel) and
20+
//! [`LevMarProblemBuilder::mrhs_parallel`](crate::solvers::levmar::LevMarProblemBuilder::mrhs_parallel)
21+
//! builder functions. **Attention** Using multithreaded calculations might actually
22+
//! slow down the overall computations, so definitely make sure to compare it
23+
//! to the single-threaded case by **measuring**. For suitable problems it might
24+
//! give you a speedup in the double digit percentages, but for unsuitable ones
25+
//! it will slow the computations down much more than that.
26+
//!
1527
//! ## Overview
1628
//!
1729
//! Many nonlinear models consist of a mixture of both truly nonlinear and _linear_ model
@@ -387,7 +399,10 @@
387399
//! \end{matrix}\right)
388400
//! ```
389401
//!
390-
//! The order of the vectors in the matrix doesn't matter.
402+
//! The order of the vectors in the matrix doesn't matter, but it will determine
403+
//! the order of the linear coefficients, see
404+
//! [`LevMarProblemBuilder::mrhs`](crate::solvers::levmar::LevMarProblemBuilder::mrhs)
405+
//! for a more detailed explanation.
391406
//!
392407
//! ## Example
393408
//! ```no_run

src/solvers/levmar/builder.rs

+34-13
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,36 @@ where
180180
/// fit. This uses single threaded calculations.
181181
///
182182
/// That means the observations are expected to be a matrix, where the
183-
/// columns correspond to the individual observations. The nonlinear
184-
/// parameters will be optimized across all the observations, but the
185-
/// linear coefficients are calculated for each observation individually.
186-
/// Hence, they also become a matrix where the columns correspond to the
187-
/// linear coefficients of the observation in the same column.
183+
/// columns correspond to the individual observations.
184+
///
185+
/// For a set of observations `$\vec{y}_1,\dots,\vec{y}_S$` (column vectors) we
186+
/// now have to pass a _matrix_ `$Y$` of observations, rather than a single
187+
/// vector to the builder. As explained above, the resulting matrix would look
188+
/// like this.
189+
///
190+
/// ```math
191+
/// \boldsymbol{Y}=\left(\begin{matrix}
192+
/// \vert & & \vert \\
193+
/// \vec{y}_1 & \dots & \vec{y}_S \\
194+
/// \vert & & \vert \\
195+
/// \end{matrix}\right)
196+
/// ```
197+
///
198+
/// The nonlinear parameters will be optimized across all the observations
199+
/// globally, but the best linear coefficients are calculated for each observation
200+
/// individually. Hence, the latter also become a matrix `$C$`, where the columns
201+
/// correspond to the linear coefficients of the observation in the same column.
202+
///
203+
/// ```math
204+
/// \boldsymbol{C}=\left(\begin{matrix}
205+
/// \vert & & \vert \\
206+
/// \vec{c}_1 & \dots & \vec{c}_S \\
207+
/// \vert & & \vert \\
208+
/// \end{matrix}\right)
209+
/// ```
210+
///
211+
/// The (column) vector of linear coefficients `$\vec{c}_j$` is for the observation
212+
/// `$\vec{y}_j$` in the same column.
188213
pub fn mrhs(model: Model) -> Self {
189214
Self {
190215
Y: None,
@@ -205,16 +230,12 @@ where
205230
{
206231
/// Create a new builder based on the given model
207232
/// for a problem with **multiple right hand sides** and perform a global
208-
/// fit. This tries to increase the speed by using multithreaded calculations.
233+
/// fit, see also [`LevMarProblemBuilder::mrhs`](crate::solvers::levmar::LevMarProblemBuilder::mrhs)
234+
/// for an explanation how to order the observations into a matrix.
235+
///
236+
/// This approach tries to increase the speed by using multithreaded calculations.
209237
/// **Attention**: using multithreading might actually be slower,
210238
/// so always try it for your usecase and measure!
211-
///
212-
/// That means the observations are expected to be a matrix, where the
213-
/// columns correspond to the individual observations. The nonlinear
214-
/// parameters will be optimized across all the observations, but the
215-
/// linear coefficients are calculated for each observation individually.
216-
/// Hence, they also become a matrix where the columns correspond to the
217-
/// linear coefficients of the observation in the same column.
218239
pub fn mrhs_parallel(model: Model) -> Self {
219240
Self {
220241
Y: None,

0 commit comments

Comments
 (0)