linalg_hlsl_math.odin 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package math_linalg_hlsl
  2. import "core:math"
  3. cos_float :: proc "c" (x: float) -> float { return math.cos(x) }
  4. sin_float :: proc "c" (x: float) -> float { return math.sin(x) }
  5. tan_float :: proc "c" (x: float) -> float { return math.tan(x) }
  6. acos_float :: proc "c" (x: float) -> float { return math.acos(x) }
  7. asin_float :: proc "c" (x: float) -> float { return math.asin(x) }
  8. atan_float :: proc "c" (x: float) -> float { return math.atan(x) }
  9. atan2_float :: proc "c" (y, x: float) -> float { return math.atan2(y, x) }
  10. cosh_float :: proc "c" (x: float) -> float { return math.cosh(x) }
  11. sinh_float :: proc "c" (x: float) -> float { return math.sinh(x) }
  12. tanh_float :: proc "c" (x: float) -> float { return math.tanh(x) }
  13. acosh_float :: proc "c" (x: float) -> float { return math.acosh(x) }
  14. asinh_float :: proc "c" (x: float) -> float { return math.asinh(x) }
  15. atanh_float :: proc "c" (x: float) -> float { return math.atanh(x) }
  16. sqrt_float :: proc "c" (x: float) -> float { return math.sqrt(x) }
  17. rsqrt_float :: proc "c" (x: float) -> float { return 1.0/math.sqrt(x) }
  18. rcp_float :: proc "c" (x: float) -> float { return 1.0/x }
  19. pow_float :: proc "c" (x, y: float) -> float { return math.pow(x, y) }
  20. exp_float :: proc "c" (x: float) -> float { return math.exp(x) }
  21. log_float :: proc "c" (x: float) -> float { return math.ln(x) }
  22. log2_float :: proc "c" (x: float) -> float { return math.log(x, 2) }
  23. log10_float :: proc "c" (x: float) -> float { return math.log(x, 10) }
  24. exp2_float :: proc "c" (x: float) -> float { return math.pow(float(2), x) }
  25. sign_float :: proc "c" (x: float) -> float { return math.sign(x) }
  26. floor_float :: proc "c" (x: float) -> float { return math.floor(x) }
  27. round_float :: proc "c" (x: float) -> float { return math.round(x) }
  28. ceil_float :: proc "c" (x: float) -> float { return math.ceil(x) }
  29. isnan_float :: proc "c" (x: float) -> bool { return math.classify(x) == .NaN}
  30. fmod_float :: proc "c" (x, y: float) -> float { return math.mod(x, y) }
  31. frac_float :: proc "c" (x: float) -> float {
  32. if x >= 0 {
  33. return x - math.trunc(x)
  34. }
  35. return math.trunc(-x) + x
  36. }
  37. cos_double :: proc "c" (x: double) -> double { return math.cos(x) }
  38. sin_double :: proc "c" (x: double) -> double { return math.sin(x) }
  39. tan_double :: proc "c" (x: double) -> double { return math.tan(x) }
  40. acos_double :: proc "c" (x: double) -> double { return math.acos(x) }
  41. asin_double :: proc "c" (x: double) -> double { return math.asin(x) }
  42. atan_double :: proc "c" (x: double) -> double { return math.atan(x) }
  43. atan2_double :: proc "c" (y, x: double) -> double { return math.atan2(y, x) }
  44. cosh_double :: proc "c" (x: double) -> double { return math.cosh(x) }
  45. sinh_double :: proc "c" (x: double) -> double { return math.sinh(x) }
  46. tanh_double :: proc "c" (x: double) -> double { return math.tanh(x) }
  47. acosh_double :: proc "c" (x: double) -> double { return math.acosh(x) }
  48. asinh_double :: proc "c" (x: double) -> double { return math.asinh(x) }
  49. atanh_double :: proc "c" (x: double) -> double { return math.atanh(x) }
  50. sqrt_double :: proc "c" (x: double) -> double { return math.sqrt(x) }
  51. rsqrt_double :: proc "c" (x: double) -> double { return 1.0/math.sqrt(x) }
  52. rcp_double :: proc "c" (x: double) -> double { return 1.0/x }
  53. pow_double :: proc "c" (x, y: double) -> double { return math.pow(x, y) }
  54. exp_double :: proc "c" (x: double) -> double { return math.exp(x) }
  55. log_double :: proc "c" (x: double) -> double { return math.ln(x) }
  56. log2_double :: proc "c" (x: double) -> double { return math.log(x, 2) }
  57. log10_double :: proc "c" (x: double) -> double { return math.log(x, 10) }
  58. exp2_double :: proc "c" (x: double) -> double { return math.pow(double(2), x) }
  59. sign_double :: proc "c" (x: double) -> double { return math.sign(x) }
  60. floor_double :: proc "c" (x: double) -> double { return math.floor(x) }
  61. round_double :: proc "c" (x: double) -> double { return math.round(x) }
  62. ceil_double :: proc "c" (x: double) -> double { return math.ceil(x) }
  63. isnan_double :: proc "c" (x: double) -> bool { return math.classify(x) == .NaN}
  64. fmod_double :: proc "c" (x, y: double) -> double { return math.mod(x, y) }
  65. frac_double :: proc "c" (x: double) -> double {
  66. if x >= 0 {
  67. return x - math.trunc(x)
  68. }
  69. return math.trunc(-x) + x
  70. }