-
Notifications
You must be signed in to change notification settings - Fork 27
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
Array Updates #633
Comments
Some caveats/gotchas/pitfalls that have come up as I've been working through the MCArray -> Array replacement:
int[] values = {1, 2, 3, 4}; // 2x2 {{1,2},{3,4}}
Array<int, 2> arr(1, 2); // create a 2D array with extents 1x2
arr(0,0) = 5;
arr(0,1) = 6;
// TODO: this will be an ArrayView since we're only temporarily wrapping a pointer
arr.insert(0, Array<int, 2>(values, 2, 2)); // temporary 2D array wrapping "values" with extents 2x2
// will print [ 1 2 3 4 5 6 ]
std::cout << arr << "\n"; The above method requires that the array argument be of the same dimension of the calling object and have identical extents in all but the leading dimension (such that you could insert a 2x2 into a 3x2 to get a 5x2). Currently the "units" of the |
I'm tempted to side with MCArray's interpretation, here. To me, Of course, it's important to be able to get the individual dimensions as well as the total number of items contained in the array. |
Regarding points (2) and (3), I don't expect to do any inserting, appending, or emplacing in the multidimensional case at all. So, if it were up to me, I wouldn't even worry about implementing those except in the 1D case (and then, if users decide they are essential after all, they could be added later). |
My thoughts on 1. I find it odd you would want to know how many tuples are in a multidimensional array. I would expect if i ask the size of a 2x2 array, that I would receive the answer 4 elements not 2 tuples. This just gets more confusing if you do a 3x3x3, is it 3, because that's the top level amount of tuples, or 9 tuple instead of 27. I agree if this was an array of containers, I would expect the size to be the number of those containers. But the fact that it is tuples is an internal implementation detail, not something the user of the class should care about. |
@samuelpmishLLNL Your point on As for inserting/appending/emplacing - it looks like at least the inserting/appending gets used fairly frequently by users of MCArray, though it's often tricky to tell if it's actually doing a multidimensional insertion or if it's actually a "trivially multidimensional" array where the trailing dimension is 1. Emplacing for a MCArray is roughly "inserting |
My two cents for what its worth... I personally feel Given the fact that this is a multidimensional array, would a user expect to use With a 2d array:
or:
|
I agree with @white238 here. Size should be the product of the dimensions. See also: https://numpy.org/doc/stable/reference/generated/numpy.ndarray.size.html EDIT: And @joshessman-llnl's original link (I should have read closer) |
I don't want to belabor this discussion too much, but it may be worth looking to the |
The decision to temporarily punt on removing MCArray from I am not completely sure of this but I would imagine the vast majority of that effort would be characterized by the following:
|
I noticed that As a workaround, I think we should consider adding the ability to construct |
From #627
I envision making the following changes in each PR (roughly in order)
Other (smaller?) feature requests/tasks:
axom::StackArray
instead ofstd::array
for the return values (and internal storage) ofshape()
et al - this will require some feature additions toStackArray
- Full GPU support for axom::Array #695std::inner_product
from index calculations so it can run on a GPU - Full GPU support for axom::Array #695axom::numerics::Matrix
to inherit fromaxom::Array
ArrayIterator
to be aware of the shape of multidimensional arrays (Replace Array external buffer functionality with ArrayView #678 (comment))MemorySpace
when it's locked down - point of contact @samuelpmishLLNLArrayView
s or in similar contextsdetail::getAllocatorID
(FIXME needs clarification) - see Full GPU support for axom::Array #695 (comment)const Array<T>
toArrayView<const T>
conversion - Initialize memory in axom::Array by default, allow for creation of ArrayView<const T> #709initializer_list
constructors toaxom::Array
- see Miscellaneous axom::Array improvements #808The text was updated successfully, but these errors were encountered: