Skip to content

Commit a013e07

Browse files
committed
Fix bug when provided arrays having different orders
1 parent 59dce08 commit a013e07

File tree

1 file changed

+3
-3
lines changed
  • lib/node_modules/@stdlib/ndarray/base/unary/src

1 file changed

+3
-3
lines changed

lib/node_modules/@stdlib/ndarray/base/unary/src/dispatch.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ int8_t stdlib_ndarray_unary_dispatch( const struct ndarrayUnaryDispatchObject *o
335335
io2 = stdlib_ndarray_iteration_order( ndims, s2 ); // +/-1
336336

337337
// Determine whether we can avoid blocked iteration...
338-
if ( io1 != 0 && io2 != 0 ) {
338+
if ( io1 != 0 && io2 != 0 && stdlib_ndarray_order( x1 ) == stdlib_ndarray_order( x2 )) {
339339
// Determine the minimum and maximum linear byte indices which are accessible by the array views:
340340
mib1 = stdlib_ndarray_offset( x1 ); // byte offset
341341
mab1 = mib1;
@@ -370,14 +370,14 @@ int8_t stdlib_ndarray_unary_dispatch( const struct ndarrayUnaryDispatchObject *o
370370
// At least one ndarray is non-contiguous, so we cannot directly use strided array functionality...
371371

372372
// Determine whether we can use simple nested loops...
373-
if ( stdlib_ndarray_order( x1 ) == stdlib_ndarray_order( x2 ) && ndims < (obj->nfunctions) ) {
373+
if ( ndims < (obj->nfunctions) ) {
374374
// So long as iteration for each respective array always moves in the same direction (i.e., no mixed sign strides), we can leverage cache-optimal (i.e., normal) nested loops without resorting to blocked iteration...
375375
obj->functions[ ndims ]( arrays, fcn );
376376
return 0;
377377
}
378378
// Fall-through to blocked iteration...
379379
}
380-
// At this point, we're either dealing with non-contiguous n-dimensional arrays and/or high dimensional n-dimensional arrays, so our only hope is that we can still perform blocked iteration...
380+
// At this point, we're either dealing with non-contiguous n-dimensional arrays, high dimensional n-dimensional arrays, and/or arrays having differing memory layouts, so our only hope is that we can still perform blocked iteration...
381381

382382
// Determine whether we can perform blocked iteration...
383383
if ( ndims <= (obj->nblockedfunctions)+1 ) {

0 commit comments

Comments
 (0)