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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! This module contains functions to compare float numbers and arrays for unit testing
//!
//! # Examples
//!
//! ### Check floating point numbers (real)
//!
//! ```rust
//! use russell_lab::*;
//!
//! fn main() {
//! approx_eq(0.123456789, 0.12345678, 1e-8);
//! approx_eq(0.123456789, 0.1234567, 1e-7);
//! approx_eq(0.123456789, 0.123456, 1e-6);
//! approx_eq(0.123456789, 0.12345, 1e-5);
//! approx_eq(0.123456789, 0.1234, 1e-4);
//! }
//! ```
//!
//! ### Check floating point numbers (complex)
//!
//! ```
//! use russell_lab::*;
//!
//! fn main() {
//! // check floating point number
//! approx_eq(0.0000123, 0.000012, 1e-6);
//!
//! // check vector of floating point numbers
//! array_approx_eq(&[0.01, 0.012], &[0.012, 0.01], 1e-2);
//!
//! // check derivative using central differences
//! struct Arguments {}
//! let f = |x: f64, _: &mut Arguments| Ok(-x);
//! let args = &mut Arguments {};
//! let at_x = 8.0;
//! let dfdx = -1.01;
//! deriv1_approx_eq(dfdx, at_x, args, 1e-2, f);
//!
//! // check complex numbers
//! complex_approx_eq(Complex64::new(1.0, 8.0), Complex64::new(1.001, 8.0), 1e-2);
//! }
//! ```
//!
//! ### Check vectors of floating point numbers (real)
//!
//! ```rust
//! use russell_lab::*;
//!
//! fn main() {
//! let a = [0.123456789, 0.123456789, 0.123456789];
//! let b = [0.12345678, 0.1234567, 0.123456];
//! array_approx_eq(&a, &b, 1e-6);
//! }
//! ```
//!
//! ### Check vectors of floating point numbers (complex)
//!
//! ```rust
//! use russell_lab::*;
//!
//! fn main() {
//! let a = &[
//! Complex64::new(0.123456789, 5.01),
//! Complex64::new(0.123456789, 5.01),
//! Complex64::new(0.123456789, 5.01)];
//! let b = &[
//! Complex64::new(0.12345678, 5.01),
//! Complex64::new(0.1234567, 5.01),
//! Complex64::new(0.123456, 5.01)];
//! complex_array_approx_eq(a, b, 1e-6);
//! }
//! ```
//!
//! ### Check derivatives using finite differences
//!
//! ```rust
//! use russell_lab::*;
//!
//! struct Arguments {}
//!
//! fn main() {
//! let f = |x: f64, _: &mut Arguments| Ok(-x);
//! let args = &mut Arguments {};
//! let at_x = 8.0;
//! let dfdx = -1.01;
//! deriv1_approx_eq(dfdx, at_x, args, 1e-2, f);
//! }
//! ```
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;