You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently if we need to do elementwise operation on array, we can create a result array, and wrap it together with parameters arrays in Zip and use apply to assign the result. However, since Zip have the shape information, can we add a helper function to allocate a result array with correct shape, so that we don't need to create the result array manually?
The text was updated successfully, but these errors were encountered:
This seems to be enough to implement this feature on Zip with some limitations (Copy-only elements because we miss handling of partially filled arrays with elements that are uninit or need drop).
/// Apply function and collect the results into a new array.pubfnapply_collect<R>(self,mutf:implFnMut($($p::Item,)*) -> R) -> Array<R,D>whereR:Copy,{unsafe{letmut output = Array::uninitialized(self.dimension.clone());self.and(output.raw_view_mut()).apply(move |$($p,)* output_| {
std::ptr::write(output_,f($($p ),*));});
output
}}
Edit: Should be fixed to at least pick the right layout out of c/f, and more if possible.
Currently if we need to do elementwise operation on array, we can create a result array, and wrap it together with parameters arrays in
Zip
and useapply
to assign the result. However, sinceZip
have the shape information, can we add a helper function to allocate a result array with correct shape, so that we don't need to create the result array manually?The text was updated successfully, but these errors were encountered: