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/cscal #4942

Merged
merged 1 commit into from
Jan 29, 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
62 changes: 6 additions & 56 deletions lib/node_modules/@stdlib/blas/base/cscal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,18 @@ Scales values from `cx` by `ca`.
```javascript
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 cx = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] );
var ca = new Complex64( 2.0, 0.0 );

cscal( 3, ca, cx, 1 );

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

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

var im = imagf( z );
// returns 2.0
// cx => <Complex64Array>[ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ]
```

The function has the following parameters:

- **N**: number of indexed elements.
- **ca**: scalar [`Complex64`][@stdlib/complex/float32/ctor] constant.
- **ca**: scalar [`Complex64`][@stdlib/complex/float32/ctor] constant.
- **cx**: input [`Complex64Array`][@stdlib/array/complex64].
- **strideX**: index increment for `cx`.

Expand All @@ -67,22 +57,12 @@ The `N` and stride parameters determine how values from `cx` are scaled by `ca`.
```javascript
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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
var ca = new Complex64( 2.0, 0.0 );

cscal( 2, ca, cx, 2 );

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

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

var im = imagf( z );
// returns 12.0
// cx => <Complex64Array>[ 2.0, 4.0, 3.0, 4.0, 10.0, 12.0, 7.0, 8.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 Complex64 = require( '@stdlib/complex/float32/ctor' );
var realf = require( '@stdlib/complex/float32/real' );
var imagf = require( '@stdlib/complex/float32/imag' );

// Initial array:
var cx0 = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
Expand All @@ -106,15 +84,7 @@ var cx1 = new Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // start at

// Scales every other value from `cx1` by `ca`...
cscal( 3, ca, cx1, 1 );

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

var re = realf( z );
// returns -2.0

var im = imagf( z );
// returns 14.0
// cx0 => <Complex64Array>[ 1.0, 2.0, -2.0, 14.0, -2.0, 22.0, -2.0, 30.0 ]
```

#### cscal.ndarray( N, ca, cx, strideX, offsetX )
Expand All @@ -124,22 +94,12 @@ Scales values from `cx` by `ca` using alternative indexing semantics.
```javascript
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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var ca = new Complex64( 2.0, 2.0 );

cscal.ndarray( 3, ca, cx, 1, 0 );

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

var re = realf( z );
// returns -2.0

var im = imagf( z );
// returns 6.0
// cx => <Complex64Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.0 ]
```

The function has the following additional parameters:
Expand All @@ -151,22 +111,12 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the
```javascript
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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
var ca = new Complex64( 2.0, 2.0 );

cscal.ndarray( 2, ca, cx, 2, 1 );

var z = cx.get( 3 );
// returns <Complex64>

var re = realf( z );
// returns -2.0

var im = imagf( z );
// returns 30.0
// cx => <Complex64Array>[ 1.0, 2.0, -2.0, 14.0, 5.0, 6.0, -2.0, 30.0 ]
```

</section>
Expand Down
42 changes: 12 additions & 30 deletions lib/node_modules/@stdlib/blas/base/cscal/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,23 @@
// Standard usage:
> var cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> var ca = new {{alias:@stdlib/complex/float32/ctor}}( 1.0, 2.0 );
> {{alias}}( 2, ca, cx, 1 );
> var z = cx.get( 0 );
> var re = {{alias:@stdlib/complex/float32/real}}( z )
-3.0
> var im = {{alias:@stdlib/complex/float32/imag}}( z )
4.0
> {{alias}}( 2, ca, cx, 1 )
<Complex64Array>[ -3.0, 4.0, -5.0, 10.0 ]

