Skip to content

docs: change variable naming for blas/base/scasum #7193

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

Merged
merged 4 commits into from
Jun 7, 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
68 changes: 34 additions & 34 deletions lib/node_modules/@stdlib/blas/base/scasum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,33 @@ limitations under the License.
var scasum = require( '@stdlib/blas/base/scasum' );
```

#### scasum( N, cx, strideX )
#### scasum( N, x, strideX )

Computes the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector.

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

var cx = new Complex64Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] );
var x = new Complex64Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] );

var out = scasum( 4, cx, 1 );
var out = scasum( 4, x, 1 );
// returns ~1.6
```

The function has the following parameters:

- **N**: number of indexed elements.
- **cx**: input [`Complex64Array`][@stdlib/array/complex64].
- **strideX**: index increment for `cx`.
- **x**: input [`Complex64Array`][@stdlib/array/complex64].
- **strideX**: index increment for `x`.

The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to traverse every other value,

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

var cx = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );
var x = new Complex64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] );

var out = scasum( 2, cx, 2 );
var out = scasum( 2, x, 2 );
// returns 7.0
```

Expand All @@ -66,26 +66,26 @@ Note that indexing is relative to the first index. To introduce an offset, use [
var Complex64Array = require( '@stdlib/array/complex64' );

// Initial array:
var cx0 = new Complex64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
var x0 = new Complex64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.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

// Compute the L2-out:
var out = scasum( 2, cx1, 1 );
var out = scasum( 2, x1, 1 );
// returns 18.0
```

#### scasum.ndarray( N, cx, strideX, offset )
#### scasum.ndarray( N, x, strideX, offset )

Computes the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector using alternative indexing semantics.

```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

var cx = new Complex64Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] );
var x = new Complex64Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] );

var out = scasum.ndarray( 4, cx, 1, 0 );
var out = scasum.ndarray( 4, x, 1, 0 );
// returns ~1.6
```

Expand All @@ -98,9 +98,9 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the
```javascript
var Complex64Array = require( '@stdlib/array/complex64' );

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

var out = scasum.ndarray( 2, cx, 1, 1 );
var out = scasum.ndarray( 2, x, 1, 1 );
// returns 18.0
```

Expand Down Expand Up @@ -135,11 +135,11 @@ 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() );

// Compute the sum of the absolute values of real and imaginary components:
var out = scasum( cx.length, cx, 1 );
var out = scasum( x.length, x, 1 );
console.log( out );
```

Expand Down Expand Up @@ -173,47 +173,47 @@ console.log( out );
#include "stdlib/blas/base/scasum.h"
```

#### c_scasum( N, \*CX, strideX )
#### c_scasum( N, \*X, strideX )

Computes the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector.

```c
const float cx[] = { 0.3f, 0.1f, 0.5f, 0.0f, 0.0f, 0.5f, 0.0f, 0.2f };
const float X[] = { 0.3f, 0.1f, 0.5f, 0.0f, 0.0f, 0.5f, 0.0f, 0.2f };

float out = c_scasum( 4, (void *)cx, 1 );
float out = c_scasum( 4, (void *)X, 1 );
// returns 1.6f
```

The function accepts the following arguments:

- **N**: `[in] CBLAS_INT` number of indexed elements.
- **CX**: `[in] void*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `CX`.
- **X**: `[in] void*` input array.
- **strideX**: `[in] CBLAS_INT` index increment for `X`.

```c
float c_scasum( const CBLAS_INT N, const void *CX, const CBLAS_INT strideX );
float c_scasum( const CBLAS_INT N, const void *X, const CBLAS_INT strideX );
```

#### c_scasum_ndarray( N, \*CX, strideX, offsetX )
#### c_scasum_ndarray( N, \*X, strideX, offsetX )

Computes the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector using alternative indexing semantics.

```c
const float cx[] = { 0.3f, 0.1f, 0.5f, 0.0f, 0.0f, 0.5f, 0.0f, 0.2f };
const float X[] = { 0.3f, 0.1f, 0.5f, 0.0f, 0.0f, 0.5f, 0.0f, 0.2f };

