File: Maths.k

package info (click to toggle)
kaya 0.2.0-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,012 kB
  • ctags: 1,307
  • sloc: cpp: 6,691; haskell: 4,833; sh: 2,868; yacc: 768; makefile: 700; perl: 87
file content (38 lines) | stat: -rw-r--r-- 1,080 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/** -*-C-*-ish
    Kaya standard library
    Copyright (C) 2004, 2005 Edwin Brady

    This file is distributed under the terms of the GNU Lesser General
    Public Licence. See COPYING for licence.
*/

module Maths;

%include "math.h";

// Some maths functions

foreign "libm" {
    public Float pow(Float x,Float e) = pow;
    public Float sqrt(Float x) = sqrt;
    public Float exp(Float x) = exp;
    public Float log(Float x) = log;
    public Float log10(Float x) = log10;
    public Float ceil(Float x) = ceil;
    public Float floor(Float x) = floor;
    public Float sin(Float x) = sin;
    public Float cos(Float x) = cos;
    public Float tan(Float x) = tan;
    public Float asin(Float x) = asin;
    public Float acos(Float x) = acos;
    public Float atan(Float x) = atan;
}

public Int pow(var Int x, var Int e) = Int(pow(Float(x),Float(e)));

// Some constants. Really, they're functions...

public Float PI = 3.141592653589793;
public Float M_E = 2.7182818284590452354;
public Float SQRT_2 = 1.41421356237309504880;
public Float SQRT_PI = 1.77245385090551602729;