Skip to content

docs: update examples for blas/base/wasm/cswap #5766

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 2 commits into from
Apr 30, 2025
Merged
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
110 changes: 10 additions & 100 deletions lib/node_modules/@stdlib/blas/base/wasm/cswap/README.md
Original file line number Diff line number Diff line change
@@ -36,31 +36,13 @@ Interchanges two complex single-precision floating-point vectors.

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var realf = require( '@stdlib/complex/float32/real' );
var imagf = require( '@stdlib/complex/float32/imag' );

var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var y = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );

cswap.main( x.length, x, 1, y, 1 );

var z = y.get( 0 );
// returns <Complex64>

var re = realf( z );
// returns 1.0

var im = imagf( z );
// returns 2.0

z = x.get( 0 );
// returns <Complex64>

re = realf( z );
// returns 0.0

im = imagf( z );
// returns 0.0
// x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
// y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
```

The function has the following parameters:
@@ -75,31 +57,13 @@ The `N` and stride parameters determine how values from `x` are interchanged wit

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var realf = require( '@stdlib/complex/float32/real' );
var imagf = require( '@stdlib/complex/float32/imag' );

var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
var y = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );

cswap.main( 2, x, -2, y, 1 );

var z = y.get( 0 );
// returns <Complex64>

var re = realf( z );
// returns 5.0

var im = imagf( z );
// returns 6.0

z = x.get( 0 );
// returns <Complex64>

re = realf( z );
// returns 0.0

im = imagf( z );
// returns 0.0
// x => <Complex64Array>[ 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ]
// y => <Complex64Array>[ 5.0, 6.0, 1.0, 2.0, 0.0, 0.0, 0.0, 0.0 ]
```

Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
@@ -108,8 +72,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var realf = require( '@stdlib/complex/float32/real' );
var imagf = require( '@stdlib/complex/float32/imag' );

// Initial arrays...
var x0 = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
@@ -121,24 +83,8 @@ var y1 = new Complex64Array( y0.buffer, y0.BYTES_PER_ELEMENT*2 ); // start at 3r

// Interchange every other value from `x1` into `y1` in reverse order...
cswap.main( 2, x1, -2, y1, 1 );

var z = y0.get( 2 );
// returns <Complex64>

var re = realf( z );
// returns 7.0

var im = imagf( z );
// returns 8.0

z = x0.get( 1 );
// returns <Complex64>

re = realf( z );
// returns 0.0

im = imagf( z );
// returns 0.0
// x0 => <Complex64Array>[ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 0.0, 0.0 ]
// y0 => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 7.0, 8.0, 3.0, 4.0 ]
```

#### cswap.ndarray( N, x, strideX, offsetX, y, strideY, offsetY )
@@ -147,31 +93,13 @@ Interchanges two complex single-precision floating-point vectors using alternati

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var realf = require( '@stdlib/complex/float32/real' );
var imagf = require( '@stdlib/complex/float32/imag' );

var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var y = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );

cswap.ndarray( x.length, x, 1, 0, y, 1, 0 );

var z = y.get( 0 );
// returns <Complex64>

var re = realf( z );
// returns 1.0

var im = imagf( z );
// returns 2.0

z = x.get( 0 );
// returns <Complex64>

re = realf( z );
// returns 0.0

im = imagf( z );
// returns 0.0
// x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
// y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
```

The function has the following additional parameters:
@@ -183,31 +111,13 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var realf = require( '@stdlib/complex/float32/real' );
var imagf = require( '@stdlib/complex/float32/imag' );

var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
var y = new Complex64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );

cswap.ndarray( 2, x, 2, 1, y, -1, y.length-1 );

var z = y.get( y.length-1 );
// returns <Complex64>

var re = realf( z );
// returns 3.0

var im = imagf( z );
// returns 4.0

z = x.get( x.length-1 );
// returns <Complex64>

re = realf( z );
// returns 0.0