float out = c_scasum_ndarray( 4, (void *)cx, 1, 0 );
float out = c_scasum_ndarray( 4, (void *)X, 1, 0 );
// returns 1.6f
```

The function accepts the following arguments:

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

```c
float c_scasum_ndarray( const CBLAS_INT N, const void *CX, const CBLAS_INT strideX, const CBLAS_INT offsetX );
float c_scasum_ndarray( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
```

</section>
Expand All @@ -240,7 +240,7 @@ float c_scasum_ndarray( const CBLAS_INT N, const void *CX, const CBLAS_INT strid

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

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

// Compute the sum of the absolute values of real and imaginary components:
float out = c_scasum( N, (void *)cx, strideX );
float out = c_scasum( N, (void *)X, strideX );

// Print the result:
printf( "out: %f\n", out );

// Compute the sum of the absolute values of real and imaginary components using alternative indexing semantics:
out = c_scasum_ndarray( N, (void *)cx, -strideX, N-1 );
out = c_scasum_ndarray( N, (void *)X, -strideX, N-1 );

// Print the result:
printf( "out: %f\n", out );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var options = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var cx = new Complex64Array( uniform( len*2, -10.0, 10.0, options ) );
var x = new Complex64Array( uniform( len*2, -10.0, 10.0, options ) );
return benchmark;

function benchmark( b ) {
Expand All @@ -55,7 +55,7 @@ function createBenchmark( len ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = scasum( cx.length, cx, 1 );
out = scasum( x.length, x, 1 );
if ( isnanf( out ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var options = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var cx = new Complex64Array( uniform( len*2, -10.0, 10.0, options ) );
var x = new Complex64Array( uniform( len*2, -10.0, 10.0, options ) );
return benchmark;

function benchmark( b ) {
Expand All @@ -60,7 +60,7 @@ function createBenchmark( len ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = scasum( cx.length, cx, 1 );
out = scasum( x.length, x, 1 );
if ( isnanf( out ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var options = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var cx = new Complex64Array( uniform( len*2, -10.0, 10.0, options ) );
var x = new Complex64Array( uniform( len*2, -10.0, 10.0, options ) );
return benchmark;

function benchmark( b ) {
Expand All @@ -55,7 +55,7 @@ function createBenchmark( len ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = scasum( cx.length, cx, 1, 0 );
out = scasum( x.length, x, 1, 0 );
if ( isnanf( out ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var options = {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var cx = new Complex64Array( uniform( len*2, -10.0, 10.0, options ) );
var x = new Complex64Array( uniform( len*2, -10.0, 10.0, options ) );
return benchmark;

function benchmark( b ) {
Expand All @@ -60,7 +60,7 @@ function createBenchmark( len ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = scasum( cx.length, cx, 1, 0 );
out = scasum( x.length, x, 1, 0 );
if ( isnanf( out ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@ static float rand_float( void ) {
* @return elapsed time in seconds
*/
static double benchmark1( int iterations, int len ) {
float cx[ len*2 ];
float X[ len*2 ];
double elapsed;
float out;
double t;
int i;

for ( i = 0; i < len*2; i += 2 ) {
cx[ i ] = ( rand_float()*10000.0f ) - 5000.0f;
cx[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f;
X[ i ] = ( rand_float()*10000.0f ) - 5000.0f;
X[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f;
}
out = 0.0f;
t = tic();
for ( i = 0; i < iterations; i++ ) {
out = c_scasum( len, (void *)cx, 1 );
out = c_scasum( len, (void *)X, 1 );
if ( out != out ) {
printf( "should not return NaN\n" );
break;
Expand All @@ -129,20 +129,20 @@ static double benchmark1( int iterations, int len ) {
* @return elapsed time in seconds
*/
static double benchmark2( int iterations, int len ) {
float cx[ len*2 ];
float X[ len*2 ];
double elapsed;
float out;
double t;
int i;

for ( i = 0; i < len*2; i += 2 ) {
cx[ i ] = ( rand_float()*10000.0f ) - 5000.0f;
cx[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f;
X[ i ] = ( rand_float()*10000.0f ) - 5000.0f;
X[ i+1 ] = ( rand_float()*10000.0f ) - 5000.0f;
}
out = 0.0f;
t = tic();
for ( i = 0; i < iterations; i++ ) {
out = c_scasum_ndarray( len, (void *)cx, 1, 0 );
out = c_scasum_ndarray( len, (void *)X, 1, 0 );
if ( out != out ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ double precision function benchmark( iterations, len )
! ..
! External functions:
interface
real function scasum( N, cx, strideX )
complex :: cx(*)
real function scasum( N, x, strideX )
complex :: x(*)
integer :: strideX, N
end function scasum
end interface
Expand Down
Loading