Skip to content

refactor: rename variable in blas/base/sasumpw #7212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025
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
28 changes: 14 additions & 14 deletions lib/node_modules/@stdlib/blas/ext/base/sasumpw/lib/ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// MODULES //

var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
var f32 = require( '@stdlib/number/float64/base/to-float32' );
var floor = require( '@stdlib/math/base/special/floor' );
var absf = require( '@stdlib/math/base/special/absf' );

Expand Down Expand Up @@ -78,13 +78,13 @@ function sasumpw( N, x, strideX, offsetX ) {
}
ix = offsetX;
if ( strideX === 0 ) {
return float64ToFloat32( N * absf( x[ ix ] ) );
return f32( N * absf( x[ ix ] ) );
}
if ( N < 8 ) {
// Use simple summation...
s = 0.0;
for ( i = 0; i < N; i++ ) {
s = float64ToFloat32( s + absf( x[ ix ] ) );
s = f32( s + absf( x[ ix ] ) );
ix += strideX;
}
return s;
Expand All @@ -103,30 +103,30 @@ function sasumpw( N, x, strideX, offsetX ) {

M = N % 8;
for ( i = 8; i < N-M; i += 8 ) {
s0 = float64ToFloat32( s0 + absf( x[ ix ] ) );
s1 = float64ToFloat32( s1 + absf( x[ ix+strideX ] ) );
s2 = float64ToFloat32( s2 + absf( x[ ix+(2*strideX) ] ) );
s3 = float64ToFloat32( s3 + absf( x[ ix+(3*strideX) ] ) );
s4 = float64ToFloat32( s4 + absf( x[ ix+(4*strideX) ] ) );
s5 = float64ToFloat32( s5 + absf( x[ ix+(5*strideX) ] ) );
s6 = float64ToFloat32( s6 + absf( x[ ix+(6*strideX) ] ) );
s7 = float64ToFloat32( s7 + absf( x[ ix+(7*strideX) ] ) );
s0 = f32( s0 + absf( x[ ix ] ) );
s1 = f32( s1 + absf( x[ ix+strideX ] ) );
s2 = f32( s2 + absf( x[ ix+(2*strideX) ] ) );
s3 = f32( s3 + absf( x[ ix+(3*strideX) ] ) );
s4 = f32( s4 + absf( x[ ix+(4*strideX) ] ) );
s5 = f32( s5 + absf( x[ ix+(5*strideX) ] ) );
s6 = f32( s6 + absf( x[ ix+(6*strideX) ] ) );
s7 = f32( s7 + absf( x[ ix+(7*strideX) ] ) );
ix += 8 * strideX;
}
// Pairwise sum the accumulators:
s = float64ToFloat32( float64ToFloat32( float64ToFloat32(s0+s1) + float64ToFloat32(s2+s3) ) + float64ToFloat32( float64ToFloat32(s4+s5) + float64ToFloat32(s6+s7) ) ); // eslint-disable-line max-len
s = f32( f32( f32(s0+s1) + f32(s2+s3) ) + f32( f32(s4+s5) + f32(s6+s7) ) ); // eslint-disable-line max-len

// Clean-up loop...
for ( i; i < N; i++ ) {
s = float64ToFloat32( s + absf( x[ ix ] ) );
s = f32( s + absf( x[ ix ] ) );
ix += strideX;
}
return s;
}
// Recurse by dividing by two, but avoiding non-multiples of unroll factor...
n = floor( N/2 );
n -= n % 8;
return float64ToFloat32( sasumpw( n, x, strideX, ix ) + sasumpw( N-n, x, strideX, ix+(n*strideX) ) ); // eslint-disable-line max-len
return f32( sasumpw( n, x, strideX, ix ) + sasumpw( N-n, x, strideX, ix+(n*strideX) ) ); // eslint-disable-line max-len
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var tape = require( 'tape' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var Float32Array = require( '@stdlib/array/float32' );
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
var f32 = require( '@stdlib/number/float64/base/to-float32' );
var sasumpw = require( './../lib/ndarray.js' );


Expand Down Expand Up @@ -63,7 +63,7 @@ tape( 'the function calculates the sum of all strided array elements', function

x = new Float32Array( [ 1.0, 1.0e38, 1.0, -1.0e38 ] );
v = sasumpw( x.length, x, 1, 0 );
t.strictEqual( v, float64ToFloat32( 2.0e38 ), 'returns expected value' );
t.strictEqual( v, f32( 2.0e38 ), 'returns expected value' );

x = new Float32Array( 1e3 );
for ( i = 0; i < 1e3; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var Float32Array = require( '@stdlib/array/float32' );
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
var f32 = require( '@stdlib/number/float64/base/to-float32' );
var tryRequire = require( '@stdlib/utils/try-require' );


Expand Down Expand Up @@ -72,7 +72,7 @@ tape( 'the function calculates the sum of all strided array elements', opts, fun

x = new Float32Array( [ 1.0, 1.0e38, 1.0, -1.0e38 ] );
v = sasumpw( x.length, x, 1, 0 );
t.strictEqual( v, float64ToFloat32( 2.0e38 ), 'returns expected value' );
t.strictEqual( v, f32( 2.0e38 ), 'returns expected value' );

x = new Float32Array( 1e3 );
for ( i = 0; i < 1e3; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var tape = require( 'tape' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var Float32Array = require( '@stdlib/array/float32' );
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
var f32 = require( '@stdlib/number/float64/base/to-float32' );
var sasumpw = require( './../lib/sasumpw.js' );


Expand Down Expand Up @@ -63,7 +63,7 @@ tape( 'the function calculates the sum of absolute values', function test( t ) {

x = new Float32Array( [ 1.0, 1.0e38, 1.0, -1.0e38 ] );
v = sasumpw( x.length, x, 1 );
t.strictEqual( v, float64ToFloat32( 2.0e38 ), 'returns expected value' );
t.strictEqual( v, f32( 2.0e38 ), 'returns expected value' );

x = new Float32Array( 1e3 );
for ( i = 0; i < 1e3; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var Float32Array = require( '@stdlib/array/float32' );
var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
var f32 = require( '@stdlib/number/float64/base/to-float32' );
var tryRequire = require( '@stdlib/utils/try-require' );


Expand Down Expand Up @@ -154,7 +154,7 @@ tape( 'the function calculates the sum of all strided array elements', opts, fun

x = new Float32Array( [ 1.0, 1.0e38, 1.0, -1.0e38 ] );
v = sasumpw( x.length, x, 1 );
t.strictEqual( v, float64ToFloat32( 2.0e38 ), 'returns expected value' );
t.strictEqual( v, f32( 2.0e38 ), 'returns expected value' );

x = new Float32Array( 1e3 );
for ( i = 0; i < 1e3; i++ ) {
Expand Down