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/ccopy #5410

Merged
merged 2 commits into from
Feb 24, 2025
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
60 changes: 5 additions & 55 deletions lib/node_modules/@stdlib/blas/base/wasm/ccopy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,14 @@ Copies values from `x` into `y`.

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

// Define strided arrays...
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 ] );

// Perform operation:
ccopy.main( x.length, x, 1, y, 1 );

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

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

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

The function has the following parameters:
Expand All @@ -68,22 +58,12 @@ The `N` and stride parameters determine how values from `x` are copied into `y`.

```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 ] );

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

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

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

var im = imagf( v );
// returns 6.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.
Expand All @@ -92,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 ] );
Expand All @@ -105,15 +83,7 @@ var y1 = new Complex64Array( y0.buffer, y0.BYTES_PER_ELEMENT*2 ); // start at 3r

// Copy every other value from `x1` into `y1` in reverse order...
ccopy.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
// y0 => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 7.0, 8.0, 3.0, 4.0 ]
```

#### ccopy.ndarray( N, x, strideX, offsetX, y, strideY, offsetY )
Expand All @@ -122,22 +92,12 @@ Copies values from `x` into `y` using alternative indexing semantics.

```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 ] );

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

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

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

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

The function has the following additional parameters:
Expand All @@ -149,22 +109,12 @@ 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 ] );

ccopy.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
// y => <Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 7.0, 8.0, 3.0, 4.0 ]
```

* * *
Expand Down
42 changes: 12 additions & 30 deletions lib/node_modules/@stdlib/blas/base/wasm/ccopy/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,24 @@
// Standard usage:
> 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
> {{alias}}.main( x.length, x, 1, y, 1 )
<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
> {{alias}}.main( 2, x, -2, y, 1 )
<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
> {{alias}}.main( 2, x1, -2, y1, 1 )
<Complex64Array>[ 7.0, 8.0, 3.0, 4.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 )
Expand Down Expand Up @@ -110,22 +100,14 @@
// Standard usage:
> 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
> {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 )
<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
> {{alias}}.ndarray( 2, x, 2, 1, y, -1, y.length-1 )
<Complex64Array>[ 0.0, 0.0, 0.0, 0.0, 7.0, 8.0, 3.0, 4.0 ]


{{alias}}.Module( memory )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,23 +307,13 @@ interface Routine extends ModuleWrapper {
*
* @example
* 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( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
*
* // Perform operation:
* ccopy.main( x.length, x, 1, y, 1 );
*
* var v = y.get( 0 );
* // returns <Complex64>
*
* var re = realf( v );
* // returns -1.0
*
* var im = imagf( v );
* // returns -2.0
* // y => <Complex64Array>[ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0 ]
*/
main( N: number, x: Complex64Array, strideX: number, y: Complex64Array, strideY: number ): Complex64Array;

Expand All @@ -341,23 +331,13 @@ interface Routine extends ModuleWrapper {
*
* @example
* 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( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
*
* // Perform operation:
* ccopy.ndarray( x.length, x, -1, 2, y, 1, 0 );
*
* var v = y.get( 0 );
* // returns <Complex64>
*
* var re = realf( v );
* // returns -5.0
*
* var im = imagf( v );
* // returns -6.0
* // y => <Complex64Array>[ -5.0, -6.0, -3.0, -4.0, -1.0, -2.0 ]
*/
ndarray( N: number, x: Complex64Array, strideX: number, offsetX: number, y: Complex64Array, strideY: number, offsetY: number ): Complex64Array;

Expand Down Expand Up @@ -437,43 +417,23 @@ interface Routine extends ModuleWrapper {
*
* @example
* 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( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
*
* // Perform operation:
* ccopy.main( x.length, x, -1, y, 1 );
*
* var v = y.get( 0 );
* // returns <Complex64>
*
* var re = realf( v );
* // returns 5.0
*
* var im = imagf( v );
* // returns 6.0
* // y => <Complex64Array>[ 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ]
*
* @example
* 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( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
*
* // Perform operation:
* ccopy.ndarray( x.length, x, 1, 0, y, -1, 2 );
*
* var v = y.get( 2 );
* // returns <Complex64>
*
* var re = realf( v );
* // returns 1.0
*
* var im = imagf( v );
* // returns 2.0
* // y => <Complex64Array>[ 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ]
*/
declare var ccopy: Routine;

Expand Down
25 changes: 2 additions & 23 deletions lib/node_modules/@stdlib/blas/base/wasm/ccopy/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
* var realf = require( '@stdlib/complex/float32/real' );
* var imagf = require( '@stdlib/complex/float32/imag' );
* var ccopy = require( '@stdlib/blas/base/wasm/ccopy' );
*
* // Define strided arrays...
Expand All @@ -35,21 +33,10 @@
*
* // Perform operation:
* ccopy.main( x.length, x, 1, y, 1 );
*
* var v = y.get( 0 );
* // returns <Complex64>
*
* var re = realf( v );
* // returns 1.0
*
* var im = imagf( v );
* // returns 2.0
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
* var Complex64 = require( '@stdlib/complex/float32/ctor' );
* var realf = require( '@stdlib/complex/float32/real' );
* var imagf = require( '@stdlib/complex/float32/imag' );
* var ccopy = require( '@stdlib/blas/base/wasm/ccopy' );
*
* // Define strided arrays...
Expand All @@ -58,15 +45,7 @@
*
* // Perform operation:
* ccopy.ndarray( x.length, x, 1, 0, y, 1, 0 );
*
* var v = y.get( 0 );
* // returns <Complex64>
*
* var re = realf( v );
* // returns 1.0
*
* var im = imagf( v );
* // returns 2.0
* // y => <Complex64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]
*
* @example
* var Memory = require( '@stdlib/wasm/memory' );
Expand Down
24 changes: 2 additions & 22 deletions lib/node_modules/@stdlib/blas/base/wasm/ccopy/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,25 @@ var Routine = require( './routine.js' );
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
* var realf = require( '@stdlib/complex/float32/real' );
* var imagf = require( '@stdlib/complex/float32/imag' );
*
* // Define strided arrays...
* var x = new Complex64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0 ] );
* var y = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
*
* // Perform operation:
* ccopy.main( x.length, x, 1, y, 1 );
*
* var v = y.get( 0 );
* // returns <Complex64>
*
* var re = realf( v );
* // returns -1.0
*
* var im = imagf( v );
* // returns -2.0
* // y => <Complex64Array>[ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0 ]
*
* @example
* var Complex64Array = require( '@stdlib/array/complex64' );
* var realf = require( '@stdlib/complex/float32/real' );
* var imagf = require( '@stdlib/complex/float32/imag' );
*
* // Define a strided arrays...
* var x = new Complex64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0 ] );
* var y = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
*
* // Perform operation:
* ccopy.ndarray( x.length, x, 1, 0, y, -1, 2 );
*
* var v = y.get( 0 );
* // returns <Complex64>
*
* var re = realf( v );
* // returns -5.0
*
* var im = imagf( v );
* // returns -6.0
* // y => <Complex64Array>[ -5.0, -6.0, -3.0, -4.0, -1.0, -2.0 ]
*/
var ccopy = new Routine();
ccopy.initializeSync(); // eslint-disable-line node/no-sync
Expand Down
Loading