// Advanced indexing:
> cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> ca = new {{alias:@stdlib/complex/float32/ctor}}( 1.0, 1.0 );
> {{alias}}( 2, ca, cx, 2 );
> z = cx.get( 0 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
-1.0
> im = {{alias:@stdlib/complex/float32/imag}}( z )
3.0
> {{alias}}( 2, ca, cx, 2 )
<Complex64Array>[ -1.0, 3.0, 3.0, 4.0, -1.0, 11.0 ]

// Using typed array views:
> var cx0 = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> var cx1 = new {{alias:@stdlib/array/complex64}}( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 );
> var ca = new {{alias:@stdlib/complex/float32/ctor}}( 2.0, 2.0 );
> {{alias}}( 2, ca, cx1, 1 );
> z = cx0.get( 1 );
> re = {{alias:@stdlib/complex/float32/real}}( z )
-2.0
> im = {{alias:@stdlib/complex/float32/imag}}( z )
14.0
> {{alias}}( 2, ca, cx1, 1 )
<Complex64Array>[ -2.0, 14.0, -2.0, 22.0 ]
> cx0
<Complex64Array>[ 1.0, 2.0, -2.0, 14.0, -2.0, 22.0 ]


{{alias}}.ndarray( N, ca, cx, strideX, offsetX )
Expand Down Expand Up @@ -101,22 +91,14 @@
// Standard usage:
> var cx = new {{alias:@stdlib/array/complex64}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> var ca = new {{alias:@stdlib/complex/float32/ctor}}( 2.0, 2.0 );
> {{alias}}.ndarray( 2, ca, cx, 1, 0 );
> var z = cx.get( 0 );
> var re = {{alias:@stdlib/complex/float32/real}}( z )
-2.0
> var im = {{alias:@stdlib/complex/float32/imag}}( z )
6.0
> {{alias}}.ndarray( 2, ca, cx, 1, 0 )
<Complex64Array>[ -2.0, 6.0, -2.0, 14.0 ]

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

See Also
--------
Expand Down
50 changes: 5 additions & 45 deletions lib/node_modules/@stdlib/blas/base/cscal/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,12 @@ interface Routine {
* @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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var ca = new Complex64( 2.0, 2.0 );
*
* cscal( 3, ca, cx, 1 );
*
* var z = cx.get( 0 );
* // returns <Complex64>
*
* var re = realf( z );
* // returns -2.0
*
* var im = imagf( z );
* // returns 6.0
* // cx => <Complex64Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.0 ]
*/
( N: number, ca: Complex64, cx: Complex64Array, strideX: number ): Complex64Array;

Expand All @@ -71,22 +61,12 @@ interface Routine {
* @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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var ca = new Complex64( 2.0, 2.0 );
*
* cscal.ndarray( 3, ca, cx, 1, 0 );
*
* var z = cx.get( 0 );
* // returns <Complex64>
*
* var re = realf( z );
* // returns -2.0
*
* var im = imagf( z );
* // returns 6.0
* // cx => <Complex64Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.0 ]
*/
ndarray( N: number, ca: Complex64, cx: Complex64Array, strideX: number, offsetX: number ): Complex64Array;
}
Expand All @@ -103,42 +83,22 @@ interface Routine {
* @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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var ca = new Complex64( 2.0, 2.0 );
*
* cscal( 3, ca, cx, 1 );
*
* var z = cx.get( 0 );
* // returns <Complex64>
*
* var re = realf( z );
* // returns -2.0
*
* var im = imagf( z );
* // returns 6.0
* // cx => <Complex64Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var ca = new Complex64( 2.0, 2.0 );
*
* cscal.ndarray( 2, ca, cx, 1, 0 );
*
* var z = cx.get( 0 );
* // returns <Complex64>
*
* var re = realf( z );
* // returns -2.0
*
* var im = imagf( z );
* // returns 6.0
* cscal.ndarray( 3, ca, cx, 1, 0 );
* // cx => <Complex64Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.0 ]
*/
declare var cscal: Routine;

Expand Down
12 changes: 1 addition & 11 deletions lib/node_modules/@stdlib/blas/base/cscal/lib/cscal.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,12 @@ var ndarray = require( './ndarray.js' );
* @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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var ca = new Complex64( 2.0, 2.0 );
*
* cscal( 3, ca, cx, 1 );
*
* var z = cx.get( 0 );
* // returns <Complex64>
*
* var re = realf( z );
* // returns -2.0
*
* var im = imagf( z );
* // returns 6.0
* // cx => <Complex64Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.0 ]
*/
function cscal( N, ca, cx, strideX ) {
var ox = stride2offset( N, strideX );
Expand Down
12 changes: 1 addition & 11 deletions lib/node_modules/@stdlib/blas/base/cscal/lib/cscal.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,12 @@ var addon = require( './../src/addon.node' );
* @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 cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var ca = new Complex64( 2.0, 2.0 );
*
* cscal( cx.length, ca, cx, 1 );
*
* var z = cx.get( 0 );
* // returns <Complex64>
*
* var re = realf( z );
* // returns -2.0
*
* var im = imagf( z );
* // returns 6.0
* // cx => <Complex64Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.0 ]
*/
function cscal( N, ca, cx, strideX ) {
var viewCX = reinterpret( cx, 0 );
Expand Down
24 changes: 2 additions & 22 deletions lib/node_modules/@stdlib/blas/base/cscal/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,24 @@
* @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 cscal = require( '@stdlib/blas/base/cscal' );
*
* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var ca = new Complex64( 2.0, 2.0 );
*
* cscal( 3, ca, cx, 1 );
*
* var z = cx.get( 0 );
* // returns <Complex64>
*
* var re = realf( z );
* // returns -2.0
*
* var im = imagf( z );
* // returns 6.0
* // cx => <Complex64Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.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 cscal = require( '@stdlib/blas/base/cscal' );
*
* var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
* var ca = new Complex64( 2.0, 2.0 );
*
* cscal.ndarray( 3, ca cx, 1, 0 );
*
* var z = cx.get( 0 );
* // returns <Complex64>
*
* var re = realf( z );
* // returns -2.0
*
* var im = imagf( z );
* // returns 6.0
* // cx => <Complex64Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.0 ]
*/

// MODULES //
Expand Down
Loading
Loading