Skip to content

Commit 0e36916

Browse files
committed
C-WORD-ORDER
1 parent 3151756 commit 0e36916

File tree

19 files changed

+226
-216
lines changed

19 files changed

+226
-216
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ First release
1111
- correct doctest Su3Adjoint::as_mut_vector
1212
- migrate to rust 2021
1313
- use readme in librairies root documentation
14-
- rename lots of gettet to match C-GETTER convention
14+
- rename lots of gettet to match C-GETTER convention
15+
- rename some structure for C-WORD-ORDER

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ implement the trait [`LatticeState`](https://abouttefeux.github.io/lattice-qcd-r
8383

8484
If you want to use your own state with the [hybride Monte Carlo](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/simulation/monte_carlo/hybride_monte_carlo/struct.HybridMonteCarloDiagnostic.html)
8585
you will have to implement
86-
[`LatticeStateWithEField`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/simulation/state/trait.LatticeStateWithEField.html) for [`LatticeStateWithEFieldSyncDefault<YourState>`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/simulation/state/struct.LatticeStateWithEFieldSyncDefault.html)
86+
[`LatticeStateWithEField`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/simulation/state/trait.LatticeStateWithEField.html) for [`LatticeStateEFSyncDefault<YourState>`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/simulation/state/struct.LatticeStateEFSyncDefault.html)
8787

8888
#### I want to use my own Monte Carlo algorithm.
8989

benches/bench.rs

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,24 @@ fn bench_simulation_creation_deterministe(
1313
rng: &mut rand::rngs::ThreadRng,
1414
d: &impl rand_distr::Distribution<Real>,
1515
) {
16-
let _simulation =
17-
LatticeStateWithEFieldSyncDefault::<LatticeStateDefault<4>, 4>::new_deterministe(
18-
1_f64, 1_f64, size, rng, d,
19-
)
20-
.unwrap();
16+
let _simulation = LatticeStateEFSyncDefault::<LatticeStateDefault<4>, 4>::new_deterministe(
17+
1_f64, 1_f64, size, rng, d,
18+
)
19+
.unwrap();
2120
}
2221

2322
fn bench_simulation_creation_threaded<D>(size: usize, d: &D, number_of_thread: usize)
2423
where
2524
D: rand_distr::Distribution<Real> + Sync,
2625
{
27-
let _simulation =
28-
LatticeStateWithEFieldSyncDefault::<LatticeStateDefault<4>, 4>::new_random_threaded(
29-
1_f64,
30-
1_f64,
31-
size,
32-
d,
33-
number_of_thread,
34-
)
35-
.unwrap();
26+
let _simulation = LatticeStateEFSyncDefault::<LatticeStateDefault<4>, 4>::new_random_threaded(
27+
1_f64,
28+
1_f64,
29+
size,
30+
d,
31+
number_of_thread,
32+
)
33+
.unwrap();
3634
}
3735

3836
fn matrix_exp_old(rng: &mut rand::rngs::ThreadRng, d: &impl rand_distr::Distribution<Real>) {
@@ -87,17 +85,15 @@ fn create_hash_map(
8785
}
8886

8987
fn simulate_euler(
90-
simulation: &mut LatticeStateWithEFieldSyncDefault<LatticeStateDefault<4>, 4>,
88+
simulation: &mut LatticeStateEFSyncDefault<LatticeStateDefault<4>, 4>,
9189
number_of_thread: usize,
9290
) {
9391
*simulation = simulation
9492
.simulate_sync(&SymplecticEuler::new(number_of_thread), 0.00001)
9593
.unwrap();
9694
}
9795

98-
fn simulate_euler_rayon(
99-
simulation: &mut LatticeStateWithEFieldSyncDefault<LatticeStateDefault<4>, 4>,
100-
) {
96+
fn simulate_euler_rayon(simulation: &mut LatticeStateEFSyncDefault<LatticeStateDefault<4>, 4>) {
10197
*simulation = simulation
10298
.simulate_sync(&SymplecticEulerRayon::new(), 0.00001)
10399
.unwrap();
@@ -149,21 +145,19 @@ fn criterion_benchmark(c: &mut Criterion) {
149145
groupe_sim.sample_size(10);
150146
let thread_count: [usize; 5] = [1, 2, 4, 6, 8];
151147
for n in thread_count.iter() {
152-
let mut sim =
153-
LatticeStateWithEFieldSyncDefault::<LatticeStateDefault<4>, 4>::new_random_threaded(
154-
1_f64, 1_f64, 5, &d, 4,
155-
)
156-
.unwrap();
148+
let mut sim = LatticeStateEFSyncDefault::<LatticeStateDefault<4>, 4>::new_random_threaded(
149+
1_f64, 1_f64, 5, &d, 4,
150+
)
151+
.unwrap();
157152
groupe_sim.bench_with_input(BenchmarkId::new("thread", n), n, |b, i| {
158153
b.iter(|| simulate_euler(&mut sim, *i))
159154
});
160155
}
161156

162-
let mut sim =
163-
LatticeStateWithEFieldSyncDefault::<LatticeStateDefault<4>, 4>::new_random_threaded(
164-
1_f64, 1_f64, 5, &d, 4,
165-
)
166-
.unwrap();
157+
let mut sim = LatticeStateEFSyncDefault::<LatticeStateDefault<4>, 4>::new_random_threaded(
158+
1_f64, 1_f64, 5, &d, 4,
159+
)
160+
.unwrap();
167161
groupe_sim.bench_function("simulate(20) rayon", |b| {
168162
b.iter(|| simulate_euler_rayon(&mut sim))
169163
});

procedural_macro/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use quote::quote;
4242
const MAX_DIM: usize = 127;
4343

4444
/// Implement [`DirectionList`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/lattice/trait.DirectionList.html)
45-
/// for [`Direction`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/lattice/struct.Direction.html) of `1` to `127` the value of [`MAX_DIM`].
45+
/// for [`Direction`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/lattice/struct.Direction.html) of `1` to `127` the value of `MAX_DIM`.
4646
///
4747
/// Using const generics might render this unecessary. Waiting for stabilisation of feature(generic_const_exprs).
4848
#[proc_macro]

src/error.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ pub enum ImplementationError {
3232
Unreachable,
3333
/// An option contained an unexpected None value.
3434
///
35-
/// Used when needing to retrun a dyn Error but [`std::option::NoneError`] does not implement [`Error`]
35+
/// Used when needing to retrun a dyn Error but `std::option::NoneError` does not implement [`Error`]
36+
// TODO NoneError
3637
OptionWithUnexpectedNone,
3738
}
3839

@@ -130,7 +131,7 @@ impl Error for StateInitializationError {
130131
}
131132
}
132133

133-
/// Error while initialising a state
134+
/// Error while initialising a state using multiple thread or threded function.
134135
#[non_exhaustive]
135136
#[derive(Debug, Clone, Eq, PartialEq)]
136137
pub enum ThreadedStateInitializationError {

src/field.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ impl Su3Adjoint {
9999
/// let su3 = Su3Adjoint::new_from_array([1_f64, 0_f64, 0_f64, 0_f64, 0_f64, 0_f64, 0_f64, 0_f64]);
100100
/// assert_eq!(su3.to_matrix(), *lattice_qcd_rs::su3::GENERATORS[0]);
101101
/// ```
102+
// TODO self non consomé ?? passé en &self ? TODO bench
102103
pub fn to_matrix(self) -> Matrix3<na::Complex<Real>> {
103104
self.data
104105
.iter()
@@ -167,7 +168,6 @@ impl Su3Adjoint {
167168
/// It is used for [`su3::su3_exp_i`].
168169
/// # Example
169170
/// ```
170-
/// # extern crate nalgebra;
171171
/// # use lattice_qcd_rs::field::Su3Adjoint;
172172
/// let su3 = Su3Adjoint::from([1_f64; 8]);
173173
/// let m = su3.to_matrix();
@@ -185,7 +185,6 @@ impl Su3Adjoint {
185185
/// Used for [`su3::su3_exp_i`]
186186
/// # Example
187187
/// ```
188-
/// # extern crate nalgebra;
189188
/// # use lattice_qcd_rs::field::Su3Adjoint;
190189
/// let su3 = Su3Adjoint::from([1_f64; 8]);
191190
/// let m = su3.to_matrix();
@@ -557,14 +556,15 @@ impl From<[Real; 8]> for Su3Adjoint {
557556
}
558557

559558
/// Represents the link matrices
559+
// TODO more doc
560560
#[derive(Debug, PartialEq, Clone)]
561561
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
562562
pub struct LinkMatrix {
563563
data: Vec<Matrix3<na::Complex<Real>>>,
564564
}
565565

566566
impl LinkMatrix {
567-
/// Creat a new link matrix field
567+
/// Creat a new link matrix field from preexisting data.
568568
pub const fn new(data: Vec<Matrix3<na::Complex<Real>>>) -> Self {
569569
Self { data }
570570
}
@@ -579,17 +579,17 @@ impl LinkMatrix {
579579
&mut self.data
580580
}
581581

582-
/// Get the link_matrix as a Vec
582+
/// Get the link_matrix as a [`Vec`].
583583
pub const fn as_vec(&self) -> &Vec<Matrix3<na::Complex<Real>>> {
584584
self.data()
585585
}
586586

587-
/// Get the link_matrix as a Vec
587+
/// Get the link_matrix as a mutable [`Vec`].
588588
pub fn as_vec_mut(&mut self) -> &mut Vec<Matrix3<na::Complex<Real>>> {
589589
self.data_mut()
590590
}
591591

592-
/// Get the link_matrix as a Vec
592+
/// Get the link_matrix as a slice.
593593
pub fn as_slice(&self) -> &[Matrix3<na::Complex<Real>>] {
594594
self.data()
595595
}
@@ -600,7 +600,8 @@ impl LinkMatrix {
600600
}
601601

602602
/// Single threaded generation with a given random number generator.
603-
/// useful to reproduce a set of data but slower than [`LinkMatrix::new_random_threaded`].
603+
/// useful to produce a deterministic set of data but slower than
604+
/// [`LinkMatrix::new_random_threaded`].
604605
/// # Example
605606
/// ```
606607
/// use lattice_qcd_rs::{field::LinkMatrix, lattice::LatticeCyclique};
@@ -635,7 +636,8 @@ impl LinkMatrix {
635636
}
636637

637638
/// Multi threaded generation of random data. Due to the non deterministic way threads
638-
/// operate a set cannot be reduced easily, In that case use [`LinkMatrix::new_random_threaded`].
639+
/// operate a set cannot be reduced easily. If you want deterministic
640+
/// generation you can use [`LinkMatrix::new_random_threaded`].
639641
///
640642
/// # Example
641643
/// ```
@@ -1199,8 +1201,8 @@ impl<const D: usize> EField<D> {
11991201
/// use lattice_qcd_rs::error::ImplementationError;
12001202
/// use lattice_qcd_rs::integrator::SymplecticEulerRayon;
12011203
/// use lattice_qcd_rs::simulation::{
1202-
/// LatticeState, LatticeStateDefault, LatticeStateWithEField,
1203-
/// LatticeStateWithEFieldSyncDefault, SimulationStateSynchrone,
1204+
/// LatticeState, LatticeStateDefault, LatticeStateEFSyncDefault, LatticeStateWithEField,
1205+
/// SimulationStateSynchrone,
12041206
/// };
12051207
/// use rand::SeedableRng;
12061208
///
@@ -1210,7 +1212,7 @@ impl<const D: usize> EField<D> {
12101212
/// let mut rng = rand::rngs::StdRng::seed_from_u64(0); // change with your seed
12111213
/// let distribution =
12121214
/// rand::distributions::Uniform::from(-std::f64::consts::PI..std::f64::consts::PI);
1213-
/// let mut state = LatticeStateWithEFieldSyncDefault::new_random_e_state(
1215+
/// let mut state = LatticeStateEFSyncDefault::new_random_e_state(
12141216
/// LatticeStateDefault::<3>::new_deterministe(1_f64, 6_f64, 4, &mut rng).unwrap(),
12151217
/// &mut rng,
12161218
/// ); // <- here internally when choosing radomly the EField it is projected.

src/integrator/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
//! # fn main() -> Result<(), Box<dyn Error>> {
1818
//! use lattice_qcd_rs::integrator::{SymplecticEuler, SymplecticIntegrator};
1919
//! use lattice_qcd_rs::simulation::{
20-
//! LatticeStateDefault, LatticeStateWithEField, LatticeStateWithEFieldSyncDefault,
20+
//! LatticeStateDefault, LatticeStateEFSyncDefault, LatticeStateWithEField,
2121
//! };
2222
//! use rand::SeedableRng;
2323
//!
2424
//! let mut rng = rand::rngs::StdRng::seed_from_u64(0); // change with your seed
25-
//! let state1 = LatticeStateWithEFieldSyncDefault::new_random_e_state(
25+
//! let state1 = LatticeStateEFSyncDefault::new_random_e_state(
2626
//! LatticeStateDefault::<3>::new_deterministe(100_f64, 1_f64, 4, &mut rng)?,
2727
//! &mut rng,
2828
//! );
@@ -39,12 +39,12 @@
3939
//! # fn main() -> Result<(), Box<dyn Error>> {
4040
//! # use lattice_qcd_rs::integrator::{SymplecticEuler, SymplecticIntegrator};
4141
//! # use lattice_qcd_rs::simulation::{
42-
//! # LatticeStateDefault, LatticeStateWithEField, LatticeStateWithEFieldSyncDefault,
42+
//! # LatticeStateDefault, LatticeStateWithEField, LatticeStateEFSyncDefault,
4343
//! # };
4444
//! # use rand::SeedableRng;
4545
//! #
4646
//! # let mut rng = rand::rngs::StdRng::seed_from_u64(0); // change with your seed
47-
//! # let state1 = LatticeStateWithEFieldSyncDefault::new_random_e_state(
47+
//! # let state1 = LatticeStateEFSyncDefault::new_random_e_state(
4848
//! # LatticeStateDefault::<3>::new_deterministe(100_f64, 1_f64, 4, &mut rng)?,
4949
//! # &mut rng,
5050
//! # );
@@ -121,12 +121,12 @@ where
121121
/// # fn main() -> Result<(), Box<dyn Error>> {
122122
/// use lattice_qcd_rs::integrator::{SymplecticEulerRayon, SymplecticIntegrator};
123123
/// use lattice_qcd_rs::simulation::{
124-
/// LatticeStateDefault, LatticeStateWithEField, LatticeStateWithEFieldSyncDefault,
124+
/// LatticeStateDefault, LatticeStateEFSyncDefault, LatticeStateWithEField,
125125
/// };
126126
/// use rand::SeedableRng;
127127
///
128128
/// let mut rng = rand::rngs::StdRng::seed_from_u64(0); // change with your seed
129-
/// let state = LatticeStateWithEFieldSyncDefault::new_random_e_state(
129+
/// let state = LatticeStateEFSyncDefault::new_random_e_state(
130130
/// LatticeStateDefault::<3>::new_deterministe(1_f64, 2_f64, 4, &mut rng)?,
131131
/// &mut rng,
132132
/// );
@@ -181,12 +181,12 @@ where
181181
/// # fn main() -> Result<(), Box<dyn Error>> {
182182
/// use lattice_qcd_rs::integrator::{SymplecticEulerRayon, SymplecticIntegrator};
183183
/// use lattice_qcd_rs::simulation::{
184-
/// LatticeStateDefault, LatticeStateWithEField, LatticeStateWithEFieldSyncDefault,
184+
/// LatticeStateDefault, LatticeStateEFSyncDefault, LatticeStateWithEField,
185185
/// };
186186
/// use rand::SeedableRng;
187187
///
188188
/// let mut rng = rand::rngs::StdRng::seed_from_u64(0); // change with your seed
189-
/// let mut state = LatticeStateWithEFieldSyncDefault::new_random_e_state(
189+
/// let mut state = LatticeStateEFSyncDefault::new_random_e_state(
190190
/// LatticeStateDefault::<3>::new_deterministe(1_f64, 2_f64, 4, &mut rng)?,
191191
/// &mut rng,
192192
/// );

src/integrator/symplectic_euler_rayon.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ use super::{
3030
/// # fn main() -> Result<(), Box<dyn Error>> {
3131
/// use lattice_qcd_rs::integrator::{SymplecticEulerRayon, SymplecticIntegrator};
3232
/// use lattice_qcd_rs::simulation::{
33-
/// LatticeStateDefault, LatticeStateWithEField, LatticeStateWithEFieldSyncDefault,
33+
/// LatticeStateDefault, LatticeStateEFSyncDefault, LatticeStateWithEField,
3434
/// };
3535
/// use rand::SeedableRng;
3636
///
3737
/// let mut rng = rand::rngs::StdRng::seed_from_u64(0); // change with your seed
38-
/// let state1 = LatticeStateWithEFieldSyncDefault::new_random_e_state(
38+
/// let state1 = LatticeStateEFSyncDefault::new_random_e_state(
3939
/// LatticeStateDefault::<3>::new_deterministe(1_f64, 2_f64, 4, &mut rng)?,
4040
/// &mut rng,
4141
/// );

src/lattice.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ impl<const D: usize> LatticeCyclique<D> {
118118

119119
/// Transform a [`LatticeLink`] into a [`LatticeLinkCanonical`].
120120
///
121-
/// See [`LatticeCyclique::get_link_canonical`] and [`LatticeLinkCanonical`].
121+
/// See [`LatticeCyclique::link_canonical`] and [`LatticeLinkCanonical`].
122122
pub fn into_canonical(&self, l: LatticeLink<D>) -> LatticeLinkCanonical<D> {
123123
self.link_canonical(*l.pos(), *l.dir())
124124
}
125125

126126
/// Get the number of points in a single direction.
127127
///
128-
/// use [`LatticeCyclique::get_number_of_points`] for the total number of points.
128+
/// use [`LatticeCyclique::number_of_points`] for the total number of points.
129129
/// Not to confuse with [`LatticeCyclique::dim_st`] which is the dimension of space-time.
130130
pub const fn dim(&self) -> usize {
131131
self.dim
@@ -803,7 +803,7 @@ pub struct LatticeLinkCanonical<const D: usize> {
803803
impl<const D: usize> LatticeLinkCanonical<D> {
804804
/// Try create a LatticeLinkCanonical. If the dir is negative it fails.
805805
///
806-
/// To guaranty creating an element see [LatticeCyclique::get_link_canonical].
806+
/// To guaranty creating an element see [LatticeCyclique::link_canonical].
807807
/// The creation of an element this ways does not guaranties that the element is inside a lattice.
808808
/// # Example
809809
/// ```
@@ -980,7 +980,7 @@ impl<const D: usize> Direction<D> {
980980
}
981981

982982
/// List all directions.
983-
/// This is very slow use [`DirectionList::get_all_directions`] instead
983+
/// This is very slow use [`DirectionList::directions`] instead
984984
pub fn directions_vec() -> Vec<Self> {
985985
let mut x = Vec::with_capacity(2 * D);
986986
for i in 0..D {

src/prelude.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ pub use super::{
1010
HybridMonteCarloDiagnostic, McWrapper, MetropolisHastingsDeltaDiagnostic,
1111
MetropolisHastingsSweep, MonteCarlo, MonteCarloDefault,
1212
},
13-
LatticeState, LatticeStateDefault, LatticeStateNew, LatticeStateWithEField,
14-
LatticeStateWithEFieldNew, LatticeStateWithEFieldSyncDefault, SimulationStateLeap,
13+
LatticeState, LatticeStateDefault, LatticeStateEFSyncDefault, LatticeStateNew,
14+
LatticeStateWithEField, LatticeStateWithEFieldNew, SimulationStateLeap,
1515
SimulationStateLeapFrog, SimulationStateSynchrone,
1616
},
1717
CMatrix3, Complex, ComplexField, Real,

0 commit comments

Comments
 (0)