Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jan 18, 2023
1 parent 4a33a7a commit 8418092
Show file tree
Hide file tree
Showing 24 changed files with 256 additions and 361 deletions.
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Copyright (c) 2016-2022 The Stdlib Authors.
Copyright (c) 2016-2023 The Stdlib Authors.
24 changes: 8 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@license Apache-2.0
Copyright (c) 2020 The Stdlib Authors.
Copyright (c) 2023 The Stdlib Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -73,7 +73,7 @@ The function has the following parameters:
- **y**: second input [`Float64Array`][mdn-float64array].
- **strideY**: index increment for `y`.

The `N` and `stride` parameters determine how values from `x` and `y` are accessed at runtime. For example, to swap in reverse order every other value in `x` with the first `N` elements of `y`,
The `N` and stride parameters determine how values from `x` and `y` are accessed at runtime. For example, to swap in reverse order every other value in `x` with the first `N` elements of `y`,

```javascript
var Float64Array = require( '@stdlib/array-float64' );
Expand Down Expand Up @@ -127,7 +127,7 @@ The function has the following additional parameters:
- **offsetX**: starting index for `x`.
- **offsetY**: starting index for `y`.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offsetX` and `offsetY` parameters support indexing semantics based on starting indices. For example, to swap every other value in `x` starting from the second value with the last `N` elements in `y` where `x[i] = y[n]`, `x[i+2] = y[n-1]`,...,
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the offset parameters support indexing semantics based on starting indices. For example, to swap every other value in `x` starting from the second value with the last `N` elements in `y` where `x[i] = y[n]`, `x[i+2] = y[n-1]`,...,

