1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use ;
use ;
/// Definition of a function.
///
/// ## Defining a function
///
/// A function is any type that implements [`Function`] and [`Problem`] traits.
///
/// ```rust
/// use gomez::nalgebra as na;
/// use gomez::{Domain, Function, Problem};
/// use na::{Dyn, IsContiguous};
///
/// struct Rosenbrock {
/// a: f64,
/// b: f64,
/// }
///
/// impl Problem for Rosenbrock {
/// type Field = f64;
///
/// fn domain(&self) -> Domain<Self::Field> {
/// Domain::unconstrained(2)
/// }
/// }
///
/// impl Function for Rosenbrock {
/// fn apply<Sx>(&self, x: &na::Vector<Self::Field, Dyn, Sx>) -> Self::Field
/// where
/// Sx: na::storage::Storage<Self::Field, Dyn> + IsContiguous,
/// {
/// // Compute the function value.
/// (self.a - x[0]).powi(2) + self.b * (x[1] - x[0].powi(2)).powi(2)
/// }
/// }
/// ```