Skip to content

Commit

Permalink
more nbody.pl fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Reini Urban committed Sep 19, 2013
1 parent 95a1275 commit 2885d50
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions example/nbody.pl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sub advance {
my $j = $i + 1;
while ($j < $nbodies) {
my ($dx, $dy, $dz) = ($bix - $xs[$j], $biy - $ys[$j], $biz - $zs[$j]);
my $distance = sqrt($dx * $dx + $dy * $dy + $dz * $dz);
my $distance = sqrt $dx * $dx + $dy * $dy + $dz * $dz;
my $mag = $dt / ($distance * $distance * $distance);
my $bim = $bimass * $mag;
my $bjm = $mass[$j] * $mag;
Expand All @@ -57,11 +57,11 @@ sub advance {
$vys[$j] += $dy * $bim;
$vzs[$j] += $dz * $bim;
$j++
}
}
($vxs[$i],$vys[$i],$vzs[$i]) = ($vx, $vy, $vz);
$xs[$i] = $bix + $dt * $bivx;
$ys[$i] = $biy + $dt * $bivy;
$zs[$i] = $biz + $dt * $bivz;
$xs[$i] = $bix + $dt * $vx;
$ys[$i] = $biy + $dt * $vy;
$zs[$i] = $biz + $dt * $vz;
$i++
}
}
Expand All @@ -77,7 +77,7 @@ sub energy {
my $j = $i + 1;
while ($j < $nbodies) {
my ($dx, $dy, $dz) = ($bix - $xs[$j], $biy - $ys[$j], $biz - $zs[$j]);
my $distance = sqrt($dx * $dx + $dy * $dy + $dz * $dz);
my $distance = sqrt $dx * $dx + $dy * $dy + $dz * $dz;
$e -= ($bimass * $mass[$j]) / $distance;
$j++
}
Expand Down
2 changes: 1 addition & 1 deletion front/potion.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ char * addmodule(Potion *P, char *result, char *prefix, char *name) {
} else {
pn_printf(P, out, "load \"%s\"\n", name);
}
if (args) // TODO split comma-delim args into list
if (args)
pn_printf(P, out, "%s(%s)\n", name, args);
else
pn_printf(P, out, "%s()\n", name);
Expand Down

0 comments on commit 2885d50

Please sign in to comment.