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
16 changes: 7 additions & 9 deletions lib/node_modules/@stdlib/blas/ext/base/dasumpw/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,18 @@ Computes the sum of absolute values ([_L1_ norm][l1norm]) of double-precision fl
var Float64Array = require( '@stdlib/array/float64' );

var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
var N = x.length;

var v = dasumpw( N, x, 1 );
var v = dasumpw( x.length, x, 1 );
// returns 5.0
```

The function has the following parameters:

- **N**: number of indexed elements.
- **x**: input [`Float64Array`][@stdlib/array/float64].
- **strideX**: index increment for `x`.
- **strideX**: stride length for `x`.

The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of absolute values of every other element in `x`,
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of absolute values of every other element:

```javascript
var Float64Array = require( '@stdlib/array/float64' );
Expand Down Expand Up @@ -104,17 +103,16 @@ Computes the sum of absolute values ([_L1_ norm][l1norm]) of double-precision fl
var Float64Array = require( '@stdlib/array/float64' );

var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
var N = x.length;

var v = dasumpw.ndarray( N, x, 1, 0 );
var v = dasumpw.ndarray( x.length, x, 1, 0 );
// returns 5.0
```

The function has the following additional parameters:

- **offsetX**: starting index for `x`.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the sum of absolute values of every other value in `x` starting from the second value
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the sum of absolute values of every other element starting from the second element:

```javascript
var Float64Array = require( '@stdlib/array/float64' );
Expand Down Expand Up @@ -204,7 +202,7 @@ The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] double*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.

```c
double stdlib_strided_dasumpw( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
Expand All @@ -225,7 +223,7 @@ The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] double*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.

```c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ static double benchmark1( int iterations, int len ) {
v = 0.0;
t = tic();
for ( i = 0; i < iterations; i++ ) {
// cppcheck-suppress uninitvar
v = stdlib_strided_dasumpw( len, x, 1 );
if ( v != v ) {
printf( "should not return NaN\n" );
Expand Down Expand Up @@ -140,6 +141,7 @@ static double benchmark2( int iterations, int len ) {
v = 0.0;
t = tic();
for ( i = 0; i < iterations; i++ ) {
// cppcheck-suppress uninitvar
v = stdlib_strided_dasumpw_ndarray( len, x, 1, 0 );
if ( v != v ) {
printf( "should not return NaN\n" );
Expand Down
15 changes: 6 additions & 9 deletions lib/node_modules/@stdlib/blas/ext/base/dasumpw/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
Input array.

strideX: integer
Index increment.
Stride length.

Returns
-------
Expand All @@ -34,19 +34,17 @@
> {{alias}}( x.length, x, 1 )
5.0

// Using `N` and `stride` parameters:
// Using `N` and stride parameters:
> x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> var stride = 2;
> {{alias}}( N, x, stride )
> {{alias}}( 3, x, stride )
5.0

// Using view offsets:
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
> stride = 2;
> {{alias}}( N, x1, stride )
> {{alias}}( 3, x1, stride )
5.0


Expand All @@ -68,7 +66,7 @@
Input array.

strideX: integer
Index increment.
Stride length.

offsetX: integer
Starting index.
Expand All @@ -87,8 +85,7 @@

// Using offset parameter:
> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}.ndarray( N, x, 2, 1 )
> {{alias}}.ndarray( 3, x, 2, 1 )
5.0

See Also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ var ndarray = require( './ndarray.js' );
* var Float64Array = require( '@stdlib/array/float64' );
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
* var N = x.length;
*
* var v = dasumpw( N, x, 1 );
* var v = dasumpw( x.length, x, 1 );
* // returns 5.0
*/
function dasumpw( N, x, strideX ) {
Expand Down
3 changes: 1 addition & 2 deletions lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
* var dasumpw = require( '@stdlib/blas/ext/base/dasumpw' );
*
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
* var N = x.length;
*
* var v = dasumpw( N, x, 1 );
* var v = dasumpw( x.length, x, 1 );
* // returns 5.0
*
* @example
Expand Down
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/blas/ext/base/dasumpw/lib/ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ function dasumpw( N, x, strideX, offsetX ) {
if ( N <= 0 ) {
return 0.0;
}
if ( N === 1 || strideX === 0 ) {
return abs( x[ offsetX ] );
}
ix = offsetX;
if ( strideX === 0 ) {
return N * abs( x[ ix ] );
}
if ( N < 8 ) {
// Use simple summation...
s = 0.0;
Expand Down Expand Up @@ -113,7 +113,7 @@ function dasumpw( N, x, strideX, offsetX ) {
ix += 8 * strideX;
}
// Pairwise sum the accumulators:
s = ((s0+s1) + (s2+s3)) + ((s4+s5) + (s6+s7));
s = ( (s0+s1) + (s2+s3) ) + ( (s4+s5) + (s6+s7) );

// Clean-up loop...
for ( i; i < N; i++ ) {
Expand Down
10 changes: 5 additions & 5 deletions lib/node_modules/@stdlib/blas/ext/base/dasumpw/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ double API_SUFFIX(stdlib_strided_dasumpw)( const CBLAS_INT N, const double *X, c
*
* @param N number of indexed elements
* @param X input array
* @param strideX index increment
* @param strideX stride length
* @param offsetX starting index
* @return output value
*/
double API_SUFFIX(stdlib_strided_dasumpw_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
double sum;
CBLAS_INT ix;
CBLAS_INT M;
CBLAS_INT n;
CBLAS_INT i;
double sum;
double s0;
double s1;
double s2;
Expand All @@ -77,10 +77,10 @@ double API_SUFFIX(stdlib_strided_dasumpw_ndarray)( const CBLAS_INT N, const doub
if ( N <= 0 ) {
return 0.0;
}
if ( N == 1 || strideX == 0 ) {
return stdlib_base_abs( X[ 0 ] );
}
ix = offsetX;
if ( strideX == 0 ) {
return N * stdlib_base_abs( X[ ix ] );
}
if ( N < 8 ) {
// Use simple summation...
sum = 0.0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,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 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 = dasumpw( 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 @@ -247,14 +247,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 first element repeated N times', opts, function test( t ) {
var x;
var v;

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

v = dasumpw( 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 @@ -156,14 +156,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 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 = dasumpw( 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 @@ -165,14 +165,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 first element repeated N times', opts, function test( t ) {
var x;
var v;

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

v = dasumpw( 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
Loading