Skip to content

Commit a8db2ce

Browse files
Merge pull request #349 from nyx-space/dep/nalgebra-0.33
Update to nalgebra 0.33 + switch to anise git
2 parents d1db1d7 + 1aa0d03 commit a8db2ce

33 files changed

+344
-418
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ maintenance = { status = "actively-developed" }
3434
gitlab = { repository = "nyx-space/nyx", branch = "master" }
3535

3636
[dependencies]
37-
nalgebra = "=0.32"
37+
nalgebra = "0.33"
3838
log = "0.4"
3939
hifitime = "4.0.0-alpha"
40-
anise = "0.4.0"
40+
# anise = "0.4.0"
41+
anise = { git = "https://github.com/nyx-space/anise.git", branch = "master" }
4142
flate2 = { version = "1.0", features = [
4243
"rust_backend",
4344
], default-features = false }
4445
serde = "1.0"
4546
serde_derive = "1.0"
4647
csv = "1"
47-
hyperdual = "=1.2.0"
48+
hyperdual = "1.3.0"
4849
bytes = "1.0"
4950
rand = "0.8"
5051
rand_distr = "0.4"

src/cosmic/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ pub trait TimeTagged {
4242
pub trait State: Default + Copy + PartialEq + fmt::Display + fmt::LowerExp + Send + Sync
4343
where
4444
Self: Sized,
45-
DefaultAllocator: Allocator<f64, Self::Size>
46-
+ Allocator<f64, Self::Size, Self::Size>
47-
+ Allocator<f64, Self::VecLength>,
45+
DefaultAllocator:
46+
Allocator<Self::Size> + Allocator<Self::Size, Self::Size> + Allocator<Self::VecLength>,
4847
{
4948
/// Size of the state and its STM
5049
type Size: DimName;
@@ -85,7 +84,7 @@ where
8584
vector: &OVector<f64, Self::VecLength>,
8685
) -> Self
8786
where
88-
DefaultAllocator: Allocator<f64, Self::VecLength>,
87+
DefaultAllocator: Allocator<Self::VecLength>,
8988
{
9089
self.set(self.epoch() + delta_t_s, vector);
9190
self

src/dynamics/mod.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::State;
2323
use anise::almanac::planetary::PlanetaryDataError;
2424
use anise::almanac::Almanac;
2525
use anise::errors::AlmanacError;
26-
use hyperdual::{OHyperdual, Owned};
26+
use hyperdual::Owned;
2727
use snafu::Snafu;
2828

2929
use std::fmt;
@@ -75,9 +75,9 @@ pub use self::sph_harmonics::*;
7575
#[allow(clippy::type_complexity)]
7676
pub trait Dynamics: Clone + Sync + Send
7777
where
78-
DefaultAllocator: Allocator<f64, <Self::StateType as State>::Size>
79-
+ Allocator<f64, <Self::StateType as State>::VecLength>
80-
+ Allocator<f64, <Self::StateType as State>::Size, <Self::StateType as State>::Size>,
78+
DefaultAllocator: Allocator<<Self::StateType as State>::Size>
79+
+ Allocator<<Self::StateType as State>::VecLength>
80+
+ Allocator<<Self::StateType as State>::Size, <Self::StateType as State>::Size>,
8181
{
8282
/// The state of the associated hyperdual state, almost always StateType + U1
8383
type HyperdualSize: DimName;
@@ -96,7 +96,7 @@ where
9696
almanac: Arc<Almanac>,
9797
) -> Result<OVector<f64, <Self::StateType as State>::VecLength>, DynamicsError>
9898
where
99-
DefaultAllocator: Allocator<f64, <Self::StateType as State>::VecLength>;
99+
DefaultAllocator: Allocator<<Self::StateType as State>::VecLength>;
100100

101101
/// Defines the equations of motion for Dual numbers for these dynamics.
102102
/// _All_ dynamics need to allow for automatic differentiation. However, if differentiation is not supported,
@@ -114,10 +114,9 @@ where
114114
DynamicsError,
115115
>
116116
where
117-
DefaultAllocator: Allocator<f64, Self::HyperdualSize>
118-
+ Allocator<f64, <Self::StateType as State>::Size>
119-
+ Allocator<f64, <Self::StateType as State>::Size, <Self::StateType as State>::Size>
120-
+ Allocator<OHyperdual<f64, Self::HyperdualSize>, <Self::StateType as State>::Size>,
117+
DefaultAllocator: Allocator<Self::HyperdualSize>
118+
+ Allocator<<Self::StateType as State>::Size>
119+
+ Allocator<<Self::StateType as State>::Size, <Self::StateType as State>::Size>,
121120
Owned<f64, Self::HyperdualSize>: Copy,
122121
{
123122
Err(DynamicsError::StateTransitionMatrixUnset)

src/io/tracking_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl DynamicTrackingArc {
8989
pub fn to_tracking_arc<Msr>(&self) -> Result<TrackingArc<Msr>, InputOutputError>
9090
where
9191
Msr: Measurement,
92-
DefaultAllocator: Allocator<f64, Msr::MeasurementSize>,
92+
DefaultAllocator: Allocator<Msr::MeasurementSize>,
9393
{
9494
// Read the file since we closed it earlier
9595
let file = File::open(&self.path).context(StdIOSnafu {

src/io/trajectory_data.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ impl TrajectoryLoader {
9999
pub fn to_traj<S>(&self) -> Result<Traj<S>, InputOutputError>
100100
where
101101
S: Interpolatable,
102-
DefaultAllocator: Allocator<f64, S::VecLength>
103-
+ Allocator<f64, S::Size>
104-
+ Allocator<f64, S::Size, S::Size>,
102+
DefaultAllocator:
103+
Allocator<S::VecLength> + Allocator<S::Size> + Allocator<S::Size, S::Size>,
105104
{
106105
// Check the schema
107106
let mut has_epoch = false; // Required

src/mc/generator.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ impl Dispersion<Normal<f64>> {
5858
#[derive(Clone)]
5959
pub struct DispersedState<S: State>
6060
where
61-
DefaultAllocator: Allocator<f64, S::Size>
62-
+ Allocator<f64, S::Size, S::Size>
63-
+ Allocator<usize, S::Size, S::Size>
64-
+ Allocator<f64, S::VecLength>,
61+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
6562
{
6663
/// The dispersed state
6764
pub state: S,

src/mc/montecarlo.rs

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use rand::SeedableRng;
3636
use rand_distr::Distribution;
3737
use rayon::prelude::ParallelIterator;
3838
use rayon::prelude::*;
39-
use std::f64;
4039
use std::fmt;
4140
use std::sync::mpsc::channel;
4241
use std::sync::Arc;
@@ -47,10 +46,7 @@ use std::time::Instant as StdInstant;
4746
/// One caveat of the design is that the trajectory is used for post processing, not each individual state. This may prevent some event switching from being shown in GNC simulations.
4847
pub struct MonteCarlo<S: Interpolatable, Distr: Distribution<DispersedState<S>>>
4948
where
50-
DefaultAllocator: Allocator<f64, S::Size>
51-
+ Allocator<f64, S::Size, S::Size>
52-
+ Allocator<f64, S::VecLength>
53-
+ Allocator<usize, S::Size, S::Size>,
49+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
5450
{
5551
/// Seed of the [64bit PCG random number generator](https://www.pcg-random.org/index.html)
5652
pub seed: Option<u128>,
@@ -63,10 +59,7 @@ where
6359

6460
impl<S: Interpolatable, Distr: Distribution<DispersedState<S>>> MonteCarlo<S, Distr>
6561
where
66-
DefaultAllocator: Allocator<f64, S::Size>
67-
+ Allocator<f64, S::Size, S::Size>
68-
+ Allocator<f64, S::VecLength>
69-
+ Allocator<usize, S::Size, S::Size>,
62+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
7063
{
7164
pub fn new(
7265
nominal_state: S,
@@ -109,11 +102,10 @@ where
109102
D: Dynamics<StateType = S>,
110103
E: ErrorCtrl,
111104
F: EventEvaluator<S>,
112-
DefaultAllocator: Allocator<f64, <D::StateType as State>::Size>
113-
+ Allocator<f64, <D::StateType as State>::Size, <D::StateType as State>::Size>
114-
+ Allocator<usize, <D::StateType as State>::Size, <D::StateType as State>::Size>
115-
+ Allocator<f64, <D::StateType as State>::VecLength>,
116-
<DefaultAllocator as Allocator<f64, <D::StateType as State>::VecLength>>::Buffer: Send,
105+
DefaultAllocator: Allocator<<D::StateType as State>::Size>
106+
+ Allocator<<D::StateType as State>::Size, <D::StateType as State>::Size>
107+
+ Allocator<<D::StateType as State>::VecLength>,
108+
<DefaultAllocator as Allocator<<D::StateType as State>::VecLength>>::Buffer<f64>: Send,
117109
{
118110
self.resume_run_until_nth_event(prop, almanac, 0, max_duration, event, trigger, num_runs)
119111
}
@@ -135,11 +127,10 @@ where
135127
D: Dynamics<StateType = S>,
136128
E: ErrorCtrl,
137129
F: EventEvaluator<S>,
138-
DefaultAllocator: Allocator<f64, <D::StateType as State>::Size>
139-
+ Allocator<f64, <D::StateType as State>::Size, <D::StateType as State>::Size>
140-
+ Allocator<usize, <D::StateType as State>::Size, <D::StateType as State>::Size>
141-
+ Allocator<f64, <D::StateType as State>::VecLength>,
142-
<DefaultAllocator as Allocator<f64, <D::StateType as State>::VecLength>>::Buffer: Send,
130+
DefaultAllocator: Allocator<<D::StateType as State>::Size>
131+
+ Allocator<<D::StateType as State>::Size, <D::StateType as State>::Size>
132+
+ Allocator<<D::StateType as State>::VecLength>,
133+
<DefaultAllocator as Allocator<<D::StateType as State>::VecLength>>::Buffer<f64>: Send,
143134
{
144135
// Generate the initial states
145136
let init_states = self.generate_states(skip, num_runs, self.seed);
@@ -207,11 +198,10 @@ where
207198
where
208199
D: Dynamics<StateType = S>,
209200
E: ErrorCtrl,
210-
DefaultAllocator: Allocator<f64, <D::StateType as State>::Size>
211-
+ Allocator<f64, <D::StateType as State>::Size, <D::StateType as State>::Size>
212-
+ Allocator<usize, <D::StateType as State>::Size, <D::StateType as State>::Size>
213-
+ Allocator<f64, <D::StateType as State>::VecLength>,
214-
<DefaultAllocator as Allocator<f64, <D::StateType as State>::VecLength>>::Buffer: Send,
201+
DefaultAllocator: Allocator<<D::StateType as State>::Size>
202+
+ Allocator<<D::StateType as State>::Size, <D::StateType as State>::Size>
203+
+ Allocator<<D::StateType as State>::VecLength>,
204+
<DefaultAllocator as Allocator<<D::StateType as State>::VecLength>>::Buffer<f64>: Send,
215205
{
216206
self.resume_run_until_epoch(prop, almanac, 0, end_epoch, num_runs)
217207
}
@@ -230,11 +220,10 @@ where
230220
where
231221
D: Dynamics<StateType = S>,
232222
E: ErrorCtrl,
233-
DefaultAllocator: Allocator<f64, <D::StateType as State>::Size>
234-
+ Allocator<f64, <D::StateType as State>::Size, <D::StateType as State>::Size>
235-
+ Allocator<usize, <D::StateType as State>::Size, <D::StateType as State>::Size>
236-
+ Allocator<f64, <D::StateType as State>::VecLength>,
237-
<DefaultAllocator as Allocator<f64, <D::StateType as State>::VecLength>>::Buffer: Send,
223+
DefaultAllocator: Allocator<<D::StateType as State>::Size>
224+
+ Allocator<<D::StateType as State>::Size, <D::StateType as State>::Size>
225+
+ Allocator<<D::StateType as State>::VecLength>,
226+
<DefaultAllocator as Allocator<<D::StateType as State>::VecLength>>::Buffer<f64>: Send,
238227
{
239228
// Generate the initial states
240229
let init_states = self.generate_states(skip, num_runs, self.seed);
@@ -315,10 +304,7 @@ where
315304
impl<S: Interpolatable, Distr: Distribution<DispersedState<S>>> fmt::Display
316305
for MonteCarlo<S, Distr>
317306
where
318-
DefaultAllocator: Allocator<f64, S::Size>
319-
+ Allocator<f64, S::Size, S::Size>
320-
+ Allocator<f64, S::VecLength>
321-
+ Allocator<usize, S::Size, S::Size>,
307+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
322308
{
323309
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
324310
write!(
@@ -332,10 +318,7 @@ where
332318
impl<S: Interpolatable, Distr: Distribution<DispersedState<S>>> fmt::LowerHex
333319
for MonteCarlo<S, Distr>
334320
where
335-
DefaultAllocator: Allocator<f64, S::Size>
336-
+ Allocator<f64, S::Size, S::Size>
337-
+ Allocator<f64, S::VecLength>
338-
+ Allocator<usize, S::Size, S::Size>,
321+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
339322
{
340323
/// Returns a filename friendly name
341324
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

src/mc/results.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@ use super::DispersedState;
4747
/// A structure storing the result of a single Monte Carlo run
4848
pub struct Run<S: Interpolatable, R>
4949
where
50-
DefaultAllocator: Allocator<f64, S::Size>
51-
+ Allocator<f64, S::Size, S::Size>
52-
+ Allocator<usize, S::Size, S::Size>
53-
+ Allocator<f64, S::VecLength>,
54-
<DefaultAllocator as Allocator<f64, S::VecLength>>::Buffer: Send,
50+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
51+
<DefaultAllocator as Allocator<S::VecLength>>::Buffer<f64>: Send,
5552
{
5653
/// The index of this run
5754
pub index: usize,
@@ -64,11 +61,8 @@ where
6461
/// A structure of Monte Carlo results
6562
pub struct Results<S: Interpolatable, R>
6663
where
67-
DefaultAllocator: Allocator<f64, S::Size>
68-
+ Allocator<f64, S::Size, S::Size>
69-
+ Allocator<usize, S::Size, S::Size>
70-
+ Allocator<f64, S::VecLength>,
71-
<DefaultAllocator as Allocator<f64, S::VecLength>>::Buffer: Send,
64+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
65+
<DefaultAllocator as Allocator<S::VecLength>>::Buffer<f64>: Send,
7266
{
7367
/// Raw data from each run, sorted by run index for O(1) access to each run
7468
pub runs: Vec<Run<S, R>>,
@@ -79,23 +73,17 @@ where
7973
/// A structure that stores the result of a propagation segment of a Monte Carlo.
8074
pub struct PropResult<S: Interpolatable>
8175
where
82-
DefaultAllocator: Allocator<f64, S::Size>
83-
+ Allocator<f64, S::Size, S::Size>
84-
+ Allocator<usize, S::Size, S::Size>
85-
+ Allocator<f64, S::VecLength>,
86-
<DefaultAllocator as Allocator<f64, S::VecLength>>::Buffer: Send,
76+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
77+
<DefaultAllocator as Allocator<S::VecLength>>::Buffer<f64>: Send,
8778
{
8879
pub state: S,
8980
pub traj: Traj<S>,
9081
}
9182

9283
impl<S: Interpolatable> Results<S, PropResult<S>>
9384
where
94-
DefaultAllocator: Allocator<f64, S::Size>
95-
+ Allocator<f64, S::Size, S::Size>
96-
+ Allocator<usize, S::Size, S::Size>
97-
+ Allocator<f64, S::VecLength>,
98-
<DefaultAllocator as Allocator<f64, S::VecLength>>::Buffer: Send,
85+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
86+
<DefaultAllocator as Allocator<S::VecLength>>::Buffer<f64>: Send,
9987
{
10088
/// Returns the value of the requested state parameter for all trajectories from `start` to `end` every `step` and
10189
/// using the value of `value_if_run_failed` if set and skipping that run if the run failed

src/md/events/details.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ pub enum EventEdge {
4949
#[derive(Clone, Debug, PartialEq)]
5050
pub struct EventDetails<S: Interpolatable>
5151
where
52-
DefaultAllocator:
53-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
52+
DefaultAllocator: Allocator<S::VecLength> + Allocator<S::Size> + Allocator<S::Size, S::Size>,
5453
{
5554
/// The state of the trajectory at the found event.
5655
pub state: S,
@@ -70,8 +69,7 @@ where
7069

7170
impl<S: Interpolatable> EventDetails<S>
7271
where
73-
DefaultAllocator:
74-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
72+
DefaultAllocator: Allocator<S::VecLength> + Allocator<S::Size> + Allocator<S::Size, S::Size>,
7573
{
7674
/// Generates detailed information about an event at a specific epoch in a trajectory.
7775
///
@@ -148,8 +146,7 @@ where
148146

149147
impl<S: Interpolatable> fmt::Display for EventDetails<S>
150148
where
151-
DefaultAllocator:
152-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
149+
DefaultAllocator: Allocator<S::VecLength> + Allocator<S::Size> + Allocator<S::Size, S::Size>,
153150
{
154151
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
155152
let prev_fmt = match self.prev_value {
@@ -173,17 +170,15 @@ where
173170
#[derive(Clone, Debug, PartialEq)]
174171
pub struct EventArc<S: Interpolatable>
175172
where
176-
DefaultAllocator:
177-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
173+
DefaultAllocator: Allocator<S::VecLength> + Allocator<S::Size> + Allocator<S::Size, S::Size>,
178174
{
179175
pub rise: EventDetails<S>,
180176
pub fall: EventDetails<S>,
181177
}
182178

183179
impl<S: Interpolatable> fmt::Display for EventArc<S>
184180
where
185-
DefaultAllocator:
186-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
181+
DefaultAllocator: Allocator<S::VecLength> + Allocator<S::Size> + Allocator<S::Size, S::Size>,
187182
{
188183
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
189184
write!(

src/md/events/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ use std::sync::Arc;
3535
/// A trait to specify how a specific event must be evaluated.
3636
pub trait EventEvaluator<S: State>: fmt::Display + Send + Sync
3737
where
38-
DefaultAllocator:
39-
Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size> + Allocator<f64, S::VecLength>,
38+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
4039
{
4140
// Evaluation of event crossing, must return whether the condition happened between between both states.
4241
fn eval_crossing(

src/md/events/search.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ use std::sync::Arc;
3232

3333
impl<S: Interpolatable> Traj<S>
3434
where
35-
DefaultAllocator:
36-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
35+
DefaultAllocator: Allocator<S::VecLength> + Allocator<S::Size> + Allocator<S::Size, S::Size>,
3736
{
3837
/// Find the exact state where the request event happens. The event function is expected to be monotone in the provided interval because we find the event using a Brent solver.
3938
#[allow(clippy::identity_op)]

src/md/trajectory/interpolatable.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ use enum_iterator::all;
3333
pub trait Interpolatable: State
3434
where
3535
Self: Sized,
36-
DefaultAllocator: Allocator<f64, Self::Size>
37-
+ Allocator<f64, Self::Size, Self::Size>
38-
+ Allocator<f64, Self::VecLength>,
36+
DefaultAllocator:
37+
Allocator<Self::Size> + Allocator<Self::Size, Self::Size> + Allocator<Self::VecLength>,
3938
{
4039
/// Interpolates a new state at the provided epochs given a slice of states.
4140
fn interpolate(self, epoch: Epoch, states: &[Self]) -> Result<Self, InterpolationError>;

0 commit comments

Comments
 (0)