Skip to content

Fix set item for N-d vector assignment #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions numpy/include/numpy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ class ndarray {

void set_item(int index, const ndarray<T>& value) { xt::view(_array, index, xt::all()) = value.get_array(); }

void set_item(int i1, int i2, const ndarray<T>& value) { xt::view(_array, i1, i2, xt::all()) = value.get_array(); }

void set_item(int i1, int i2, int i3, const ndarray<T>& value) { xt::view(_array, i1, i2, i3, xt::all()) = value.get_array(); }

void set_item(int i1, int i2, int i3, int i4, const ndarray<T>& value) { xt::view(_array, i1, i2, i3, i4, xt::all()) = value.get_array(); }

void set_item(int i1, int i2, int i3, int i4, int i5, const ndarray<T>& value) { xt::view(_array, i1, i2, i3, i4, i5, xt::all()) = value.get_array(); }

void set_item(const std::vector<int>& indices, const ndarray<T>& value) {
xt::view(_array, xt::keep(indices)) = value.get_array();
}
Expand All @@ -303,13 +311,13 @@ class ndarray {
xt::view(_array, xt::range(std::get<0>(slice), std::get<1>(slice), std::get<2>(slice))) = value.get_array();
}

void set_item_2d(int i1, int i2, T value) { xt::view(_array, i1, i2) = value; }
void set_item(int i1, int i2, T value) { xt::view(_array, i1, i2) = value; }

void set_item_3d(int i1, int i2, int i3, T value) { xt::view(_array, i1, i2, i3) = value; }
void set_item(int i1, int i2, int i3, T value) { xt::view(_array, i1, i2, i3) = value; }

void set_item_4d(int i1, int i2, int i3, int i4, T value) { xt::view(_array, i1, i2, i3, i4) = value; }
void set_item(int i1, int i2, int i3, int i4, T value) { xt::view(_array, i1, i2, i3, i4) = value; }

void set_item_5d(int i1, int i2, int i3, int i4, int i5, T value) { xt::view(_array, i1, i2, i3, i4, i5) = value; }
void set_item(int i1, int i2, int i3, int i4, int i5, T value) { xt::view(_array, i1, i2, i3, i4, i5) = value; }

// Boolean Functions
bool all() const { return xt::all(_array); }
Expand Down
Loading
Loading