Skip to content

Commit 7ab44c7

Browse files
committedAug 7, 2020
Cargo fmt
1 parent ee75a8a commit 7ab44c7

File tree

10 files changed

+196
-276
lines changed

10 files changed

+196
-276
lines changed
 

‎src/fuga/mod.rs

+7-32
Original file line numberDiff line numberDiff line change
@@ -110,53 +110,28 @@ pub use crate::macros::{julia_macro::*, matlab_macro::*, r_macro::*};
110110
pub use crate::traits::{
111111
fp::{FPMatrix, FPVector},
112112
general::Algorithm,
113-
math::{InnerProduct, LinearOp, Norm, Normed, Vector, VectorProduct, MatrixProduct},
113+
math::{InnerProduct, LinearOp, MatrixProduct, Norm, Normed, Vector, VectorProduct},
114114
mutable::{MutFP, MutMatrix},
115115
num::{ExpLogOps, Number, NumberVector, PowOps, Real, TrigOps},
116116
pointer::{MatrixPtr, Oxide, Redox},
117-
sugar::{Scalable, ScalableMut, VecOps},
118117
stable::StableFn,
118+
sugar::{Scalable, ScalableMut, VecOps},
119119
};
120120

121121
#[allow(unused_imports)]
122-
pub use crate::structure::{
123-
dual::*,
124-
hyper_dual::*,
125-
matrix::*,
126-
polynomial::*,
127-
vector::*
128-
};
122+
pub use crate::structure::{dual::*, hyper_dual::*, matrix::*, polynomial::*, vector::*};
129123

130-
pub use crate::util::{
131-
api::*,
132-
low_level::*,
133-
non_macro::*,
134-
print::*,
135-
useful::*,
136-
wrapper::*
137-
};
124+
pub use crate::util::{api::*, low_level::*, non_macro::*, print::*, useful::*, wrapper::*};
138125

139126
#[allow(unused_imports)]
140-
pub use crate::statistics::{
141-
dist::*,
142-
ops::*,
143-
rand::*,
144-
stat::*
145-
};
127+
pub use crate::statistics::{dist::*, ops::*, rand::*, stat::*};
146128

147129
#[allow(unused_imports)]
148130
pub use crate::special::function::*;
149131

150132
#[allow(unused_imports)]
151133
pub use crate::numerical::{
152-
eigen::*,
153-
integral::*,
154-
interp::*,
155-
ode::*,
156-
optimize::*,
157-
spline::*,
158-
utils::*,
159-
root::*,
134+
eigen::*, integral::*, interp::*, ode::*, optimize::*, root::*, spline::*, utils::*,
160135
};
161136

162137
#[allow(unused_imports)]
@@ -177,6 +152,7 @@ pub use crate::structure::ad::*;
177152
// Enums
178153
// =============================================================================
179154
pub use crate::numerical::integral::Integral::{GaussLegendre, NewtonCotes};
155+
pub use crate::numerical::root::RootFind::{Bisection, FalsePosition, Newton, Secant};
180156
pub use crate::statistics::stat::QType::{
181157
Type1, Type2, Type3, Type4, Type5, Type6, Type7, Type8, Type9,
182158
};
@@ -185,4 +161,3 @@ pub use crate::structure::matrix::{
185161
SolveKind::{LU, WAZ},
186162
};
187163
pub use crate::traits::num::Number::{D, F};
188-
pub use crate::numerical::root::RootFind::{Bisection, FalsePosition, Newton, Secant};

‎src/numerical/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ pub mod interp;
88
pub mod newton;
99
pub mod ode;
1010
pub mod optimize;
11+
pub mod root;
1112
pub mod spline;
1213
pub mod utils;
13-
pub mod root;

‎src/numerical/root.rs

+153-179
Large diffs are not rendered by default.

‎src/prelude/mod.rs

