vcosf4   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/tests/core/xtlang.xtm

Implementation

(bind-func vcosf4
  (let ((p:/4,float/* (alloc))
  (b:/4,float/* (alloc))
  (c:/4,float/* (alloc))
  (d:/4,float/* (alloc))
  (f1:/4,float/* (alloc))
  (f2:/4,float/* (alloc))
  (i:i32 0)
  (p_ 0.225)
  (d_ (dtof (/ 3.1415 2.0)))
  (b_ (dtof (/ 4.0 3.1415)))
  (c_ (dtof (/ -4.0 (* 3.1415 3.1415)))))
    (dotimes (i 4)
      (vset! p i p_) (vset! b i b_) (vset! c i c_) (vset! d i d_))
    (lambda (x:/4,float/)
      ;; offset x for cos
      (set! x (+ x d))
      ;; no SIMD for abs yet!
      (dotimes (i 4) (vset! f1 i (fabs (vref x i))))
      (let ((y (+ (* b x) (* c x f1))))
  ;; no SIMD for abs yet!
  (dotimes (i 4) (vset! f2 i (fabs (vref y i))))
  (+ (* p (- (* y f2) y)) y)))))


Back to Index

Similar Entries