1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

nbody.v fixes

This commit is contained in:
vertical222 2019-07-07 07:18:04 +08:00 committed by Alexander Medvednikov
parent 818f8252f6
commit 8c3e47c9de

View File

@ -3,10 +3,6 @@
// -0.169075164 // -0.169075164
// -0.169059907 // -0.169059907
// Elapsed time: 4.91s
// Maximum resident (kbytes): 788
// Between Rust and Go
import math import math
const ( const (
@ -103,23 +99,23 @@ fn energy(sys System) f64 {
} }
fn arr_momentum() []Momentum { fn arr_momentum() []Momentum {
mut x := []Momentum return [
x << Momentum {0.0, 0.0, 0.0, SolarMass} Momentum {0.0, 0.0, 0.0, SolarMass},
x << Momentum {1.66007664274403694e-03 * DaysPerYear, 7.69901118419740425e-03 * DaysPerYear, -6.90460016972063023e-05 * DaysPerYear, 9.54791938424326609e-04 * SolarMass} Momentum {1.66007664274403694e-03 * DaysPerYear, 7.69901118419740425e-03 * DaysPerYear, -6.90460016972063023e-05 * DaysPerYear, 9.54791938424326609e-04 * SolarMass},
x << Momentum {-2.76742510726862411e-03 * DaysPerYear, 4.99852801234917238e-03 * DaysPerYear, 2.30417297573763929e-05 * DaysPerYear, 2.85885980666130812e-04 * SolarMass} Momentum {-2.76742510726862411e-03 * DaysPerYear, 4.99852801234917238e-03 * DaysPerYear, 2.30417297573763929e-05 * DaysPerYear, 2.85885980666130812e-04 * SolarMass},
x << Momentum {2.96460137564761618e-03 * DaysPerYear, 2.37847173959480950e-03 * DaysPerYear, -2.96589568540237556e-05 * DaysPerYear, 4.36624404335156298e-05 * SolarMass} Momentum {2.96460137564761618e-03 * DaysPerYear, 2.37847173959480950e-03 * DaysPerYear, -2.96589568540237556e-05 * DaysPerYear, 4.36624404335156298e-05 * SolarMass},
x << Momentum {2.68067772490389322e-03 * DaysPerYear, 1.62824170038242295e-03 * DaysPerYear, -9.51592254519715870e-05 * DaysPerYear, 5.15138902046611451e-05 * SolarMass} Momentum {2.68067772490389322e-03 * DaysPerYear, 1.62824170038242295e-03 * DaysPerYear, -9.51592254519715870e-05 * DaysPerYear, 5.15138902046611451e-05 * SolarMass},
return x ]
} }
pub fn arr_position() []Position { pub fn arr_position() []Position {
mut x := []Position return [
x << Position {0.0, 0.0, 0.0} Position {0.0, 0.0, 0.0},
x << Position {4.84143144246472090e+00, -1.16032004402742839e+00, -1.03622044471123109e-01} Position {4.84143144246472090e+00, -1.16032004402742839e+00, -1.03622044471123109e-01},
x << Position {8.34336671824457987e+00, 4.12479856412430479e+00, -4.03523417114321381e-01} Position {8.34336671824457987e+00, 4.12479856412430479e+00, -4.03523417114321381e-01},
x << Position {1.28943695621391310e+01, -1.51111514016986312e+01, -2.23307578892655734e-01} Position {1.28943695621391310e+01, -1.51111514016986312e+01, -2.23307578892655734e-01},
x << Position {1.53796971148509165e+01, -2.59193146099879641e+01, 1.79258772950371181e-01} Position {1.53796971148509165e+01, -2.59193146099879641e+01, 1.79258772950371181e-01},
return x ]
} }
fn main() { fn main() {