Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import gcusumkbn = require( './index' );
const y = new Float64Array( 10 );

gcusumkbn( x.length, 0.0, x, 1, y, 1 ); // $ExpectType Float64Array
gcusumkbn( x.length, 0.0, new AccessorArray( x ), 1, new AccessorArray( y ), 1 ); // $ExpectType AccessorArray
gcusumkbn( x.length, 0.0, new AccessorArray( x ), 1, new AccessorArray( y ), 1 ); // $ExpectType AccessorArray<number>
}

// The compiler throws an error if the function is provided a first argument which is not a number...
Expand Down Expand Up @@ -142,7 +142,7 @@ import gcusumkbn = require( './index' );
const y = new Float64Array( 10 );

gcusumkbn.ndarray( x.length, 0.0, x, 1, 0, y, 1, 0 ); // $ExpectType Float64Array
gcusumkbn.ndarray( x.length, 0.0, new AccessorArray( x ), 1, 0, new AccessorArray( y ), 1, 0 ); // $ExpectType AccessorArray
gcusumkbn.ndarray( x.length, 0.0, new AccessorArray( x ), 1, 0, new AccessorArray( y ), 1, 0 ); // $ExpectType AccessorArray<number>
}

// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ var abs = require( '@stdlib/math/base/special/abs' );
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
*
* var x = toAccessorArray( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
* var y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
*
* gcusumkbn( 4, 0.0, arraylike2object( x ), 2, 1, arraylike2object( y ), 1, 0 );
* gcusumkbn( 4, 0.0, arraylike2object( toAccessorArray( x ) ), 2, 1, arraylike2object( toAccessorArray( y ) ), 1, 0 );
* // y => [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ]
*/
function gcusumkbn( N, sum, x, strideX, offsetX, y, strideY, offsetY ) {
var xbuf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ function gcusumkbn( N, sum, x, strideX, offsetX, y, strideY, offsetY ) {
ox = arraylike2object( x );
oy = arraylike2object( y );
if ( ox.accessorProtocol || oy.accessorProtocol ) {
return accessors( N, sum, ox, strideX, offsetX, oy, strideY, offsetY );
accessors( N, sum, ox, strideX, offsetX, oy, strideY, offsetY );
return y;
}
ix = offsetX;
iy = offsetY;
Expand Down
14 changes: 14 additions & 0 deletions lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];

gcusumkbn( x.length, 0.0, toAccessorArray( x ), 1, toAccessorArray( y ), 1 );

Check warning on line 140 in lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 81. Maximum allowed is 80
expected = [
1.0,
3.0,
Expand All @@ -150,7 +150,7 @@
x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];

gcusumkbn( x.length, 10.0, toAccessorArray( x ), 1, toAccessorArray( y ), 1 );

Check warning on line 153 in lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 82. Maximum allowed is 80
expected = [
11.0,
13.0,
Expand All @@ -162,7 +162,7 @@

x = [ NaN, NaN ];
y = [ 0.0, 0.0 ];
gcusumkbn( x.length, 0.0, toAccessorArray( x ), 1, toAccessorArray( y ), 1 );

Check warning on line 165 in lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 81. Maximum allowed is 80

for ( i = 0; i < y.length; i++ ) {
t.strictEqual( isnan( y[ i ] ), true, 'returns expected value. i: ' + i );
Expand All @@ -170,7 +170,7 @@

x = [ 1.0, NaN, 3.0, NaN ];
y = [ 0.0, 0.0, 0.0, 0.0 ];
gcusumkbn( x.length, 0.0, toAccessorArray( x ), 1, toAccessorArray( y ), 1 );

Check warning on line 173 in lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 81. Maximum allowed is 80

expected = [
1.0,
Expand All @@ -188,7 +188,7 @@

x = [ 1.0, 1.0e100, 1.0, -1.0e100 ];
y = [ 0.0, 0.0, 0.0, 0.0 ];
gcusumkbn( x.length, 0.0, toAccessorArray( x ), 1, toAccessorArray( y ), 1 );

Check warning on line 191 in lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 81. Maximum allowed is 80

expected = [
1.0,
Expand All @@ -210,7 +210,7 @@
expected.push( expected[ i-1 ] + x[ i ] );
}
}
gcusumkbn( x.length, 0.0, toAccessorArray( x ), 1, toAccessorArray( y ), 1 );

Check warning on line 213 in lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 81. Maximum allowed is 80
t.deepEqual( y, expected, 'returns expected value' );

t.end();
Expand All @@ -230,6 +230,20 @@
t.end();
});

tape( 'the function returns a reference to the output array (accessors)', function test( t ) {
var out;
var x;
var y;

x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] );

out = gcusumkbn( x.length, 0.0, x, 1, y, 1 );

t.strictEqual( out, y, 'same reference' );
t.end();
});

tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) {
var expected;
var x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];

gcusumkbn( x.length, 0.0, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 );

Check warning on line 138 in lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.ndarray.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 87. Maximum allowed is 80
expected = [
1.0,
3.0,
Expand All @@ -148,7 +148,7 @@
x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];

gcusumkbn( x.length, 10.0, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 );

Check warning on line 151 in lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.ndarray.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 88. Maximum allowed is 80
expected = [
11.0,
13.0,
Expand All @@ -160,7 +160,7 @@

x = [ NaN, NaN ];
y = [ 0.0, 0.0 ];
gcusumkbn( x.length, 0.0, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 );

Check warning on line 163 in lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.ndarray.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 87. Maximum allowed is 80

for ( i = 0; i < y.length; i++ ) {
t.strictEqual( isnan( y[ i ] ), true, 'returns expected value. i: ' + i );
Expand All @@ -168,7 +168,7 @@

x = [ 1.0, NaN, 3.0, NaN ];
y = [ 0.0, 0.0, 0.0, 0.0 ];
gcusumkbn( x.length, 0.0, toAccessorArray( x ), 1, 0, toAccessorArray( y ), 1, 0 );

Check warning on line 171 in lib/node_modules/@stdlib/blas/ext/base/gcusumkbn/test/test.ndarray.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 87. Maximum allowed is 80

expected = [
1.0,
Expand Down Expand Up @@ -227,6 +227,20 @@
t.end();
});

tape( 'the function returns a reference to the output array (accessors)', function test( t ) {
var out;
var x;
var y;

x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
y = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] );

out = gcusumkbn( x.length, 0.0, x, 1, 0, y, 1, 0 );

t.strictEqual( out, y, 'same reference' );
t.end();
});

tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `y` unchanged', function test( t ) {
var expected;
var x;
Expand Down