ext/numo/narray/ndloop.c in numo-narray-0.9.0.9 vs ext/numo/narray/ndloop.c in numo-narray-0.9.1.0
- old
+ new
@@ -1877,10 +1877,23 @@
{
size_t *c;
int i,j;
int nd = lp->ndim;
+ // for zero-dimensional narray
+ if (nd==0) {
+ switch (lp->n[0]) {
+ case 0:
+ return;
+ case 1:
+ nd = 1;
+ break;
+ default:
+ rb_fatal("invalid narray");
+ }
+ }
+
// pass total ndim to iterator
lp->user.ndim += nd;
// alloc counter
lp->user.opt_ptr = c = ALLOCA_N(size_t, nd+1);
@@ -1916,10 +1929,10 @@
VALUE
#ifdef HAVE_STDARG_PROTOTYPES
na_ndloop_with_index(ndfunc_t *nf, int argc, ...)
#else
-na_ndloop(nf, argc, va_alist)
+na_ndloop_with_index(nf, argc, va_alist)
ndfunc_t *nf;
int argc;
va_dcl
#endif
{