```javascript
var Float64Array = require( '@stdlib/array-float64' );
Expand Down Expand Up @@ -162,22 +162,14 @@ dswap.ndarray( 3, x, 2, 1, y, -1, y.length-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-base-discrete-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array-filled-by' );
var dswap = require( '@stdlib/blas-base-dswap' );

var x;
var y;
var i;

x = new Float64Array( 10 );
y = new Float64Array( 10 );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = round( randu()*500.0 );
y[ i ] = round( randu()*255.0 );
}
var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 500 ) );
console.log( x );

var y = filledarrayBy( x.length, 'float64', discreteUniform( 0, 255 ) );
console.log( y );

// Swap elements in `x` and `y` starting from the end of `y`:
Expand Down
22 changes: 10 additions & 12 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,14 +21,19 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random-base-randu' );
var uniform = require( '@stdlib/random-base-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array-filled-by' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pow = require( '@stdlib/math-base-special-pow' );
var Float64Array = require( '@stdlib/array-float64' );
var pkg = require( './../package.json' ).name;
var dswap = require( './../lib/dswap.js' );


// VARIABLES //

var rand = uniform( -10000.0, 10000.0 );


// FUNCTIONS //

/**
Expand All @@ -39,15 +44,8 @@ var dswap = require( './../lib/dswap.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20000.0 ) - 10000.0;
}
var x = filledarrayBy( len, 'float64', rand );
var y = filledarrayBy( len, 'float64', rand );
return benchmark;

/**
Expand Down
18 changes: 6 additions & 12 deletions benchmark/benchmark.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,10 +22,10 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random-base-randu' );
var uniform = require( '@stdlib/random-base-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array-filled-by' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pow = require( '@stdlib/math-base-special-pow' );
var Float64Array = require( '@stdlib/array-float64' );
var tryRequire = require( '@stdlib/utils-try-require' );
var pkg = require( './../package.json' ).name;

Expand All @@ -36,6 +36,7 @@ var dswap = tryRequire( resolve( __dirname, './../lib/dswap.native.js' ) );
var opts = {
'skip': ( dswap instanceof Error )
};
var rand = uniform( -10000.0, 10000.0 );


// FUNCTIONS //
Expand All @@ -48,15 +49,8 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20000.0 ) - 10000.0;
}
var x = filledarrayBy( len, 'float64', rand );
var y = filledarrayBy( len, 'float64', rand );
return benchmark;

/**
Expand Down
22 changes: 10 additions & 12 deletions benchmark/benchmark.ndarray.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,14 +21,19 @@
// MODULES //

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


// VARIABLES //

var rand = uniform( -10000.0, 10000.0 );


// FUNCTIONS //

/**
Expand All @@ -39,15 +44,8 @@ var dswap = require( './../lib/ndarray.js' );
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20000.0 ) - 10000.0;
}
var x = filledarrayBy( len, 'float64', rand );
var y = filledarrayBy( len, 'float64', rand );
return benchmark;

/**
Expand Down
18 changes: 6 additions & 12 deletions benchmark/benchmark.ndarray.native.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,10 +22,10 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random-base-randu' );
var uniform = require( '@stdlib/random-base-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array-filled-by' );
var isnan = require( '@stdlib/math-base-assert-is-nan' );
var pow = require( '@stdlib/math-base-special-pow' );
var Float64Array = require( '@stdlib/array-float64' );
var tryRequire = require( '@stdlib/utils-try-require' );
var pkg = require( './../package.json' ).name;

Expand All @@ -36,6 +36,7 @@ var dswap = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) );
var opts = {
'skip': ( dswap instanceof Error )
};
var rand = uniform( -10000.0, 10000.0 );


// FUNCTIONS //
Expand All @@ -48,15 +49,8 @@ var opts = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x;
var y;
var i;

x = new Float64Array( len );
y = new Float64Array( len );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = ( randu()*20000.0 ) - 10000.0;
}
var x = filledarrayBy( len, 'float64', rand );
var y = filledarrayBy( len, 'float64', rand );
return benchmark;

/**
Expand Down
21 changes: 9 additions & 12 deletions docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{alias}}( N, x, strideX, y, strideY )
Interchanges two double-precision floating-point vectors.

The `N` and `stride` parameters determine how values from `x` are swapped
The `N` and stride parameters determine how values from `x` are swapped
with values from `y`.

Indexing is relative to the first index. To introduce an offset, use typed
Expand All @@ -13,7 +13,7 @@
Parameters
----------
N: integer
Number of values to swap.
Number of values.

x: Float64Array
First input array.
Expand All @@ -30,7 +30,7 @@
Returns
-------
y: Float64Array
Input array `y`.
Second input array.

Examples
--------
Expand All @@ -43,17 +43,15 @@
// Advanced indexing:
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> y = new {{alias:@stdlib/array/float64}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}( N, x, -2, y, 1 )
> {{alias}}( 3, x, -2, y, 1 )
<Float64Array>[ 5.0, 3.0, 1.0, 10.0, 11.0, 12.0 ]

// Using typed array views:
> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> var y0 = new {{alias:@stdlib/array/float64}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*3 );
> N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
> {{alias}}( N, x1, -2, y1, 1 )
> {{alias}}( 3, x1, -2, y1, 1 )
<Float64Array>[ 6.0, 4.0, 2.0 ]
> y0
<Float64Array>[ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ]
Expand All @@ -64,13 +62,13 @@
indexing semantics.

While typed array views mandate a view offset based on the underlying
buffer, the `offset` parameters support indexing semantics based on starting
buffer, the offset parameters support indexing semantics based on starting
indices.

Parameters
----------
N: integer
Number of values to swap.
Number of values.

x: Float64Array
First input array.
Expand All @@ -93,7 +91,7 @@
Returns
-------
y: Float64Array
Input array `y`.
Second input array.

Examples
--------
Expand All @@ -106,8 +104,7 @@
// Advanced indexing:
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> y = new {{alias:@stdlib/array/float64}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
> var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
> {{alias}}.ndarray( N, x, 2, 1, y, -1, y.length-1 )
> {{alias}}.ndarray( 3, x, 2, 1, y, -1, y.length-1 )
<Float64Array>[ 7.0, 8.0, 9.0, 6.0, 4.0, 2.0 ]

See Also
Expand Down
6 changes: 3 additions & 3 deletions docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,7 @@ interface Routine {
/**
* Interchanges two double-precision floating-point vectors.
*
* @param N - number of values to swap
* @param N - number of values
* @param x - first input array
* @param strideX - `x` stride length
* @param y - second input array
Expand All @@ -47,7 +47,7 @@ interface Routine {
/**
* Interchanges two double-precision floating-point vectors using alternative indexing semantics.
*
* @param N - number of values to swap
* @param N - number of values
* @param x - first input array
* @param strideX - `x` stride length
* @param offsetX - starting index for `x`
Expand Down
20 changes: 6 additions & 14 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2020 The Stdlib Authors.
* Copyright (c) 2023 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,22 +18,14 @@

'use strict';

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-base-discrete-uniform' ).factory;
var filledarrayBy = require( '@stdlib/array-filled-by' );
var dswap = require( './../lib' );

var x;
var y;
var i;

x = new Float64Array( 10 );
y = new Float64Array( 10 );
for ( i = 0; i < x.length; i++ ) {
x[ i ] = round( randu()*500.0 );
y[ i ] = round( randu()*255.0 );
}
var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 500 ) );
console.log( x );

var y = filledarrayBy( x.length, 'float64', discreteUniform( 0, 255 ) );
console.log( y );

// Swap elements in `x` and `y` starting from the end of `y`:
Expand Down
Loading

0 comments on commit 8418092

Please sign in to comment.