Skip to content

Commit e5b8613

Browse files
committed
Infer order from strides array
1 parent b6f08d4 commit e5b8613

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/node_modules/@stdlib/ndarray/ctor/manifest.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@stdlib/ndarray/base/dtype-char",
3838
"@stdlib/ndarray/base/iteration-order",
3939
"@stdlib/ndarray/base/numel",
40+
"@stdlib/ndarray/base/strides2order",
4041
"@stdlib/ndarray/dtypes",
4142
"@stdlib/ndarray/orders"
4243
]

lib/node_modules/@stdlib/ndarray/ctor/src/ndarray.c

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "stdlib/ndarray_iteration_order.h"
2525
#include "stdlib/ndarray_numel.h"
2626
#include "stdlib/ndarray_orders.h"
27+
#include "stdlib/ndarray_strides2order.h"
2728
#include "stdlib/ndarray.h"
2829

2930
/**
@@ -83,6 +84,8 @@
8384
* free( x );
8485
*/
8586
struct ndarray * stdlib_ndarray_constructor( uint8_t *data, uint64_t ndims, int64_t *shape, int64_t *strides, uint64_t offset, enum STDLIB_NDARRAY_ORDER order, enum STDLIB_NDARRAY_DTYPE dtype ) {
87+
uint8_t ord;
88+
8689
struct ndarray *arr = malloc( sizeof( struct ndarray ) );
8790
if ( arr == NULL ) {
8891
return NULL;
@@ -102,6 +105,9 @@ struct ndarray * stdlib_ndarray_constructor( uint8_t *data, uint64_t ndims, int6
102105
arr->ltr = stdlib_ndarray_dtype_char( dtype );
103106
arr->_iterationOrder = stdlib_ndarray_iteration_order( ndims, strides );
104107

108+
// Infer the array "order" from the stride array (this is supplementary to the `order` parameter):
109+
ord = stdlib_ndarray_strides2order( ndims, strides );
110+
105111
// TODO: compute flags
106112

107113
return arr;

0 commit comments

Comments
 (0)