Skip to content

Commit

Permalink
fix: apply code review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
headlessNode committed Oct 3, 2024
1 parent de4db91 commit 39e4cb9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ function dnanasumors( N, x, strideX, offsetX ) {
if ( N <= 0 ) {
return 0.0;
}
if ( N === 1 || strideX === 0 ) {
if ( strideX === 0 ) {
if ( isnan( x[ offsetX ] ) ) {
return 0.0;
}
return abs( x[ offsetX ] );
return abs( x[ offsetX ] * N );
}
ix = offsetX;
sum = 0.0;
Expand Down
6 changes: 3 additions & 3 deletions lib/node_modules/@stdlib/blas/ext/base/dnanasumors/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ double API_SUFFIX(stdlib_strided_dnanasumors_ndarray)( const CBLAS_INT N, const
if ( N <= 0 ) {
return 0.0;
}
if ( N == 1 || strideX == 0 ) {
if ( stdlib_base_is_nan( X[ 0 ] ) ) {
if ( strideX == 0 ) {
if ( stdlib_base_is_nan( X[ offsetX ] ) ) {
return 0.0;
}
return stdlib_base_abs( X[ 0 ] );
return stdlib_base_abs( X[ offsetX ] * N );
}
ix = offsetX;
sum = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
t.end();
});

tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element', function test( t ) {
tape( 'if provided a `stride` parameter equal to `0`, the function returns the sum of the first element repeated N times', function test( t ) {
var x;
var v;

x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );

v = dnanasumors( x.length, x, 0 );
t.strictEqual( v, 1.0, 'returns expected value' );
t.strictEqual( v, 5.0, 'returns expected value' );

t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
t.end();
});

tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element', opts, function test( t ) {
tape( 'if provided a `stride` parameter equal to `0`, the function returns the sum of the first element repeated N times', function test( t ) {
var x;
var v;

x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );

v = dnanasumors( x.length, x, 0 );
t.strictEqual( v, 1.0, 'returns expected value' );
t.strictEqual( v, 5.0, 'returns expected value' );

t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
t.end();
});

tape( 'if provided a `stride` parameter equal to `0`, the function returns the first indexed element', function test( t ) {
tape( 'if provided a `stride` parameter equal to `0`, the function returns the sum of the first element repeated N times', function test( t ) {
var x;
var v;

x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );

v = dnanasumors( x.length, x, 0, 0 );
t.strictEqual( v, 1.0, 'returns expected value' );
t.strictEqual( v, 5.0, 'returns expected value' );

t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
t.end();
});

tape( 'if provided a `stride` parameter equal to `0`, the function returns the first indexed element', opts, function test( t ) {
tape( 'if provided a `stride` parameter equal to `0`, the function returns the sum of the first element repeated N times', function test( t ) {
var x;
var v;

x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );

v = dnanasumors( x.length, x, 0, 0 );
t.strictEqual( v, 1.0, 'returns expected value' );
t.strictEqual( v, 5.0, 'returns expected value' );

t.end();
});
Expand Down

0 comments on commit 39e4cb9

Please sign in to comment.