Skip to content

Commit 49f4678

Browse files
authored
chore: update docs and tests of blas/ext/base/dapxsum
PR-URL: #3213 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent f4009fd commit 49f4678

File tree

14 files changed

+36
-38
lines changed

14 files changed

+36
-38
lines changed

lib/node_modules/@stdlib/blas/ext/base/dapxsum/README.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ Adds a scalar constant to each double-precision floating-point strided array ele
4444
var Float64Array = require( '@stdlib/array/float64' );
4545

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

49-
var v = dapxsum( N, 5.0, x, 1 );
48+
var v = dapxsum( x.length, 5.0, x, 1 );
5049
// returns 16.0
5150
```
5251

@@ -55,9 +54,9 @@ The function has the following parameters:
5554
- **N**: number of indexed elements.
5655
- **alpha**: scalar constant.
5756
- **x**: input [`Float64Array`][@stdlib/array/float64].
58-
- **strideX**: index increment for `x`.
57+
- **strideX**: stride length for `x`.
5958

60-
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element in `x`,
59+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element:
6160

6261
```javascript
6362
var Float64Array = require( '@stdlib/array/float64' );
@@ -90,17 +89,16 @@ Adds a scalar constant to each double-precision floating-point strided array ele
9089
var Float64Array = require( '@stdlib/array/float64' );
9190

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

95-
var v = dapxsum.ndarray( N, 5.0, x, 1, 0 );
93+
var v = dapxsum.ndarray( x.length, 5.0, x, 1, 0 );
9694
// returns 16.0
9795
```
9896

9997
The function has the following additional parameters:
10098

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

103-
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 access every other value in `x` starting from the second value
101+
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 access every element starting from the second element:
104102

105103
```javascript
106104
var Float64Array = require( '@stdlib/array/float64' );
@@ -190,7 +188,7 @@ The function accepts the following arguments:
190188
- **N**: `[in] CBLAS_INT` number of indexed elements.
191189
- **alpha**: `[in] double` scalar constant.
192190
- **X**: `[in] double*` input array.
193-
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
191+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
194192
195193
```c
196194
double stdlib_strided_dapxsum( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX );
@@ -212,7 +210,7 @@ The function accepts the following arguments:
212210
- **N**: `[in] CBLAS_INT` number of indexed elements.
213211
- **alpha**: `[in] double` scalar constant.
214212
- **X**: `[in] double*` input array.
215-
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
213+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
216214
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
217215
218216
```c

