;; complex in -> real out
(bind-func idft
(lambda (in:Complexd* out:double* len)
(let ((n:i64 0) (k:i64 0) (tmp 0.0) (cpx:Complexd* null) (N (i64tod len)))
(dotimes (n len)
(pset! out n 0.0)
(dotimes (k len)
(set! cpx (pref-ptr in k))
(set! tmp (* (i64tod (* k n)) (/ TWOPI N)))
(pset! out n
(+ (pref out n)
(- (* (tref cpx 0) (cos tmp))
(* (tref cpx 1) (sin tmp))))))
;; scale
(pset! out n (/ (pref out n) N)))
void)))