im = imagf( z );
// returns 0.0
// x => <Complex64Array>[ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 0.0, 0.0 ]
// y => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 7.0, 8.0, 3.0, 4.0 ]
```

* * *
70 changes: 20 additions & 50 deletions lib/node_modules/@stdlib/blas/base/wasm/cswap/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -38,48 +38,30 @@
> var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> var y = new {{alias:@stdlib/array/complex64}}( [ 6.0, 7.0, 8.0, 9.0 ] );
> {{alias}}.main( x.length, x, 1, y, 1 );
> var z = y.get( 0 );
> var re = {{alias:@stdlib/complex/float32/real}}( z )
1.0
> var im = {{alias:@stdlib/complex/float32/imag}}( z )
2.0
> z = x.get( 0 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
6.0
> im = {{alias:@stdlib/complex/float32/imag}}( z )
7.0
> x
<Complex64Array>[ 6.0, 7.0, 8.0, 9.0 ]
> y
<Complex64Array>[ 1.0, 2.0, 3.0, 4.0 ]

// Advanced indexing:
> x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
> y = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
> {{alias}}.main( 2, x, -2, y, 1 );
> z = y.get( 0 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
5.0
> im = {{alias:@stdlib/complex/float32/imag}}( z )
6.0
> z = x.get( 0 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
0.0
> im = {{alias:@stdlib/complex/float32/imag}}( z )
0.0
> x
<Complex64Array>[ 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ]
> y
<Complex64Array>[ 5.0, 6.0, 1.0, 2.0, 0.0, 0.0, 0.0, 0.0 ]

// Using typed array views:
> var x0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
> var y0 = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
> var x1 = new {{alias:@stdlib/array/complex64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> var y1 = new {{alias:@stdlib/array/complex64}}( y0.buffer, y0.BYTES_PER_ELEMENT*2 );
> {{alias}}.main( 2, x1, -2, y1, 1 );
> z = y0.get( 2 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
7.0
> im = {{alias:@stdlib/complex/float32/imag}}( z )
8.0
> z = x0.get( 1 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
0.0
> im = {{alias:@stdlib/complex/float32/imag}}( z )
0.0
> x0
<Complex64Array>[ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 0.0, 0.0 ]
> y0
<Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 7.0, 8.0, 3.0, 4.0 ]


{{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY )
@@ -124,31 +106,19 @@
> var x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> var y = new {{alias:@stdlib/array/complex64}}( [ 6.0, 7.0, 8.0, 9.0 ] );
> {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 );
> var z = y.get( 0 );
> var re = {{alias:@stdlib/complex/float32/real}}( z )
1.0
> var im = {{alias:@stdlib/complex/float32/imag}}( z )
2.0
> z = x.get( 0 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
6.0
> im = {{alias:@stdlib/complex/float32/imag}}( z )
7.0
> x
<Complex64Array>[ 6.0, 7.0, 8.0, 9.0 ]
> y
<Complex64Array>[ 1.0, 2.0, 3.0, 4.0 ]

// Advanced indexing:
> x = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
> y = new {{alias:@stdlib/array/complex64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
> {{alias}}.ndarray( 2, x, 2, 1, y, -1, y.length-1 );
> z = y.get( y.length-1 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
3.0
> im = {{alias:@stdlib/complex/float32/imag}}( z )
4.0
> z = x.get( 1 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
0.0
> im = {{alias:@stdlib/complex/float32/imag}}( z )
0.0
> x
<Complex64Array>[ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 0.0, 0.0 ]
> y
<Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 7.0, 8.0, 3.0, 4.0 ]


{{alias}}.Module( memory )
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/blas/base/wasm/cswap/lib/index.js
Original file line number Diff line number Diff line change
@@ -33,8 +33,8 @@
*
* // Perform operation:
* cswap.main( x.length, x, 1, y, 1 );
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
@@ -46,8 +46,8 @@
*
* // Perform operation:
* cswap.ndarray( x.length, x, 1, 0, y, 1, 0 );
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*
* @example
* var Memory = require( '@stdlib/wasm/memory' );
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/blas/base/wasm/cswap/lib/main.js
Original file line number Diff line number Diff line change
@@ -40,8 +40,8 @@ var Routine = require( './routine.js' );
*
* // Perform operation:
* cswap.main( x.length, x, 1, y, 1 );
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
@@ -52,8 +52,8 @@ var Routine = require( './routine.js' );
*
* // Perform operation:
* cswap.ndarray( x.length, x, 1, 0, y, 1, 0 );
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*/
var cswap = new Routine();
cswap.initializeSync(); // eslint-disable-line node/no-sync
16 changes: 8 additions & 8 deletions lib/node_modules/@stdlib/blas/base/wasm/cswap/lib/routine.js
Original file line number Diff line number Diff line change
@@ -56,8 +56,8 @@ var Module = require( './module.js' );
*
* // Perform operation:
* cswap.main( x.length, x, 1, y, 1 );
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
@@ -74,8 +74,8 @@ var Module = require( './module.js' );
*
* // Perform operation:
* cswap.ndarray( x.length, x, 1, 0, y, 1, 0 );
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*/
function Routine() {
if ( !( this instanceof Routine ) ) {
@@ -119,8 +119,8 @@ inherits( Routine, Module );
*
* // Perform operation:
* cswap.main( x.length, x, 1, y, 1 );
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*/
setReadOnly( Routine.prototype, 'main', function cswap( N, x, strideX, y, strideY ) {
return this.ndarray( N, x, strideX, stride2offset( N, strideX ), y, strideY, stride2offset( N, strideY ) ); // eslint-disable-line max-len
@@ -157,8 +157,8 @@ setReadOnly( Routine.prototype, 'main', function cswap( N, x, strideX, y, stride
*
* // Perform operation:
* cswap.ndarray( x.length, x, 1, 0, y, 1, 0 );
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ];
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
* // x => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*/
setReadOnly( Routine.prototype, 'ndarray', function cswap( N, x, strideX, offsetX, y, strideY, offsetY ) {
var ptrs;