vcosf4   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/core/extempore_lang.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.141592 2.0)))
        (b_ (dtof (/ 4.0 3.141592)))
        (c_ (dtof (/ -4.0 (* 3.141592 3.141592)))))
    (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