-
Notifications
You must be signed in to change notification settings - Fork 320
ndarray development discussion and dashboard #293
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
Comments
Is it possible to reconsider #152 (range dimension and negative indexing)? As indexing and slicing uses different syntax, this should not be a breaking change, and it would really be useful for some kind of code. I think of FFT-like algorithms, where the problem space is naturally slitted over a symmetric If this is not acceptable to be in ndarray I think I'll try to implement it on top of standard arrays, but this means that we will be paying an additional overhead. I started a PoC for range-based dimensions in mudi, using a |
We can consider the change when we know how to implement it. Do you have any links that detail how such a thing is implemented efficiently? I don't understand why your implementation would have different performance implications than ndarray's? |
I know two implementation of this: the Fortran standard and Boost.MultiArray.
The performances implication might come from the needed translation from Another solution would be to do the index linearisation separately and call Another solution again would be to store a pointer + dimensions and build a ndarray from this when needed to access the functionalities with a |
It's intriguing, thanks for the links. Need to investigate how compatible it is with custom stride arrays. (To give a simple motivation for strided arrays: We want to be able to cut an array into array views that are rectangular pieces.) (The overhead of is_standard_layout should go away at some point, arrays should carry their layout information as an additional field. For a low-dimensional array, it's not much of an overhead, it's just comparing a pair.) |
Ok, there will be a ndarray 0.9 shortly after 0.8. I don't expect any actual breakage or difficulty with the upgrades, and the library is not really used for “interchange” much, so I think it's unproblematic. We're evidently still in exploration and development. |
I'm using ndarray heavily for a project right now for the first time and the biggest difficulty I'm encountering is how to write functions that can handle arrays of different shapes/forms. For instance, is there a way to take an Array or an ArrayView? I'm assuming there is - but haven't been able to figure it out as of yet. Perhaps you could provide additional guidance on how to use arrays in code outside the library. Thanks! |
@jonathanstrong If you want to have a function that takes any sort of Array, you have to work with fn zip_mut_with<A, B, S1, S2, E, F>(&mut ArrayBase<S1, E>, rhs: &ArrayBase<S2, E>, f: F) where
S1: DataMut<Elem = A>,
S2: Data<Elem = B>,
E: Dimension,
F: FnMut(&mut A, &B), Let's say you wanted to have a function that took a matrix and a vector, then you would use As you mentioned arrays of different shapes/forms: unfortunately, we don't have compile-time integer generics yet. So if you want to ensure that, say, a function takes two arrays of exactly the same number of elements/shape, you need to assert that at runtime. |
hi @jonathanstrong, I think accepting arrays of varying ndim is the least nice part of the library right now. Is that part of what you are doing? |
thanks for the example @SuperFluffy. @bluss that's one pain point. The one that prompted me to write was when I looped through the rows of a matrix with However, coming from a numpy/theano background this is definitely the rust math lib I feel most comfortable/productive working in. Thanks for all your hard work on it. |
Did my example with the I recently realized why @bluss chose to introduce I suppose once compile-time integer generics land, you might be able to pass around
Maybe it makes sense to do it like |
Right, it's convenient to write functions in terms of concrete types (like
|
I guess it's important for ndarray to explain that Array, ArrayView, ArrayViewMut are meant to mirror the ownership and borrowing semantics of |
This issue is superseded by discussion board (github) and matrix. |
The text was updated successfully, but these errors were encountered: