db4
Slava Pestov 2008-11-29 12:42:53 -06:00
parent 267ab0aa4d
commit 1ae43cc5e7
1 changed files with 20 additions and 22 deletions

View File

@ -11,39 +11,37 @@ IN: benchmark.nbody
TUPLE: body
{ location float-array }
{ velocity float-array }
{ mass float } ;
{ mass float read-only } ;
: <body> ( -- body ) body new ; inline
: <body> ( location velocity mass -- body )
[ days-per-year v*n ] [ solar-mass * ] bi* body boa ; inline
: <jupiter> ( -- body )
<body>
F{ 4.84143144246472090e+00 -1.16032004402742839e+00 -1.03622044471123109e-01 } >>location
F{ 1.66007664274403694e-03 7.69901118419740425e-03 -6.90460016972063023e-05 } days-per-year v*n >>velocity
9.54791938424326609e-04 solar-mass * >>mass ;
F{ 4.84143144246472090e+00 -1.16032004402742839e+00 -1.03622044471123109e-01 }
F{ 1.66007664274403694e-03 7.69901118419740425e-03 -6.90460016972063023e-05 }
9.54791938424326609e-04
<body> ;
: <saturn> ( -- body )
<body>
F{ 8.34336671824457987e+00 4.12479856412430479e+00 -4.03523417114321381e-01 } >>location
F{ -2.76742510726862411e-03 4.99852801234917238e-03 2.30417297573763929e-05 } days-per-year v*n >>velocity
2.85885980666130812e-04 solar-mass * >>mass ;
F{ 8.34336671824457987e+00 4.12479856412430479e+00 -4.03523417114321381e-01 }
F{ -2.76742510726862411e-03 4.99852801234917238e-03 2.30417297573763929e-05 }
2.85885980666130812e-04
<body> ;
: <uranus> ( -- body )
<body>
F{ 1.28943695621391310e+01 -1.51111514016986312e+01 -2.23307578892655734e-01 } >>location
F{ 2.96460137564761618e-03 2.37847173959480950e-03 -2.96589568540237556e-05 } days-per-year v*n >>velocity
4.36624404335156298e-05 solar-mass * >>mass ;
F{ 1.28943695621391310e+01 -1.51111514016986312e+01 -2.23307578892655734e-01 }
F{ 2.96460137564761618e-03 2.37847173959480950e-03 -2.96589568540237556e-05 }
4.36624404335156298e-05
<body> ;
: <neptune> ( -- body )
<body>
F{ 1.53796971148509165e+01 -2.59193146099879641e+01 1.79258772950371181e-01 } >>location
F{ 2.68067772490389322e-03 1.62824170038242295e-03 -9.51592254519715870e-05 } days-per-year v*n >>velocity
5.15138902046611451e-05 solar-mass * >>mass ;
F{ 1.53796971148509165e+01 -2.59193146099879641e+01 1.79258772950371181e-01 }
F{ 2.68067772490389322e-03 1.62824170038242295e-03 -9.51592254519715870e-05 }
5.15138902046611451e-05
<body> ;
: <sun> ( -- body )
<body>
solar-mass >>mass
F{ 0 0 0 } >>location
F{ 0 0 0 } >>velocity ;
F{ 0 0 0 } F{ 0 0 0 } 1 <body> ;
: offset-momentum ( body offset -- body )
vneg solar-mass v/n >>velocity ; inline