Skip to content

Inplace operations (sum_axis, ...) #425

Closed
@davenza

Description

@davenza

It would be really useful to have inplace versions for some operations.

In one of my projects I am using sum_axis(). However, I would prefer to make the operation inplace. I don't think is necessary to allocate more memory. Is there any plans to do such a thing?

I've tried to develop my own version of the sum_axis_inplace by wrapping the ArrayD inside a struct:

pub struct TabularValues<V>(pub ArrayD<V>);

However, making inplace changes in the Array involves a bunch of unsafe code (in my implementation I used multiple ArrayViews of the data in the deleted axis with ArrayView::from_shape_ptr()). Still, my implementation is not complete because I don't know how to modify the shape and strides. In fact, I would also like to call shrink_to_fit in the inner Vec, but I don't know how to do that.

Having easier access to the elements of the array (Vec, shape, strides) would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions