Re: [julia-users] delete slices from 3D array

338 views
Skip to first unread message

Stefan Karpinski

unread,
Jun 12, 2013, 10:23:18 AM6/12/13
to Julia Users
No, we don't support resizing anything but 1-d arrays, which is actually already a rather big problem for hoisting bounds checks – not an issue that NumPy needs to worry about.


On Wed, Jun 12, 2013 at 10:13 AM, <sam.ca...@gmail.com> wrote:
Hi all,

is there a function to delete slices from a 3D array given a list of slice indexes?
I'm looking for the equivalent of numpy.delete, for example, given the following matrix

x = np.zeros((4,4,4))

delte the second and fourth slice on the third axis:
y = np.delete(x, [1,3], axis=2)

Sam

Elliot Saba

unread,
Jun 12, 2013, 2:16:52 PM6/12/13
to julia...@googlegroups.com
I recently worked on a project in julia where I wanted to delete columns from a 2d array, and I ended up having to write my own resizing algorithms.  Ironically, those algorithms took up much more runtime than any other portion of the algorithm, so perhaps we can get some fast algorithm published (in base or wherever) to do this eventually.  I don't see it as a super high priority at the moment, however.

Stefan Karpinski

unread,
Jun 12, 2013, 2:24:28 PM6/12/13
to julia...@googlegroups.com
Another option in cases where you know you're going to have to shuffle or add or delete columns a lot would be to use an array-of-arrays. You could throw a wrapper around such a type to make it act like a 2d Array but also have facilities for column removal, addition and reordering. The down side would be that matvec and matmul with such a type would have to be column-wise, which not as fast.
Reply all
Reply to author
Forward
0 new messages