Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jul 6, 2024
1 parent 44686d5 commit f6a8f48
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 107 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

<details>

- [`e47b1be`](https://github.com/stdlib-js/stdlib/commit/e47b1be3a80eb9a7ab1fa9f421a133a580ce4366) - **refactor:** reduce code duplication _(by Athan Reines)_
- [`dc36936`](https://github.com/stdlib-js/stdlib/commit/dc369364ee617f8f62b40d951a0f0d34f795da6e) - **feat:** add boolean dtype support to `strided/base/mskunary` [(#2520)](https://github.com/stdlib-js/stdlib/pull/2520) _(by Jaysukh Makvana)_
- [`cf3f92e`](https://github.com/stdlib-js/stdlib/commit/cf3f92eddd20ec1a4106c8a34f7d7705a9a99dbc) - **fix:** update include paths _(by Athan Reines)_
- [`75d4f83`](https://github.com/stdlib-js/stdlib/commit/75d4f83cb85610d23a04dc21a03f8075f6d3665f) - **refactor:** update require and include paths _(by Athan Reines)_
Expand Down
26 changes: 13 additions & 13 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dist/index.js.map

Large diffs are not rendered by default.

61 changes: 13 additions & 48 deletions lib/accessors.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

'use strict';

// MODULES //

var stride2offset = require( '@stdlib/strided-base-stride2offset' );
var ndarray = require( './accessors.ndarray.js' );


// MAIN //

/**
Expand Down Expand Up @@ -63,57 +69,16 @@
* // => <Float64Array>[ 20.0, 40.0, 0.0, 80.0, 100.0 ]
*/
function mskunary( arrays, shape, strides, accessors, fcn ) {
var xget;
var mget;
var yset;
var sx;
var sm;
var sy;
var ix;
var im;
var iy;
var x;
var m;
var y;
var offsets;
var N;
var i;

N = shape[ 0 ];
if ( N <= 0 ) {
return;
}
sx = strides[ 0 ];
sm = strides[ 1 ];
sy = strides[ 2 ];
if ( sx < 0 ) {
ix = (1-N) * sx;
} else {
ix = 0;
}
if ( sm < 0 ) {
im = (1-N) * sm;
} else {
im = 0;
}
if ( sy < 0 ) {
iy = (1-N) * sy;
} else {
iy = 0;
}
x = arrays[ 0 ];
m = arrays[ 1 ];
y = arrays[ 2 ];
xget = accessors[ 0 ];
mget = accessors[ 1 ];
yset = accessors[ 2 ];
for ( i = 0; i < N; i++ ) {
if ( mget( m, im ) === 0 ) {
yset( y, iy, fcn( xget( x, ix ) ) );
}
ix += sx;
im += sm;
iy += sy;
}
offsets = [
stride2offset( N, strides[ 0 ] ),
stride2offset( N, strides[ 1 ] ),
stride2offset( N, strides[ 2 ] )
];
return ndarray( arrays, shape, strides, offsets, accessors, fcn );
}


Expand Down
55 changes: 13 additions & 42 deletions lib/unary.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@

'use strict';

// MODULES //

var stride2offset = require( '@stdlib/strided-base-stride2offset' );
var ndarray = require( './unary.ndarray.js' );


// MAIN //

/**
Expand Down Expand Up @@ -51,51 +57,16 @@
* // => <Float64Array>[ 10.0, 20.0, 0.0, 40.0, 50.0 ]
*/
function mskunary( arrays, shape, strides, fcn ) {
var sx;
var sm;
var sy;
var ix;
var im;
var iy;
var x;
var m;
var y;
var offsets;
var N;
var i;

N = shape[ 0 ];
if ( N <= 0 ) {
return;
}
sx = strides[ 0 ];
sm = strides[ 1 ];
sy = strides[ 2 ];
if ( sx < 0 ) {
ix = (1-N) * sx;
} else {
ix = 0;
}
if ( sm < 0 ) {
im = (1-N) * sm;
} else {
im = 0;
}
if ( sy < 0 ) {
iy = (1-N) * sy;
} else {
iy = 0;
}
x = arrays[ 0 ];
m = arrays[ 1 ];
y = arrays[ 2 ];
for ( i = 0; i < N; i++ ) {
if ( m[ im ] === 0 ) {
y[ iy ] = fcn( x[ ix ] );
}
ix += sx;
im += sm;
iy += sy;
}
offsets = [
stride2offset( N, strides[ 0 ] ),
stride2offset( N, strides[ 1 ] ),
stride2offset( N, strides[ 2 ] )
];
return ndarray( arrays, shape, strides, offsets, fcn );
}


Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@stdlib/array-dtype": "^0.2.1",
"@stdlib/complex-float32-ctor": "^0.0.1",
"@stdlib/complex-float64-ctor": "^0.0.1",
"@stdlib/strided-base-stride2offset": "github:stdlib-js/strided-base-stride2offset#main",
"@stdlib/types": "^0.3.2",
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1",
"@stdlib/utils-library-manifest": "^0.2.1"
Expand Down

0 comments on commit f6a8f48

Please sign in to comment.