File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -106,8 +106,14 @@ where
106106 out. zip_mut_with_same_shape( rhs, clone_iopf( A :: $mth) ) ;
107107 out
108108 } else {
109- let ( lhs, rhs) = self . broadcast_with( rhs) . unwrap( ) ;
110- Zip :: from( & lhs) . and( & rhs) . map_collect_owned( clone_opf( A :: $mth) )
109+ let ( lhs_view, rhs_view) = self . broadcast_with( & rhs) . unwrap( ) ;
110+ if lhs_view. shape( ) == self . shape( ) {
111+ let mut out = self . into_dimensionality:: <<D as DimMax <E >>:: Output >( ) . unwrap( ) ;
112+ out. zip_mut_with_same_shape( & rhs_view, clone_iopf( A :: $mth) ) ;
113+ out
114+ } else {
115+ Zip :: from( & lhs_view) . and( & rhs_view) . map_collect_owned( clone_opf( A :: $mth) )
116+ }
111117 }
112118 }
113119}
@@ -141,8 +147,14 @@ where
141147 out. zip_mut_with_same_shape( self , clone_iopf_rev( A :: $mth) ) ;
142148 out
143149 } else {
144- let ( rhs, lhs) = rhs. broadcast_with( self ) . unwrap( ) ;
145- Zip :: from( & lhs) . and( & rhs) . map_collect_owned( clone_opf( A :: $mth) )
150+ let ( rhs_view, lhs_view) = rhs. broadcast_with( self ) . unwrap( ) ;
151+ if rhs_view. shape( ) == rhs. shape( ) {
152+ let mut out = rhs. into_dimensionality:: <<E as DimMax <D >>:: Output >( ) . unwrap( ) ;
153+ out. zip_mut_with_same_shape( & lhs_view, clone_iopf_rev( A :: $mth) ) ;
154+ out
155+ } else {
156+ Zip :: from( & lhs_view) . and( & rhs_view) . map_collect_owned( clone_opf( A :: $mth) )
157+ }
146158 }
147159 }
148160}
You can’t perform that action at this time.
0 commit comments