Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[n-body] fix some type errors
  • Loading branch information
moritz committed May 6, 2012
1 parent fce6a8b commit 35a8ba2
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions shootout/n-body.p6.pl
Expand Up @@ -4,16 +4,15 @@
#
# USAGE: perl6 n-body.p6.pl 1000

constant PI = 3.141592653589793;
constant SOLAR_MASS = (4 * PI * PI);
constant DAYS_PER_YEAR = 365.24;
constant SOLAR_MASS = (4 * pi * pi);
constant DAYS_PER_YEAR = 365.24e0;

constant $LAST = 4;

# @ns = ( sun, jupiter, saturn, uranus, neptune )
my Num @XS = (0, 4.84143144246472090e+00, 8.34336671824457987e+00, 1.28943695621391310e+01, 1.53796971148509165e+01);
my Num @YS = (0, -1.16032004402742839e+00, 4.12479856412430479e+00, -1.51111514016986312e+01, -2.59193146099879641e+01);
my Num @ZS = (0, -1.03622044471123109e-01, -4.03523417114321381e-01, -2.23307578892655734e-01, 1.79258772950371181e-01);
my Num @XS = (0e0, 4.84143144246472090e+00, 8.34336671824457987e+00, 1.28943695621391310e+01, 1.53796971148509165e+01);
my Num @YS = (0e0, -1.16032004402742839e+00, 4.12479856412430479e+00, -1.51111514016986312e+01, -2.59193146099879641e+01);
my Num @ZS = (0e0, -1.03622044471123109e-01, -4.03523417114321381e-01, -2.23307578892655734e-01, 1.79258772950371181e-01);
my Num @VXS = map {$^a * DAYS_PER_YEAR},
(0, 1.66007664274403694e-03, -2.76742510726862411e-03, 2.96460137564761618e-03, 2.68067772490389322e-03);
my Num @VYS = map {$^a * DAYS_PER_YEAR},
Expand Down Expand Up @@ -63,7 +62,7 @@ ($dt)
sub energy {
my Num ($e, $dx, $dy, $dz, $distance);

$e = 0.0;
$e = 0e0;
for 0..$LAST -> $i {
$e += 0.5 * @MASS[$i] *
(@VXS[$i]*@VXS[$i] + @VYS[$i]*@VYS[$i] + @VZS[$i]*@VZS[$i]);
Expand All @@ -79,7 +78,7 @@ sub energy {
}

sub offset_momentum {
my Num ($px, $py, $pz) = (0.0, 0.0, 0.0);
my Num ($px, $py, $pz) = (0e0, 0e0, 0e0);

for 0..$LAST -> $i {
$px += @VXS[$i] * @MASS[$i];
Expand Down

0 comments on commit 35a8ba2

Please sign in to comment.