Skip to content

Commit

Permalink
refactor: update to follow current project conventions
Browse files Browse the repository at this point in the history
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: passed
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---

---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: na
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: na
  - task: run_c_benchmarks
    status: na
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: na
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: na
---
  • Loading branch information
headlessNode committed Jan 10, 2025
1 parent ff48331 commit 3fe217d
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 173 deletions.
47 changes: 15 additions & 32 deletions lib/node_modules/@stdlib/blas/ext/base/gsumkbn2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,29 @@ limitations under the License.
var gsumkbn2 = require( '@stdlib/blas/ext/base/gsumkbn2' );
```

#### gsumkbn2( N, x, stride )
#### gsumkbn2( N, x, strideX )

Computes the sum of strided array elements using a second-order iterative Kahan–Babuška algorithm.

```javascript
var x = [ 1.0, -2.0, 2.0 ];
var N = x.length;

var v = gsumkbn2( N, x, 1 );
var v = gsumkbn2( x.length, x, 1 );
// returns 1.0
```

The function has the following parameters:

- **N**: number of indexed elements.
- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
- **stride**: index increment for `x`.
- **strideX**: stride length.

The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the sum 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 every other element:

```javascript
var floor = require( '@stdlib/math/base/special/floor' );

var x = [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ];
var N = floor( x.length / 2 );

var v = gsumkbn2( N, x, 2 );
var v = gsumkbn2( 4, x, 2 );
// returns 5.0
```

Expand All @@ -72,42 +68,35 @@ Note that indexing is relative to the first index. To introduce an offset, use [

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var floor = require( '@stdlib/math/base/special/floor' );

var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

var N = floor( x0.length / 2 );

var v = gsumkbn2( N, x1, 2 );
var v = gsumkbn2( 4, x1, 2 );
// returns 5.0
```

#### gsumkbn2.ndarray( N, x, stride, offset )
#### gsumkbn2.ndarray( N, x, strideX, offsetX )

Computes the sum of strided array elements using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.

```javascript
var x = [ 1.0, -2.0, 2.0 ];
var N = x.length;

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

The function has the following additional parameters:

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

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 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 every other element starting from the second element:

```javascript
var floor = require( '@stdlib/math/base/special/floor' );

var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
var N = floor( x.length / 2 );

