;This returns the position of the max value in a vector
(bind-func vmax_pos:[i64,float*,i64]*
(lambda (buf:float* len:i64)
(let ((max_val:float (pref buf 0))
(i:i64 0)
(max_pos:i64 0))
(dotimes (i len)
(if (> (pref buf i) max_val)
(begin
(set! max_val (pref buf i))
(set! max_pos i))))
max_pos)))