Thanks to visit codestin.com
Credit goes to github.com

Skip to content

docs: change variable naming in blas/base/cscal #6881

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
128 changes: 64 additions & 64 deletions lib/node_modules/@stdlib/blas/base/cscal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,39 @@ limitations under the License.
var cscal = require( '@stdlib/blas/base/cscal' );
```

#### cscal( N, ca, cx, strideX )
#### cscal( N, alpha, x, strideX )

Scales values from `cx` by `ca`.
Scales values from `x` by `alpha`.

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );

var cx = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] );
var ca = new Complex64( 2.0, 0.0 );
var x = new Complex64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] );
var alpha = new Complex64( 2.0, 0.0 );

cscal( 3, ca, cx, 1 );
// cx => <Complex64Array>[ 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 ]
cscal( 3, alpha, x, 1 );
// x => <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.
- **cx**: input [`Complex64Array`][@stdlib/array/complex64].
- **strideX**: index increment for `cx`.
- **alpha**: scalar [`Complex64`][@stdlib/complex/float32/ctor] constant.
- **x**: input [`Complex64Array`][@stdlib/array/complex64].
- **strideX**: index increment for `x`.

The `N` and stride parameters determine how values from `cx` are scaled by `ca`. For example, to scale every other value in `cx` by `ca`,
The `N` and stride parameters determine how values from `x` are scaled by `alpha`. For example, to scale every other value in `x` by `alpha`,

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );

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 );
var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
var alpha = new Complex64( 2.0, 0.0 );

cscal( 2, ca, cx, 2 );
// cx => <Complex64Array>[ 2.0, 4.0, 3.0, 4.0, 10.0, 12.0, 7.0, 8.0 ]
cscal( 2, alpha, x, 2 );
// x => <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 @@ -74,49 +74,49 @@ var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );

// Initial array:
var cx0 = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
var x0 = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );

// Define a scalar constant:
var ca = new Complex64( 2.0, 2.0 );
var alpha = new Complex64( 2.0, 2.0 );

// Create an offset view:
var cx1 = new Complex64Array( cx0.buffer, cx0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var x1 = new Complex64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

// Scales every other value from `cx1` by `ca`...
cscal( 3, ca, cx1, 1 );
// cx0 => <Complex64Array>[ 1.0, 2.0, -2.0, 14.0, -2.0, 22.0, -2.0, 30.0 ]
// Scales every other value from `x1` by `alpha`...
cscal( 3, alpha, x1, 1 );
// x0 => <Complex64Array>[ 1.0, 2.0, -2.0, 14.0, -2.0, 22.0, -2.0, 30.0 ]
```

#### cscal.ndarray( N, ca, cx, strideX, offsetX )
#### cscal.ndarray( N, alpha, x, strideX, offsetX )

Scales values from `cx` by `ca` using alternative indexing semantics.
Scales values from `x` by `alpha` using alternative indexing semantics.

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );

var cx = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var ca = new Complex64( 2.0, 2.0 );
var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
var alpha = new Complex64( 2.0, 2.0 );

cscal.ndarray( 3, ca, cx, 1, 0 );
// cx => <Complex64Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.0 ]
cscal.ndarray( 3, alpha, x, 1, 0 );
// x => <Complex64Array>[ -2.0, 6.0, -2.0, 14.0, -2.0, 22.0 ]
```

The function has the following additional parameters:

- **offsetX**: starting index for `cx`.
- **offsetX**: starting index for `x`.

While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to scale every other value in the input strided array starting from the second element,

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );

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 );
var x = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] );
var alpha = new Complex64( 2.0, 2.0 );

cscal.ndarray( 2, ca, cx, 2, 1 );
// cx => <Complex64Array>[ 1.0, 2.0, -2.0, 14.0, 5.0, 6.0, -2.0, 30.0 ]
cscal.ndarray( 2, alpha, x, 2, 1 );
// x => <Complex64Array>[ 1.0, 2.0, -2.0, 14.0, 5.0, 6.0, -2.0, 30.0 ]
```

</section>
Expand All @@ -127,7 +127,7 @@ cscal.ndarray( 2, ca, cx, 2, 1 );

## Notes

- If `N <= 0` or `strideX <= 0`, both functions return `cx` unchanged.
- If `N <= 0` or `strideX <= 0`, both functions return `x` unchanged.
- `cscal()` corresponds to the [BLAS][blas] level 1 function [`cscal`][cscal].

</section>
Expand All @@ -150,15 +150,15 @@ function rand() {
return new Complex64( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) );
}

var cx = filledarrayBy( 10, 'complex64', rand );
console.log( cx.toString() );
var x = filledarrayBy( 10, 'complex64', rand );
console.log( x.toString() );

var ca = new Complex64( 2.0, 2.0 );
console.log( ca.toString() );
var alpha = new Complex64( 2.0, 2.0 );
console.log( alpha.toString() );

// Scale elements from `cx` by `ca`:
cscal( cx.length, ca, cx, 1 );
console.log( cx.get( cx.length-1 ).toString() );
// Scale elements from `x` by `alpha`:
cscal( x.length, alpha, x, 1 );
console.log( x.get( x.length-1 ).toString() );
```

</section>
Expand Down Expand Up @@ -191,53 +191,53 @@ console.log( cx.get( cx.length-1 ).toString() );
#include "stdlib/blas/base/cscal.h"
```

#### c_cscal( N, ca, \*CX, strideX )
#### c_cscal( N, alpha, \*X, strideX )

Scales values from `CX` by `ca`.
Scales values from `X` by `alpha`.