lib/node_modules/@stdlib/blas/ext/base/dapxsum/benchmark/c/benchmark.length.c

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ static double benchmark1( int iterations, int len ) {
107107
v = 0.0;
108108
t = tic();
109109
for ( i = 0; i < iterations; i++ ) {
110+
// cppcheck-suppress uninitvar
110111
v = stdlib_strided_dapxsum( len, 5.0, x, 1 );
111112
if ( v != v ) {
112113
printf( "should not return NaN\n" );
@@ -140,6 +141,7 @@ static double benchmark2( int iterations, int len ) {
140141
v = 0.0;
141142
t = tic();
142143
for ( i = 0; i < iterations; i++ ) {
144+
// cppcheck-suppress uninitvar
143145
v = stdlib_strided_dapxsum_ndarray( len, 5.0, x, 1, 0 );
144146
if ( v != v ) {
145147
printf( "should not return NaN\n" );

lib/node_modules/@stdlib/blas/ext/base/dapxsum/docs/repl.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Adds a scalar constant to each double-precision floating-point strided
44
array element and computes the sum.
55

6-
The `N` and stride parameters determine which elements in the strided
7-
array are accessed at runtime.
6+
The `N` and stride parameters determine which elements in the strided array
7+
are accessed at runtime.
88

99
Indexing is relative to the first index. To introduce an offset, use a typed
1010
array view.
@@ -17,13 +17,13 @@
1717
Number of indexed elements.
1818

1919
alpha: number
20-
Constant.
20+
Scalar constant.
2121

2222
x: Float64Array
2323
Input array.
2424

2525
strideX: integer
26-
Index increment.
26+
Stride length.
2727

2828
Returns
2929
-------
@@ -63,13 +63,13 @@
6363
Number of indexed elements.
6464

6565
alpha: number
66-
Constant.
66+
Scalar constant.
6767

6868
x: Float64Array
6969
Input array.
7070

7171
strideX: integer
72-
Index increment.
72+
Stride length.
7373

7474
offsetX: integer
7575
Starting index.

lib/node_modules/@stdlib/blas/ext/base/dapxsum/docs/types/index.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface Routine {
2626
* Adds a scalar constant to each double-precision floating-point strided array element and computes the sum.
2727
*
2828
* @param N - number of indexed elements
29-
* @param alpha - constant
29+
* @param alpha - scalar constant
3030
* @param x - input array
3131
* @param strideX - stride length
3232
* @returns sum
@@ -45,7 +45,7 @@ interface Routine {
4545
* Adds a scalar constant to each double-precision floating-point strided array element and computes the sum using alternative indexing semantics.
4646
*
4747
* @param N - number of indexed elements
48-
* @param alpha - constant
48+
* @param alpha - scalar constant
4949
* @param x - input array
5050
* @param strideX - stride length
5151
* @param offsetX - starting index
@@ -66,7 +66,7 @@ interface Routine {
6666
* Adds a scalar constant to each double-precision floating-point strided array element and computes the sum.
6767
*
6868
* @param N - number of indexed elements
69-
* @param alpha - constant
69+
* @param alpha - scalar constant
7070
* @param x - input array
7171
* @param strideX - stride length
7272
* @returns sum

lib/node_modules/@stdlib/blas/ext/base/dapxsum/examples/c/example.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ int main( void ) {
2727
const int N = 4;
2828

2929
// Specify the stride length:
30-
const int stride = 2;
30+
const int strideX = 2;
3131

3232
// Compute the sum:
33-
double v = stdlib_strided_dapxsum( N, 5.0, x, stride );
33+
double v = stdlib_strided_dapxsum( N, 5.0, x, strideX );
3434

3535
// Print the result:
3636
printf( "sum: %lf\n", v );

lib/node_modules/@stdlib/blas/ext/base/dapxsum/lib/dapxsum.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var ndarray = require( './ndarray.js' );
3030
* Adds a scalar constant to each double-precision floating-point strided array element and computes the sum.
3131
*
3232
* @param {PositiveInteger} N - number of indexed elements
33-
* @param {number} alpha - constant
33+
* @param {number} alpha - scalar constant
3434
* @param {Float64Array} x - input array
3535
* @param {integer} strideX - stride length
3636
* @returns {number} sum
@@ -39,9 +39,8 @@ var ndarray = require( './ndarray.js' );
3939
* var Float64Array = require( '@stdlib/array/float64' );
4040
*
4141
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
42-
* var N = x.length;
4342
*
44-
* var v = dapxsum( N, 5.0, x, 1 );
43+
* var v = dapxsum( x.length, 5.0, x, 1 );
4544
* // returns 16.0
4645
*/
4746
function dapxsum( N, alpha, x, strideX ) {

lib/node_modules/@stdlib/blas/ext/base/dapxsum/lib/dapxsum.native.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var addon = require( './../src/addon.node' );
2929
* Adds a scalar constant to each double-precision floating-point strided array element and computes the sum.
3030
*
3131
* @param {PositiveInteger} N - number of indexed elements
32-
* @param {number} alpha - constant
32+
* @param {number} alpha - scalar constant
3333
* @param {Float64Array} x - input array
3434
* @param {integer} strideX - stride length
3535
* @returns {number} sum
@@ -38,9 +38,8 @@ var addon = require( './../src/addon.node' );
3838
* var Float64Array = require( '@stdlib/array/float64' );
3939
*
4040
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
41-
* var N = x.length;
4241
*
43-
* var v = dapxsum( N, 5.0, x, 1 );
42+
* var v = dapxsum( x.length, 5.0, x, 1 );
4443
* // returns 16.0
4544
*/
4645
function dapxsum( N, alpha, x, strideX ) {

lib/node_modules/@stdlib/blas/ext/base/dapxsum/lib/ndarray.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var dapxsumkbn = require( '@stdlib/blas/ext/base/dapxsumkbn' ).ndarray;
2929
* Adds a scalar constant to each double-precision floating-point strided array element and computes the sum.
3030
*
3131
* @param {PositiveInteger} N - number of indexed elements
32-
* @param {number} alpha - constant
32+
* @param {number} alpha - scalar constant
3333
* @param {Float64Array} x - input array
3434
* @param {integer} strideX - stride length
3535
* @param {NonNegativeInteger} offsetX - starting index

lib/node_modules/@stdlib/blas/ext/base/dapxsum/lib/ndarray.native.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var addon = require( './../src/addon.node' );
2929
* Adds a scalar constant to each double-precision floating-point strided array element and computes the sum.
3030
*
3131
* @param {PositiveInteger} N - number of indexed elements
32-
* @param {number} alpha - constant
32+
* @param {number} alpha - scalar constant
3333
* @param {Float64Array} x - input array
3434
* @param {integer} strideX - stride length
3535
* @param {NonNegativeInteger} offsetX - starting index

lib/node_modules/@stdlib/blas/ext/base/dapxsum/src/main.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ double API_SUFFIX(stdlib_strided_dapxsum)( const CBLAS_INT N, const double alpha
4141
* @param N number of indexed elements
4242
* @param alpha scalar constant
4343
* @param X input array
44-
* @param strideX index increment
45-
* @param offsetX index offset
44+
* @param strideX stride length
45+
* @param offsetX starting index
4646
* @return output value
4747
*/
4848
double API_SUFFIX(stdlib_strided_dapxsum_ndarray)( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {

lib/node_modules/@stdlib/blas/ext/base/dapxsum/test/test.dapxsum.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
135135
t.end();
136136
});
137137

138-
tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element plus a constant', function test( t ) {
138+
tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element plus a constant repeated N times', function test( t ) {
139139
var x;
140140
var v;
141141

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

144144
v = dapxsum( x.length, 5.0, x, 0 );
145-
t.strictEqual( v, 6.0, 'returns expected value' );
145+
t.strictEqual( v, x.length * (x[0]+5.0), 'returns expected value' );
146146

147147
t.end();
148148
});

lib/node_modules/@stdlib/blas/ext/base/dapxsum/test/test.dapxsum.native.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,14 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
253253
t.end();
254254
});
255255

256-
tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element plus a constant', opts, function test( t ) {
256+
tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element plus a constant repeated N times', opts, function test( t ) {
257257
var x;
258258
var v;
259259

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

262262
v = dapxsum( x.length, 5.0, x, 0 );
263-
t.strictEqual( v, 6.0, 'returns expected value' );
263+
t.strictEqual( v, x.length * (x[0]+5.0), 'returns expected value' );
264264

265265
t.end();
266266
});

lib/node_modules/@stdlib/blas/ext/base/dapxsum/test/test.ndarray.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ tape( 'the function supports a negative `stride` parameter', function test( t )
135135
t.end();
136136
});
137137

138-
tape( 'if provided a `stride` parameter equal to `0`, the function returns the first indexed element plus a constant', function test( t ) {
138+
tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element plus a constant repeated N times', function test( t ) {
139139
var x;
140140
var v;
141141

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

144144
v = dapxsum( x.length, 5.0, x, 0, 0 );
145-
t.strictEqual( v, 6.0, 'returns expected value' );
145+
t.strictEqual( v, x.length * (x[0]+5.0), 'returns expected value' );
146146

147147
t.end();
148148
});

lib/node_modules/@stdlib/blas/ext/base/dapxsum/test/test.ndarray.native.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ tape( 'the function supports a negative `stride` parameter', opts, function test
144144
t.end();
145145
});
146146

147-
tape( 'if provided a `stride` parameter equal to `0`, the function returns the first indexed element plus a constant', opts, function test( t ) {
147+
tape( 'if provided a `stride` parameter equal to `0`, the function returns the first element plus a constant repeated N times', opts, function test( t ) {
148148
var x;
149149
var v;
150150

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

153153
v = dapxsum( x.length, 5.0, x, 0, 0 );
154-
t.strictEqual( v, 6.0, 'returns expected value' );
154+
t.strictEqual( v, x.length * (x[0]+5.0), 'returns expected value' );
155155

156156
t.end();
157157
});

0 commit comments

Comments
 (0)