var v = gsumkbn2.ndarray( N, x, 2, 1 );
var v = gsumkbn2.ndarray( 4, x, 2, 1 );
// returns 5.0
```

Expand All @@ -133,18 +122,12 @@ var v = gsumkbn2.ndarray( N, x, 2, 1 );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var Float64Array = require( '@stdlib/array/float64' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var gsumkbn2 = require( '@stdlib/blas/ext/base/gsumkbn2' );

var x;
var i;

x = new Float64Array( 10 );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = round( randu()*100.0 );
}
var x = discreteUniform( 10, -100, 100, {
'dtype': 'float64'
});
console.log( x );

var v = gsumkbn2( x.length, x, 1 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var pkg = require( './../package.json' ).name;
var gsumkbn2 = require( './../lib/main.js' );


// VARIABLES //

var options = {
'dtype': 'generic'
};


// FUNCTIONS //

/**
Expand All @@ -38,13 +45,7 @@ var gsumkbn2 = require( './../lib/main.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var i;

x = [];
for ( i = 0; i < len; i++ ) {
x.push( ( randu()*10.0 ) - 20.0 );
}
var x = uniform( len, -100, 100, options );
return benchmark;

function benchmark( b ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var pkg = require( './../package.json' ).name;
var gsumkbn2 = require( './../lib/ndarray.js' );


// VARIABLES //

var options = {
'dtype': 'generic'
};


// FUNCTIONS //

/**
Expand All @@ -38,13 +45,7 @@ var gsumkbn2 = require( './../lib/ndarray.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var i;

x = [];
for ( i = 0; i < len; i++ ) {
x.push( ( randu()*10.0 ) - 20.0 );
}
var x = uniform( len, -100, 100, options );
return benchmark;

function benchmark( b ) {
Expand Down
34 changes: 15 additions & 19 deletions lib/node_modules/@stdlib/blas/ext/base/gsumkbn2/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

{{alias}}( N, x, stride )
{{alias}}( N, x, strideX )
Computes the sum of strided array elements using a second-order iterative
Kahan–Babuška algorithm.

The `N` and `stride` parameters determine which elements in `x` are accessed
at runtime.
The `N` and stride parameters determine which elements in the strided array
are accessed at runtime.

Indexing is relative to the first index. To introduce an offset, use a typed
array view.
Expand All @@ -19,8 +19,8 @@
x: Array<number>|TypedArray
Input array.

stride: integer
Index increment.
strideX: integer
Stride length.

Returns
-------
Expand All @@ -34,27 +34,24 @@
> {{alias}}( x.length, x, 1 )
1.0

// Using `N` and `stride` parameters:
// Using `N` and stride parameters:
> x = [ -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, 2 )
1.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, 2 )
-1.0

{{alias}}.ndarray( N, x, stride, offset )

{{alias}}.ndarray( N, x, strideX, offsetX )
Computes the sum of strided array elements using a second-order iterative
Kahan–Babuška algorithm and alternative indexing semantics.

While typed array views mandate a view offset based on the underlying
buffer, the `offset` parameter supports indexing semantics based on a
buffer, the offset parameter supports indexing semantics based on a
starting index.

Parameters
Expand All @@ -65,10 +62,10 @@
x: Array<number>|TypedArray
Input array.

stride: integer
Index increment.
strideX: integer
Stride length.

offset: integer
offsetX: integer
Starting index.

Returns
Expand All @@ -85,8 +82,7 @@

// Using offset parameter:
> var x = [ 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 )
-1.0

See Also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface Routine {
*
* @param N - number of indexed elements
* @param x - input array
* @param stride - stride length
* @param strideX - stride length
* @returns sum
*
* @example
Expand All @@ -40,15 +40,15 @@ interface Routine {
* var v = gsumkbn2( x.length, x, 1 );
* // returns 1.0
*/
( N: number, x: NumericArray, stride: number ): number;
( N: number, x: NumericArray, strideX: number ): number;

/**
* Computes the sum of strided array elements using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
*
* @param N - number of indexed elements
* @param x - input array
* @param stride - stride length
* @param offset - starting index
* @param strideX - stride length
* @param offsetX - starting index
* @returns sum
*
* @example
Expand All @@ -57,15 +57,15 @@ interface Routine {
* var v = gsumkbn2.ndarray( x.length, x, 1, 0 );
* // returns 1.0
*/
ndarray( N: number, x: NumericArray, stride: number, offset: number ): number;
ndarray( N: number, x: NumericArray, strideX: number, offsetX: number ): number;
}

/**
* Computes the sum of strided array elements using a second-order iterative Kahan–Babuška algorithm.
*
* @param N - number of indexed elements
* @param x - input array
* @param stride - stride length
* @param strideX - stride length
* @returns sum
*
* @example
Expand Down
16 changes: 5 additions & 11 deletions lib/node_modules/@stdlib/blas/ext/base/gsumkbn2/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var Float64Array = require( '@stdlib/array/float64' );
var gsumkbn2 = require( './../lib' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var gsumkbn2 = require( '@stdlib/blas/ext/base/gsumkbn2' );

var x;
var i;

x = new Float64Array( 10 );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = round( randu()*100.0 );
}
var x = discreteUniform( 10, -100, 100, {
'dtype': 'float64'
});
console.log( x );

var v = gsumkbn2( x.length, x, 1 );
Expand Down
7 changes: 2 additions & 5 deletions lib/node_modules/@stdlib/blas/ext/base/gsumkbn2/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,16 @@
* var gsumkbn2 = require( '@stdlib/blas/ext/base/gsumkbn2' );
*
* var x = [ 1.0, -2.0, 2.0 ];
* var N = x.length;
*
* var v = gsumkbn2( N, x, 1 );
* var v = gsumkbn2( x.length, x, 1 );
* // returns 1.0
*
* @example
* var floor = require( '@stdlib/math/base/special/floor' );
* var gsumkbn2 = require( '@stdlib/blas/ext/base/gsumkbn2' );
*
* var x = [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ];
* var N = floor( x.length / 2 );
*
* var v = gsumkbn2.ndarray( N, x, 2, 1 );
* var v = gsumkbn2.ndarray( 4, x, 2, 1 );
* // returns 5.0
*/

Expand Down
Loading

0 comments on commit 3fe217d

Please # to comment.