2011-10-26 13:28:23 -05:00
|
|
|
/* Module: math */
|
|
|
|
|
2011-10-18 06:45:17 -05:00
|
|
|
native "llvm" mod llvm {
|
|
|
|
fn sqrt(n: float) -> float = "sqrt.f64";
|
|
|
|
fn sin(n: float) -> float = "sin.f64";
|
|
|
|
fn asin(n: float) -> float = "asin.f64";
|
|
|
|
fn cos(n: float) -> float = "cos.f64";
|
|
|
|
fn acos(n: float) -> float = "acos.f64";
|
|
|
|
fn tan(n: float) -> float = "tan.f64";
|
|
|
|
fn atan(n: float) -> float = "atan.f64";
|
|
|
|
}
|
|
|
|
|
2011-10-26 18:24:31 -05:00
|
|
|
/*
|
|
|
|
Function: sqrt
|
|
|
|
|
|
|
|
Returns the square root
|
|
|
|
*/
|
2011-10-18 06:45:17 -05:00
|
|
|
fn sqrt(x: float) -> float { llvm::sqrt(x) }
|
2011-10-26 18:24:31 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: sin
|
|
|
|
|
|
|
|
Returns the sine of an angle
|
|
|
|
*/
|
2011-10-18 06:45:17 -05:00
|
|
|
fn sin(x: float) -> float { llvm::sin(x) }
|
2011-10-26 18:24:31 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: cos
|
|
|
|
|
|
|
|
Returns the cosine of an angle
|
|
|
|
*/
|
2011-10-18 06:45:17 -05:00
|
|
|
fn cos(x: float) -> float { llvm::cos(x) }
|
2011-10-26 18:24:31 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: tan
|
|
|
|
|
|
|
|
Returns the tangent of an angle
|
|
|
|
*/
|
2011-10-18 06:45:17 -05:00
|
|
|
fn tan(x: float) -> float { llvm::tan(x) }
|
2011-10-26 18:24:31 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: asin
|
|
|
|
|
|
|
|
Returns the arcsine of an angle
|
|
|
|
*/
|
2011-10-18 06:45:17 -05:00
|
|
|
fn asin(x: float) -> float { llvm::asin(x) }
|
2011-10-26 18:24:31 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: acos
|
|
|
|
|
|
|
|
Returns the arccosine of an angle
|
|
|
|
*/
|
2011-10-18 06:45:17 -05:00
|
|
|
fn acos(x: float) -> float { llvm::acos(x) }
|
2011-10-26 18:24:31 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: atan
|
|
|
|
|
|
|
|
Returns the arctangent of an angle
|
|
|
|
*/
|
2011-10-18 06:45:17 -05:00
|
|
|
fn atan(x: float) -> float { llvm::atan(x) }
|
|
|
|
|
2011-10-26 18:24:31 -05:00
|
|
|
/*
|
|
|
|
Const: pi
|
|
|
|
|
|
|
|
Archimedes' constant
|
|
|
|
*/
|
2011-10-18 06:45:17 -05:00
|
|
|
const pi: float = 3.141592653589793;
|
|
|
|
|
2011-10-26 18:24:31 -05:00
|
|
|
/*
|
|
|
|
Function: min
|
|
|
|
|
|
|
|
Returns the minimum of two values
|
|
|
|
*/
|
2011-10-25 08:56:55 -05:00
|
|
|
fn min<T>(x: T, y: T) -> T { x < y ? x : y }
|
2011-10-26 18:24:31 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
Function: max
|
|
|
|
|
|
|
|
Returns the maximum of two values
|
|
|
|
*/
|
2011-10-25 08:56:55 -05:00
|
|
|
fn max<T>(x: T, y: T) -> T { x < y ? y : x }
|