Skip to content

docs: change variable naming for blas/base/scnrm2 #7176

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 2 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
66 changes: 33 additions & 33 deletions lib/node_modules/@stdlib/blas/base/scnrm2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,33 @@ limitations under the License.
var scnrm2 = require( '@stdlib/blas/base/scnrm2' );
```

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

Computes the L2-norm of a complex single-precision 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 norm = scnrm2( 4, cx, 1 );
var norm = scnrm2( 4, x, 1 );
// returns ~0.8
```

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 norm = scnrm2( 2, cx, 2 );
var norm = scnrm2( 2, x, 2 );
// returns ~4.6
```

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-norm:
var norm = scnrm2( 2, cx1, 1 );
var norm = scnrm2( 2, x1, 1 );
// returns ~9.3
```

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

Computes the L2-norm of a complex single-precision 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 norm = scnrm2.ndarray( 4, cx, 1, 0 );
var norm = scnrm2.ndarray( 4, x, 1, 0 );
// returns ~0.8
```

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 norm = scnrm2.ndarray( 2, cx, 1, 1 );
var norm = scnrm2.ndarray( 2, x, 1, 1 );
// returns ~9.3
```

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 L2-norm:
var norm = scnrm2( cx.length, cx, 1 );
var norm = scnrm2( x.length, x, 1 );
console.log( norm );
```

Expand Down Expand Up @@ -173,46 +173,46 @@ console.log( norm );
#include "stdlib/blas/base/scnrm2.h"
```

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

Computes the L2-norm of a complex single-precision 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 norm = c_scnrm2( 4, (void *)cx, 1 );
float norm = c_scnrm2( 4, (void *)X, 1 );
// returns 0.8f
```

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_scnrm2( const CBLAS_INT N, const void *CX, const CBLAS_INT strideX );
float c_scnrm2( const CBLAS_INT N, const void *X, const CBLAS_INT strideX );
```

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

Computes the L2-norm of a complex single-precision 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 norm = c_scnrm2_ndarray( 4, (void *)cx, 1, 0 );
float norm = c_scnrm2_ndarray( 4, (void *)X, 1, 0 );
// returns 0.8f
```

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_scnrm2_ndarray( const CBLAS_INT N, const void *CX, const CBLAS_INT strideX, const CBLAS_INT offsetX );
float c_scnrm2_ndarray( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
```

</section>
Expand All @@ -239,7 +239,7 @@ float c_scnrm2_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 @@ -248,13 +248,13 @@ int main( void ) {
const int strideX = 1;

// Compute the L2-norm:
float norm = c_scnrm2( N, (void *)cx, strideX );
float norm = c_scnrm2( N, (void *)X, strideX );

// Print the result:
printf( "L2-norm: %f\n", norm );

// Compute the L2-norm using alternative indexing semantics:
norm = c_scnrm2_ndarray( N, (void *)cx, -strideX, N-1 );
norm = c_scnrm2_ndarray( N, (void *)X, -strideX, N-1 );

// Print the result:
printf( "L2-norm: %f\n", norm );
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++ ) {
norm = scnrm2( cx.length, cx, 1 );
norm = scnrm2( x.length, x, 1 );
if ( isnanf( norm ) ) {
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++ ) {
norm = scnrm2( cx.length, cx, 1 );
norm = scnrm2( x.length, x, 1 );
if ( isnanf( norm ) ) {
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++ ) {
norm = scnrm2( cx.length, cx, 1, 0 );
norm = scnrm2( x.length, x, 1, 0 );
if ( isnanf( norm ) ) {
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++ ) {
norm = scnrm2( cx.length, cx, 1, 0 );
norm = scnrm2( x.length, x, 1, 0 );
if ( isnanf( norm ) ) {
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 norm;
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;
}
norm = 0.0f;
t = tic();
for ( i = 0; i < iterations; i++ ) {
norm = c_scnrm2( len, (void *)cx, 1 );
norm = c_scnrm2( len, (void *)X, 1 );
if ( norm != norm ) {
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 norm;
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;
}
norm = 0.0f;
t = tic();
for ( i = 0; i < iterations; i++ ) {
norm = c_scnrm2_ndarray( len, (void *)cx, 1, 0 );
norm = c_scnrm2_ndarray( len, (void *)X, 1, 0 );
if ( norm != norm ) {
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 scnrm2( N, cx, strideX )
complex :: cx(*)
real function scnrm2( N, x, strideX )
complex :: x(*)
integer :: strideX, N
end function scnrm2
end interface
Expand Down Expand Up @@ -217,4 +217,4 @@ subroutine main()
end do
call print_summary( count, count )
end subroutine main
end program bench
end program bench
Loading