math.km 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ## Math Constants
  2. /// τ = 2π
  3. export const Tau: Float := (2.0 * Pi);
  4. /// π = arccos(-1)
  5. export const Pi: Float := { acos -1.0 };
  6. /// e = exp(1)
  7. export const E: Float := { exp 1.0 };
  8. ## Math Basic Operators
  9. export function +: &(Integer,Integer) => Integer native 'i+i';
  10. export function -: &(Integer,Integer) => Integer native 'i-i';
  11. export function -: &(Integer) => Integer native '-i';
  12. export function *: &(Integer,Integer) => Integer native 'i*i';
  13. export function /: &(Integer,Integer) => Integer native 'i/i';
  14. export function %: &(Integer,Integer) => Integer native 'i%i';
  15. export function +: &(Number,Number) => Number native 'i+i';
  16. export function *: &(Number,Number) => Number native 'i*i';
  17. export function /: &(Number,Number) => Number native 'i/i';
  18. export function %: &(Number,Number) => Number native 'i%i';
  19. export function -!: &(Number,Number) => Number native 'n-!n';
  20. export function +: &(Float,Float) => Float native 'f+f';
  21. export function -: &(Float,Float) => Float native 'f-f';
  22. export function -: &(Float) => Float native '-f';
  23. export function *: &(Float,Float) => Float native 'f*f';
  24. export function /: &(Float,Float) => Float native 'f/f';
  25. export function %: &(Float,Float) => Float native 'f%f';
  26. export function +: &(Complex,Complex) => Complex native 'c+c';
  27. export function +: &(Float,Complex) => Complex native 'f+c';
  28. export function +: &(Complex,Float) => Complex native 'c+f';
  29. export function -: &(Complex,Complex) => Complex native 'c-c';
  30. export function -: &(Float,Complex) => Complex native 'f-c';
  31. export function -: &(Complex,Float) => Complex native 'c-f';
  32. export function -: &(Complex) => Complex native '-c';
  33. export function *: &(Complex,Complex) => Complex native 'c*c';
  34. export function *: &(Float,Complex) => Complex native 'f*c';
  35. export function *: &(Complex,Float) => Complex native 'c*f';
  36. export function /: &(Complex,Complex) => Complex native 'c/c';
  37. export function /: &(Float,Complex) => Complex native 'f/c';
  38. export function /: &(Complex,Float) => Complex native 'c/f';
  39. ## Math Advanced Operators
  40. export function **: &(Integer,Integer) => Integer native 'i**i';
  41. export function modexp: &(Integer,Integer,Number) => Integer native 'modexp';
  42. export function quorem: &(Integer,Integer) => (Integer,Integer) native 'quorem';
  43. export function divmod: &(Integer,Integer) => (Integer,Integer) native 'divmod';
  44. export function **: &(Float,Float) => Float native 'f**f';
  45. export function floor: &(Float) => Float native 'floor';
  46. export function ceil: &(Float) => Float native 'ceil';
  47. export function round: &(Float) => Float native 'round';
  48. export function sqrt: &(Float) => Float native 'float-sqrt';
  49. export function cbrt: &(Float) => Float native 'float-cbrt';
  50. export function exp: &(Float) => Float native 'float-exp';
  51. export function log: &(Float) => Float native 'float-log';
  52. export function sin: &(Float) => Float native 'float-sin';
  53. export function cos: &(Float) => Float native 'float-cos';
  54. export function tan: &(Float) => Float native 'float-tan';
  55. export function asin: &(Float) => Float native 'float-asin';
  56. export function acos: &(Float) => Float native 'float-acos';
  57. export function atan: &(Float) => Float native 'float-atan';
  58. export function atan2: &({ y:Float, x:Float }) => Float
  59. native 'atan2';
  60. export function sqrt: &(Complex) => Complex native 'complex-sqrt';
  61. export function cbrt: &(Complex) => Complex native 'complex-cbrt';
  62. export function exp: &(Complex) => Complex native 'complex-exp';
  63. export function log: &(Complex) => Complex native 'complex-log';
  64. export function sin: &(Complex) => Complex native 'complex-sin';
  65. export function cos: &(Complex) => Complex native 'complex-cos';
  66. export function tan: &(Complex) => Complex native 'complex-tan';
  67. export function asin: &(Complex) => Complex native 'complex-asin';
  68. export function acos: &(Complex) => Complex native 'complex-acos';
  69. export function atan: &(Complex) => Complex native 'complex-atan';