Skip to content

Commit

Permalink
feat: add support for accessor strided arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Nov 23, 2023
1 parent e8ca7bf commit be9d624
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/node_modules/@stdlib/array/base/strided2array4d/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@

'use strict';

// MODULES //

var resolveGetter = require( '@stdlib/array/base/resolve-getter' );


// MAIN //

/**
Expand Down Expand Up @@ -46,6 +51,7 @@
* // returns [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ]
*/
function strided2array4d( x, shape, strides, offset ) {
var get;
var out;
var dx0;
var dx1;
Expand All @@ -66,6 +72,8 @@ function strided2array4d( x, shape, strides, offset ) {
var t2;
var t1;

get = resolveGetter( x );

S3 = shape[ 0 ];
S2 = shape[ 1 ];
S1 = shape[ 2 ];
Expand All @@ -87,7 +95,7 @@ function strided2array4d( x, shape, strides, offset ) {
t1 = [];
ix0 = ix1 + ( dx1*i1 );
for ( i0 = 0; i0 < S0; i0++ ) {
t1.push( x[ ix0 ] );
t1.push( get( x, ix0 ) );
ix0 += dx0;
}
t2.push( t1 );
Expand Down

0 comments on commit be9d624

Please sign in to comment.