Skip to content

Commit

Permalink
docs: update examples for blas/base/cscal
Browse files Browse the repository at this point in the history
PR-URL: stdlib-js#4942
Ref: stdlib-js#4833
Reviewed-by: Athan Reines <[email protected]>

---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: passed
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: passed
  - task: run_c_benchmarks
    status: na
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: failed
---
  • Loading branch information
gururaj1512 authored and saurabhraghuvanshii committed Jan 29, 2025
1 parent 9711748 commit d3e1396
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 197 deletions.
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

0 comments on commit d3e1396

Please sign in to comment.