vsum   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/core/math.xtm

Implementation

(bind-func vsum
  (lambda (buf:i32* len:i64)
    (let ((tot:i32 0) (i 0))
      (if (> len 3)
        (let ((chunks (/ len 4)) (vbuf:/4,i32/* (cast buf)) (vtot:/4,i32/* (salloc)))
          (vfill! vtot 0 0 0 0)
          (let ((totref (pref vtot 0)))
            (dotimes (i chunks)
              (set! totref (+ totref (pref-ptr vbuf i))))
            (set! tot (+ (vref totref 0) (vref totref 1) (vref totref 2) (vref totref 3))))
          (set! len (& len 3))
          (set! buf (pref-ptr buf (* i 4)))))
      (dotimes (i len)
        (set! tot (+ tot (pref buf i))))
      tot)))


Back to Index

Similar Entries

  • vsum    xtlang
  • vsum    xtlang
  • vsum    xtlang
  • vvsum    xtlang
  • vvsum    xtlang