Skip to content
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

docs: update examples for blas/base/wasm/zswap #5770

Merged
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
110 changes: 10 additions & 100 deletions lib/node_modules/@stdlib/blas/base/wasm/zswap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,13 @@ Interchanges two complex double-precision floating-point vectors.

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );

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

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

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

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

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

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

re = real( z );
// returns 0.0

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

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

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );

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

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

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

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

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

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

re = real( z );
// returns 0.0

im = imag( z );
// returns 0.0
// x => <Complex128Array>[ 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ]
// y => <Complex128Array>[ 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.
Expand All @@ -108,8 +72,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );

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

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

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

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

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

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

re = real( z );
// returns 0.0

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

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

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );

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

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

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

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

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

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

re = real( z );
// returns 0.0

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

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

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );

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

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

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

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

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

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

re = real( z );
// returns 0.0

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

* * *
Expand Down
70 changes: 20 additions & 50 deletions lib/node_modules/@stdlib/blas/base/wasm/zswap/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,48 +38,30 @@
> var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> var y = new {{alias:@stdlib/array/complex128}}( [ 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/float64/real}}( z )
1.0
> var im = {{alias:@stdlib/complex/float64/imag}}( z )
2.0
> z = x.get( 0 );
> re = {{alias:@stdlib/complex/float64/real}}( z )
6.0
> im = {{alias:@stdlib/complex/float64/imag}}( z )
7.0
> x
<Complex128Array>[ 6.0, 7.0, 8.0, 9.0 ]
> y
<Complex128Array>[ 1.0, 2.0, 3.0, 4.0 ]

// Advanced indexing:
> x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
> y = new {{alias:@stdlib/array/complex128}}( [ 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/float64/real}}( z )
5.0
> im = {{alias:@stdlib/complex/float64/imag}}( z )
6.0
> z = x.get( 0 );
> re = {{alias:@stdlib/complex/float64/real}}( z )
0.0
> im = {{alias:@stdlib/complex/float64/imag}}( z )
0.0
> x
<Complex128Array>[ 0.0, 0.0, 3.0, 4.0, 0.0, 0.0, 7.0, 8.0 ]
> y
<Complex128Array>[ 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/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> var y0 = new {{alias:@stdlib/array/complex128}}( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
> var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> var y1 = new {{alias:@stdlib/array/complex128}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 );
> {{alias}}.main( 2, x1, -1, y1, 1 );
> z = y0.get( 2 );
> re = {{alias:@stdlib/complex/float64/real}}( z )
3.0
> im = {{alias:@stdlib/complex/float64/imag}}( z )
4.0
> z = x0.get( 1 );
> re = {{alias:@stdlib/complex/float64/real}}( z )
0.0
> im = {{alias:@stdlib/complex/float64/imag}}( z )
0.0
> x0
<Complex128Array>[ 1.0, 2.0, 0.0, 0.0, 0.0, 0.0 ]
> y0
<Complex128Array>[ 0.0, 0.0, 5.0, 6.0, 3.0, 4.0 ]


{{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY )
Expand Down Expand Up @@ -124,31 +106,19 @@
> var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> var y = new {{alias:@stdlib/array/complex128}}( [ 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/float64/real}}( z )
1.0
> var im = {{alias:@stdlib/complex/float64/imag}}( z )
2.0
> z = x.get( 0 );
> re = {{alias:@stdlib/complex/float64/real}}( z )
6.0
> im = {{alias:@stdlib/complex/float64/imag}}( z )
7.0
> x
<Complex128Array>[ 6.0, 7.0, 8.0, 9.0 ]
> y
<Complex128Array>[ 1.0, 2.0, 3.0, 4.0 ]

// Advanced indexing:
> x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
> y = new {{alias:@stdlib/array/complex128}}( [ 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/float64/real}}( z )
3.0
> im = {{alias:@stdlib/complex/float64/imag}}( z )
4.0
> z = x.get( 1 );
> re = {{alias:@stdlib/complex/float64/real}}( z )
0.0
> im = {{alias:@stdlib/complex/float64/imag}}( z )
0.0
> x
<Complex128Array>[ 1.0, 2.0, 0.0, 0.0, 5.0, 6.0, 0.0, 0.0 ]
> y
<Complex128Array>[ 0.0, 0.0, 0.0, 0.0, 7.0, 8.0, 3.0, 4.0 ]


{{alias}}.Module( memory )
Expand Down
Loading