+6-34
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub mod simpler;
108108
pub use crate::traits::{
109109
fp::{FPMatrix, FPVector},
110110
general::Algorithm,
111-
math::{InnerProduct, LinearOp, Vector},
111+
math::{InnerProduct, LinearOp, MatrixProduct, Vector, VectorProduct},
112112
mutable::{MutFP, MutMatrix},
113113
num::{ExpLogOps, Number, NumberVector, PowOps, Real, TrigOps},
114114
pointer::{MatrixPtr, Oxide, Redox},
@@ -122,24 +122,8 @@ pub use crate::structure::{
122122
dual::*,
123123
hyper_dual::*,
124124
matrix::{
125-
combine,
126-
diag,
127-
gemm,
128-
gemv,
129-
gen_householder,
130-
inv_l,
131-
inv_u,
132-
matrix,
133-
ml_matrix,
134-
py_matrix,
135-
r_matrix,
136-
Col,
137-
Matrix,
138-
Row,
139-
Shape,
140-
PQLU,
141-
QR,
142-
WAZD,
125+
combine, diag, gemm, gemv, gen_householder, inv_l, inv_u, matrix, ml_matrix, py_matrix,
126+
r_matrix, Col, Matrix, Row, Shape, PQLU, QR, WAZD,
143127
},
144128
polynomial::*,
145129
vector::*,
@@ -148,22 +132,10 @@ pub use crate::structure::{
148132
pub use simpler::{solve, SimplerLinearAlgebra};
149133

150134
#[allow(unused_imports)]
151-
pub use crate::util::{
152-
api::*,
153-
low_level::*,
154-
non_macro::*,
155-
print::*,
156-
useful::*,
157-
wrapper::*,
158-
};
135+
pub use crate::util::{api::*, low_level::*, non_macro::*, print::*, useful::*, wrapper::*};
159136

160137
#[allow(unused_imports)]
161-
pub use crate::statistics::{
162-
dist::*,
163-
ops::*,
164-
rand::*,
165-
stat::*,
166-
};
138+
pub use crate::statistics::{dist::*, ops::*, rand::*, stat::*};
167139

168140
#[allow(unused_imports)]
169141
pub use crate::special::function::*;
@@ -174,9 +146,9 @@ pub use crate::numerical::{
174146
interp::*,
175147
ode::*,
176148
optimize::*,
149+
root::{bisection, false_position, newton, secant},
177150
spline::*,
178151
utils::*,
179-
root::{bisection, secant, newton, false_position},
180152
};
181153

182154
pub use simpler::{eigen, integrate};

‎src/statistics/dist.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ pub use self::OPDist::*;
135135
pub use self::TPDist::*;
136136
use crate::special::function::*;
137137
//use statistics::rand::ziggurat;
138-
use crate::statistics::{
139-
stat::Statistics,
140-
ops::C,
141-
};
138+
use crate::statistics::{ops::C, stat::Statistics};
142139
use std::convert::Into;
143140
use std::f64::consts::E;
144141

@@ -316,7 +313,11 @@ impl<T: PartialOrd + SampleUniform + Copy + Into<f64>> RNG for TPDist<T> {
316313
Binomial(num, mu) => {
317314
let mut rng = thread_rng();
318315
let binom = rand_distr::Binomial::new(*num as u64, (*mu).into()).unwrap();
319-
binom.sample_iter(&mut rng).take(n).map(|t| t as f64).collect()
316+
binom
317+
.sample_iter(&mut rng)
318+
.take(n)
319+
.map(|t| t as f64)
320+
.collect()
320321
}
321322

322323
Normal(m, s) => {
@@ -414,7 +415,7 @@ impl<T: PartialOrd + SampleUniform + Copy + Into<f64>> RNG for TPDist<T> {
414415
let n = *n;
415416
let mu = (*mu).into();
416417
let m = x.into() as usize;
417-
(C(n, m) as f64) * mu.powi(m as i32) * (1f64 - mu).powi((n - m) as i32)
418+
(C(n, m) as f64) * mu.powi(m as i32) * (1f64 - mu).powi((n - m) as i32)
418419
}
419420
Normal(m, s) => {
420421
let mean = (*m).into();

‎src/structure/ad.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,16 @@ use crate::traits::{
122122
stable::StableFn,
123123
};
124124
use peroxide_ad::{
125-
ad_display, ad_impl, ad_impl_ad, ad_impl_add, ad_impl_div, ad_impl_double_ended_iter,
126-
ad_impl_exact_size_iter, ad_impl_explogops, ad_impl_from, ad_impl_from_iter, ad_impl_index,
127-
ad_impl_into_iter, ad_impl_iter, ad_impl_mul, ad_impl_neg, ad_impl_powops, ad_impl_sub,
128-
ad_impl_trigops, ad_iter_def, ad_struct_def, ad_impl_from_type, ad_impl_add_f64, ad_impl_sub_f64,
129-
ad_impl_mul_f64, ad_impl_div_f64, f64_impl_add_ad, f64_impl_sub_ad, f64_impl_mul_ad, f64_impl_div_ad,
130-
f64_impl_from_ad, ad_impl_stable_fn, def_ad
125+
ad_display, ad_impl, ad_impl_ad, ad_impl_add, ad_impl_add_f64, ad_impl_div, ad_impl_div_f64,
126+
ad_impl_double_ended_iter, ad_impl_exact_size_iter, ad_impl_explogops, ad_impl_from,
127+
ad_impl_from_iter, ad_impl_from_type, ad_impl_index, ad_impl_into_iter, ad_impl_iter,
128+
ad_impl_mul, ad_impl_mul_f64, ad_impl_neg, ad_impl_powops, ad_impl_stable_fn, ad_impl_sub,
129+
ad_impl_sub_f64, ad_impl_trigops, ad_iter_def, ad_struct_def, def_ad, f64_impl_add_ad,
130+
f64_impl_div_ad, f64_impl_from_ad, f64_impl_mul_ad, f64_impl_sub_ad,
131131
};
132132
use std::iter::FromIterator;
133-
use std::ops::{Add, Div, Index, IndexMut, Mul, Neg, Sub};
134133
use std::marker::PhantomData;
134+
use std::ops::{Add, Div, Index, IndexMut, Mul, Neg, Sub};
135135

136136
ad_struct_def!();
137137
ad_display!();
@@ -301,7 +301,7 @@ impl<F: Fn(T) -> T, T> ADLift<F, T> {
301301
pub fn new(f: F) -> Self {
302302
Self {
303303
f: Box::new(f),
304-
_marker: PhantomData
304+
_marker: PhantomData,
305305
}
306306
}
307307

@@ -329,6 +329,5 @@ impl<F: Fn(T) -> T, T: AD> StableFn<AD1> for ADLift<F, T> {
329329
//
330330
//impl<F: FnOnce<(T)>, T> FnOnce<f64> for ADLift<F> {
331331
// type Output = f64;
332-
//
332+
//
333333
//}
334-

‎src/structure/matrix.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,12 @@ use crate::numerical::eigen::{eigen, EigenMethod};
458458
use crate::traits::{
459459
fp::{FPMatrix, FPVector},
460460
general::Algorithm,
461-
math::{InnerProduct, LinearOp, Norm, Normed, Vector, MatrixProduct},
461+
math::{InnerProduct, LinearOp, MatrixProduct, Norm, Normed, Vector},
462462
mutable::MutMatrix,
463463
};
464464
use crate::util::{
465465
low_level::{copy_vec_ptr, swap_vec_ptr},
466-
non_macro::{eye, zeros, cbind, rbind},
466+
non_macro::{cbind, eye, rbind, zeros},
467467
useful::{nearly_eq, tab},
468468
};
469469
use std::cmp::{max, min};
@@ -1402,18 +1402,17 @@ impl MatrixProduct for Matrix {
14021402
fn kronecker(&self, other: &Self) -> Self {
14031403
let r1 = self.row;
14041404
let c1 = self.col;
1405-
1405+
14061406
let mut result = self[(0, 0)] * other;
14071407

1408-
for j in 1 .. c1 {
1408+
for j in 1..c1 {
14091409
let n = self[(0, j)] * other;
14101410
result = cbind(result, n);
14111411
}
1412-
14131412

1414-
for i in 1 .. r1 {
1413+
for i in 1..r1 {
14151414
let mut m = self[(i, 0)] * other;
1416-
for j in 1 .. c1 {
1415+
for j in 1..c1 {
14171416
let n = self[(i, j)] * other;
14181417
m = cbind(m, n);
14191418
}
@@ -1429,9 +1428,9 @@ impl MatrixProduct for Matrix {
14291428
let r = self.row;
14301429
let c = self.col;
14311430

1432-
let mut m = matrix(vec![0f64; r*c], r, c, self.shape);
1433-
for i in 0 .. r {
1434-
for j in 0 .. c {
1431+
let mut m = matrix(vec![0f64; r * c], r, c, self.shape);
1432+
for i in 0..r {
1433+
for j in 0..c {
14351434
m[(i, j)] = self[(i, j)] * other[(i, j)]
14361435
}
14371436
}

‎src/traits/math.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::convert::Into;
21
use crate::structure::matrix::Matrix;
2+
use std::convert::Into;
33

44
/// Mathematical Vector
55
///

‎src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ pub mod math;
44
pub mod mutable;
55
pub mod num;
66
pub mod pointer;
7-
pub mod sugar;
87
pub mod stable;
8+
pub mod sugar;

‎tests/matrix.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ fn test_col_map() {
9898

9999
#[test]
100100
fn test_outer() {
101-
let a = c!(1,2,3);
102-
let b = c!(4,5,6);
101+
let a = c!(1, 2, 3);
102+
let b = c!(4, 5, 6);
103103
let c = a.outer(&b);
104104
assert_eq!(c, ml_matrix("4 5 6;8 10 12;12 15 18"));
105105
}

0 commit comments

Comments
 (0)
Please sign in to comment.