Sha256: 9df7e425c301c018c2550f5f735763cd0170cd299cbc982b14ed73a2f6adcc20
Contents?: true
Size: 996 Bytes
Versions: 7
Compression:
Stored size: 996 Bytes
Contents
static void <%=c_iter%>(na_loop_t *const lp) { size_t n; char *p1, *p2; dtype *buf; INIT_COUNTER(lp, n); p1 = (lp->args[0]).ptr + (lp->args[0].iter[0]).pos; p2 = (lp->args[1]).ptr + (lp->args[1].iter[0]).pos; buf = (dtype*)p1; <%=tp%>_qsort(buf, n, sizeof(dtype)); <% if is_float %> for (; n; n--) { if (!isnan(buf[n-1])) break; } <% end %> if (n==0) { *(dtype*)p2 = buf[0]; } else if (n%2==0) { *(dtype*)p2 = (buf[n/2-1]+buf[n/2])/2; } else { *(dtype*)p2 = buf[(n-1)/2]; } } static VALUE <%=c_func%>(int argc, VALUE *argv, VALUE self) { VALUE reduce; ndfunc_arg_in_t ain[2] = {{cT,0},{sym_reduce,0}}; ndfunc_arg_out_t aout[1] = {{INT2FIX(0),0}}; ndfunc_t ndf = {<%=c_iter%>, STRIDE_LOOP_NIP|NDF_FLAT_REDUCE, 2,1, ain,aout}; self = na_copy(self); reduce = na_reduce_dimension(argc, argv, 1, &self); // v[0] = self return na_ndloop(&ndf, 2, self, reduce); }
Version data entries
7 entries across 7 versions & 1 rubygems