@@ -39,7 +39,7 @@ use std::slice;
3939use std:: sync:: Mutex ;
4040
4141//itertools
42- use itertools:: izip;
42+ use itertools:: { izip} ;
4343
4444//Math
4545use std:: f64:: consts:: FRAC_2_SQRT_PI ;
@@ -1682,22 +1682,15 @@ pub fn rotate_back_py(nx: f64, ny: f64, nz: f64, ux: f64, uy: f64, uz: f64) -> (
16821682/// direction (list(f64), list(f64), list(f64)): direction vector of particle in simulation coordinates.
16831683pub fn rotate_back_vec_py ( nx : Vec < f64 > , ny : Vec < f64 > , nz : Vec < f64 > , ux : Vec < f64 > , uy : Vec < f64 > , uz : Vec < f64 > ) -> ( Vec < f64 > , Vec < f64 > , Vec < f64 > ) {
16841684
1685- let length = nx . len ( ) ;
1685+ let ( ux_new , ( uy_new , uz_new ) ) = ( nx , ny , nz , ux , uy , uz ) . into_par_iter ( ) . map ( | ( nx_ , ny_ , nz_ , ux_ , uy_ , uz_ ) | {
16861686
1687- let mut ux_new = Vec :: with_capacity ( length) ;
1688- let mut uy_new = Vec :: with_capacity ( length) ;
1689- let mut uz_new = Vec :: with_capacity ( length) ;
1687+ let mut ux_mut = ux_;
1688+ let mut uy_mut = uy_;
1689+ let mut uz_mut = uz_;
1690+ rotate_back ( nx_, ny_, nz_, & mut ux_mut, & mut uy_mut, & mut uz_mut) ;
16901691
1691- ( 0 ..length) . into_iter ( ) . for_each ( |index| {
1692-
1693- let mut ux_ = ux[ index] ;
1694- let mut uy_ = uy[ index] ;
1695- let mut uz_ = uz[ index] ;
1696- rotate_back ( nx[ index] , ny[ index] , nz[ index] , & mut ux_, & mut uy_, & mut uz_) ;
1697- ux_new. push ( ux_) ;
1698- uy_new. push ( uy_) ;
1699- uz_new. push ( uz_) ;
1700- } ) ;
1692+ ( ux_mut, ( uy_mut, uz_mut) )
1693+ } ) . unzip ( ) ;
17011694
17021695 ( ux_new, uy_new, uz_new)
17031696}
0 commit comments