linalg_hlsl_math.odin 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. ceil_float :: proc "c" (x: float) -> float { return math.ceil(x) }
  28. fmod_float :: proc "c" (x, y: float) -> float { return math.mod(x, y) }
  29. frac_float :: proc "c" (x: float) -> float {
  30. if x >= 0 {
  31. return x - math.trunc(x)
  32. }
  33. return math.trunc(-x) + x
  34. }
  35. cos_double :: proc "c" (x: double) -> double { return math.cos(x) }
  36. sin_double :: proc "c" (x: double) -> double { return math.sin(x) }
  37. tan_double :: proc "c" (x: double) -> double { return math.tan(x) }
  38. acos_double :: proc "c" (x: double) -> double { return math.acos(x) }
  39. asin_double :: proc "c" (x: double) -> double { return math.asin(x) }
  40. atan_double :: proc "c" (x: double) -> double { return math.atan(x) }
  41. atan2_double :: proc "c" (y, x: double) -> double { return math.atan2(y, x) }
  42. cosh_double :: proc "c" (x: double) -> double { return math.cosh(x) }
  43. sinh_double :: proc "c" (x: double) -> double { return math.sinh(x) }
  44. tanh_double :: proc "c" (x: double) -> double { return math.tanh(x) }
  45. acosh_double :: proc "c" (x: double) -> double { return math.acosh(x) }
  46. asinh_double :: proc "c" (x: double) -> double { return math.asinh(x) }
  47. atanh_double :: proc "c" (x: double) -> double { return math.atanh(x) }
  48. sqrt_double :: proc "c" (x: double) -> double { return math.sqrt(x) }
  49. rsqrt_double :: proc "c" (x: double) -> double { return 1.0/math.sqrt(x) }
  50. rcp_double :: proc "c" (x: double) -> double { return 1.0/x }
  51. pow_double :: proc "c" (x, y: double) -> double { return math.pow(x, y) }
  52. exp_double :: proc "c" (x: double) -> double { return math.exp(x) }
  53. log_double :: proc "c" (x: double) -> double { return math.ln(x) }
  54. log2_double :: proc "c" (x: double) -> double { return math.log(x, 2) }
  55. log10_double :: proc "c" (x: double) -> double { return math.log(x, 10) }
  56. exp2_double :: proc "c" (x: double) -> double { return math.pow(double(2), x) }
  57. sign_double :: proc "c" (x: double) -> double { return math.sign(x) }
  58. floor_double :: proc "c" (x: double) -> double { return math.floor(x) }
  59. ceil_double :: proc "c" (x: double) -> double { return math.ceil(x) }
  60. fmod_double :: proc "c" (x, y: double) -> double { return math.mod(x, y) }
  61. frac_double :: proc "c" (x: double) -> double {
  62. if x >= 0 {
  63. return x - math.trunc(x)
  64. }
  65. return math.trunc(-x) + x
  66. }