From: Fabian <fb...@t-...> - 2010-10-20 11:50:00
|
Hi all, there is a little bug in idx-flatten, when you use it with a negative argument. For example: ;;define: (setq a (idx-reshape (arange (* 12 57 12 12 3)) '(12 57 12 12 3))) = ::Index:DoubleStorage:<12x57x12x12x3> ;;now you get: (idx-flatten a -2) *** index-reshape! : number of elements must be the same with new shape : 295488 Debug toplevel [y/N] ? ------------ Fix: in file src/index.c, function index_flatten line 3716, replace for (int i=IND_NDIMS(ind)-2; i>=r-1; i--) IND_DIM(shp, r-1) *= IND_DIM(ind, i); for (int i=r-2; i>=0; i--) IND_DIM(shp, i-r+2) = IND_DIM(ind, i); with: for (int i=0; i<=r-2;i++) IND_DIM(shp, i) = IND_DIM(ind, i); for (int i=r-1; i<=IND_NDIMS(ind)-2;i++) IND_DIM(shp, r-1) *= IND_DIM(ind, i); ------------ ;;now it works; (mapfor (i -4 4 1) (shape (idx-flatten a i))) ;;gives: ((295488) (12 24624) (12 57 432) (12 57 12 36) (12 57 12 12 3) (684 12 12 3) (8208 12 3) (98496 3) (295488)) with best regards Fabian |