@@ -22,7 +22,7 @@ use crate::dimension::{
22
22
abs_index, axes_of, do_slice, merge_axes, move_min_stride_axis_to_last,
23
23
offset_from_low_addr_ptr_to_logical_ptr, size_of_shape_checked, stride_offset, Axes ,
24
24
} ;
25
- use crate :: dimension:: broadcast:: co_broadcast;
25
+ use crate :: dimension:: broadcast:: { co_broadcast, upcast } ;
26
26
use crate :: dimension:: reshape_dim;
27
27
use crate :: error:: { self , ErrorKind , ShapeError , from_kind} ;
28
28
use crate :: math_cell:: MathCell ;
@@ -2036,56 +2036,6 @@ where
2036
2036
E : IntoDimension ,
2037
2037
S : Data ,
2038
2038
{
2039
- /// Return new stride when trying to grow `from` into shape `to`
2040
- ///
2041
- /// Broadcasting works by returning a "fake stride" where elements
2042
- /// to repeat are in axes with 0 stride, so that several indexes point
2043
- /// to the same element.
2044
- ///
2045
- /// **Note:** Cannot be used for mutable iterators, since repeating
2046
- /// elements would create aliasing pointers.
2047
- fn upcast < D : Dimension , E : Dimension > ( to : & D , from : & E , stride : & E ) -> Option < D > {
2048
- // Make sure the product of non-zero axis lengths does not exceed
2049
- // `isize::MAX`. This is the only safety check we need to perform
2050
- // because all the other constraints of `ArrayBase` are guaranteed
2051
- // to be met since we're starting from a valid `ArrayBase`.
2052
- let _ = size_of_shape_checked ( to) . ok ( ) ?;
2053
-
2054
- let mut new_stride = to. clone ( ) ;
2055
- // begin at the back (the least significant dimension)
2056
- // size of the axis has to either agree or `from` has to be 1
2057
- if to. ndim ( ) < from. ndim ( ) {
2058
- return None ;
2059
- }
2060
-
2061
- {
2062
- let mut new_stride_iter = new_stride. slice_mut ( ) . iter_mut ( ) . rev ( ) ;
2063
- for ( ( er, es) , dr) in from
2064
- . slice ( )
2065
- . iter ( )
2066
- . rev ( )
2067
- . zip ( stride. slice ( ) . iter ( ) . rev ( ) )
2068
- . zip ( new_stride_iter. by_ref ( ) )
2069
- {
2070
- /* update strides */
2071
- if * dr == * er {
2072
- /* keep stride */
2073
- * dr = * es;
2074
- } else if * er == 1 {
2075
- /* dead dimension, zero stride */
2076
- * dr = 0
2077
- } else {
2078
- return None ;
2079
- }
2080
- }
2081
-
2082
- /* set remaining strides to zero */
2083
- for dr in new_stride_iter {
2084
- * dr = 0 ;
2085
- }
2086
- }
2087
- Some ( new_stride)
2088
- }
2089
2039
let dim = dim. into_dimension ( ) ;
2090
2040
2091
2041
// Note: zero strides are safe precisely because we return an read-only view
0 commit comments