testsuite: update tests to not use math intrinsics directly

This commit is contained in:
Huon Wilson 2013-04-21 00:59:08 +10:00
parent d9c54f8387
commit c5baeb1db3
2 changed files with 3 additions and 7 deletions

View File

@ -1,6 +1,5 @@
use core::from_str::FromStr;
use core::uint::range;
use core::unstable::intrinsics::sqrtf64;
static PI: f64 = 3.141592653589793;
static SOLAR_MASS: f64 = 4.0 * PI * PI;
@ -88,7 +87,7 @@ fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: i32) {
d[2] = bodies[i].x[2] - bodies[j].x[2];
let d2 = d[0]*d[0] + d[1]*d[1] + d[2]*d[2];
let mag = dt / (d2 * sqrtf64(d2));
let mag = dt / (d2 * f64::sqrt(d2));
let a_mass = bodies[i].mass, b_mass = bodies[j].mass;
bodies[i].v[0] -= d[0] * b_mass * mag;
@ -121,7 +120,7 @@ fn energy(bodies: &[Planet, ..N_BODIES]) -> f64 {
for range(0, 3) |k| {
d[k] = bodies[i].x[k] - bodies[j].x[k];
}
let dist = sqrtf64(d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
let dist = f64::sqrt(d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
e -= bodies[i].mass * bodies[j].mass / dist;
}
}
@ -147,4 +146,3 @@ fn main() {
println(fmt!("%.9f", energy(&bodies) as float));
}

View File

@ -1,6 +1,5 @@
use core::from_str::FromStr;
use core::iter::ExtendedMutableIter;
use core::unstable::intrinsics::sqrtf64;
#[inline]
fn A(i: i32, j: i32) -> i32 {
@ -49,6 +48,5 @@ fn main() {
mult_AtAv(v, u, tmp);
}
println(fmt!("%.9f", sqrtf64(dot(u,v) / dot(v,v)) as float));
println(fmt!("%.9f", f64::sqrt(dot(u,v) / dot(v,v)) as float));
}