```c
#include "stdlib/complex/float32/ctor.h"

float cx[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
const stdlib_complex64_t ca = stdlib_complex64( 2.0f, 2.0f );
float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
const stdlib_complex64_t alpha = stdlib_complex64( 2.0f, 2.0f );

c_cscal( 4, ca, (void *)cx, 1 );
c_cscal( 4, alpha, (void *)x, 1 );
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **ca**: `[in] stdlib_complex64_t` scalar constant.
- **CX**: `[inout] void*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `CX`.
- **alpha**: `[in] stdlib_complex64_t` scalar constant.
- **X**: `[inout] void*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `X`.

```c
void c_cscal( const CBLAS_INT N, const stdlib_complex64_t ca, void *CX, const CBLAS_INT strideX );
void c_cscal( const CBLAS_INT N, const stdlib_complex64_t alpha, void *X, const CBLAS_INT strideX );
```

#### c_cscal_ndarray( N, ca, \*CX, strideX, offsetX )
#### c_cscal_ndarray( N, alpha, \*X, strideX, offsetX )

Scales values from `CX` by `ca` using alternative indexing semantics.
Scales values from `X` by `alpha` using alternative indexing semantics.

```c
#include "stdlib/complex/float32/ctor.h"

float cx[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
const stdlib_complex64_t ca = stdlib_complex64( 2.0f, 2.0f );
float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
const stdlib_complex64_t alpha = stdlib_complex64( 2.0f, 2.0f );

c_cscal( 4, ca, (void *)cx, 1, 0 );
c_cscal( 4, alpha, (void *)x, 1, 0 );
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **ca**: `[in] stdlib_complex64_t` scalar constant.
- **CX**: `[inout] void*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `CX`.
- **offsetX**: `[in] CBLAS_INT` starting index for `CX`.
- **alpha**: `[in] stdlib_complex64_t` scalar constant.
- **X**: `[inout] void*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.

```c
void c_cscal_ndarray( const CBLAS_INT N, const stdlib_complex64_t ca, void *CX, const CBLAS_INT strideX, const CBLAS_INT offsetX );
void c_cscal_ndarray( const CBLAS_INT N, const stdlib_complex64_t alpha, void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
```

</section>
Expand Down Expand Up @@ -265,10 +265,10 @@ void c_cscal_ndarray( const CBLAS_INT N, const stdlib_complex64_t ca, void *CX,

int main( void ) {
// Create a strided array of interleaved real and imaginary components:
float cx[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };
float x[] = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f };

// Create a complex scalar:
const stdlib_complex64_t ca = stdlib_complex64( 2.0f, 2.0f );
const stdlib_complex64_t alpha = stdlib_complex64( 2.0f, 2.0f );

// Specify the number of elements:
const int N = 4;
Expand All @@ -277,19 +277,19 @@ int main( void ) {
const int strideX = 1;

// Scale the elements of the array:
c_cscal( N, ca, (void *)cx, strideX );
c_cscal( N, alpha, (void *)x, strideX );

// Print the result:
for ( int i = 0; i < N; i++ ) {
printf( "cx[ %i ] = %f + %fj\n", i, cx[ i*2 ], cx[ (i*2)+1 ] );
printf( "x[ %i ] = %f + %fj\n", i, x[ i*2 ], x[ (i*2)+1 ] );
}

// Scale the elements of the array:
c_cscal_ndarray( N, ca, (void *)cx, -strideX, 3 );
c_cscal_ndarray( N, alpha, (void *)x, -strideX, 3 );

// Print the result:
for ( int i = 0; i < N; i++ ) {
printf( "cx[ %i ] = %f + %fj\n", i, cx[ i*2 ], cx[ (i*2)+1 ] );
printf( "x[ %i ] = %f + %fj\n", i, x[ i*2 ], x[ (i*2)+1 ] );
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ var options = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var alpha;
var xbuf;
var z;
var x;

xbuf = uniform( len*2, -100.0, 100.0, options );
x = new Complex64Array( xbuf.buffer );

z = new Complex64( 1.0, 0.0 );
alpha = new Complex64( 1.0, 0.0 );

return benchmark;

Expand All @@ -69,7 +69,7 @@ function createBenchmark( len ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
cscal( x.length, z, x, 1 );
cscal( x.length, alpha, x, 1 );
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ var options = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var alpha;
var xbuf;
var z;
var x;

xbuf = uniform( len*2, -100.0, 100.0, options );
x = new Complex64Array( xbuf.buffer );

z = new Complex64( 1.0, 0.0 );
alpha = new Complex64( 1.0, 0.0 );

return benchmark;

Expand All @@ -74,7 +74,7 @@ function createBenchmark( len ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
cscal( x.length, z, x, 1 );
cscal( x.length, alpha, x, 1 );
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ var options = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var alpha;
var xbuf;
var z;
var x;

xbuf = uniform( len*2, -100.0, 100.0, options );
x = new Complex64Array( xbuf.buffer );

z = new Complex64( 1.0, 0.0 );
alpha = new Complex64( 1.0, 0.0 );

return benchmark;

Expand All @@ -69,7 +69,7 @@ function createBenchmark( len ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
cscal( x.length, z, x, 1, 0 );
cscal( x.length, alpha, x, 1, 0 );
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ var options = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var alpha;
var xbuf;
var z;
var x;

xbuf = uniform( len*2, -100.0, 100.0, options );
x = new Complex64Array( xbuf.buffer );

z = new Complex64( 1.0, 0.0 );
alpha = new Complex64( 1.0, 0.0 );

return benchmark;

Expand All @@ -74,7 +74,7 @@ function createBenchmark( len ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
cscal( x.length, z, x, 1, 0 );
cscal( x.length, alpha, x, 1, 0 );
if ( isnanf( xbuf[ i%(len*2) ] ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Loading