Skip to content
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/dznrm2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,33 @@ limitations under the License.
var dznrm2 = require( '@stdlib/blas/base/dznrm2' );
```

#### dznrm2( N, zx, strideX )
#### dznrm2( N, x, strideX )

Computes the L2-norm of a complex double-precision floating-point vector.

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );

var zx = new Complex128Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] );
var x = new Complex128Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] );

var norm = dznrm2( 4, zx, 1 );
var norm = dznrm2( 4, x, 1 );
// returns ~0.8
```

The function has the following parameters:

- **N**: number of indexed elements.
- **zx**: input [`Complex128Array`][@stdlib/array/complex128].
- **strideX**: index increment for `zx`.
- **x**: input [`Complex128Array`][@stdlib/array/complex128].
- **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 Complex128Array = require( '@stdlib/array/complex128' );

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

var norm = dznrm2( 2, zx, 2 );
var norm = dznrm2( 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 Complex128Array = require( '@stdlib/array/complex128' );

// Initial array:
var zx0 = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
var x0 = new Complex128Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );

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

// Compute the L2-norm:
var norm = dznrm2( 2, zx1, 1 );
var norm = dznrm2( 2, x1, 1 );
// returns ~9.3
```

#### dznrm2.ndarray( N, zx, strideX, offset )
#### dznrm2.ndarray( N, x, strideX, offset )

Computes the L2-norm of a complex double-precision floating-point vector using alternative indexing semantics.

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );

var zx = new Complex128Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] );
var x = new Complex128Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 ] );

var norm = dznrm2.ndarray( 4, zx, 1, 0 );
var norm = dznrm2.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 Complex128Array = require( '@stdlib/array/complex128' );

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

var norm = dznrm2.ndarray( 2, zx, 1, 1 );
var norm = dznrm2.ndarray( 2, x, 1, 1 );
// returns ~9.3
```

Expand Down Expand Up @@ -135,11 +135,11 @@ function rand() {
return new Complex128( discreteUniform( 0, 10 ), discreteUniform( -5, 5 ) );
}

var zx = filledarrayBy( 10, 'complex128', rand );
console.log( zx.toString() );
var x = filledarrayBy( 10, 'complex128', rand );
console.log( x.toString() );

// Computes the L2-norm:
var norm = dznrm2( zx.length, zx, 1 );
var norm = dznrm2( x.length, x, 1 );
console.log( norm );
```

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

#### c_dznrm2( N, \*ZX, strideX )
#### c_dznrm2( N, \*X, strideX )

Computes the L2-norm of a complex double-precision floating-point vector.

```c
const double zx[] = { 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 };
const double X[] = { 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 };

double norm = c_dznrm2( 4, (void *)zx, 1 );
double norm = c_dznrm2( 4, (void *)X, 1 );
// returns 0.8
```

The function accepts the following arguments:

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

```c
double c_dznrm2( const CBLAS_INT N, const void *ZX, const CBLAS_INT strideX );
double c_dznrm2( const CBLAS_INT N, const void *X, const CBLAS_INT strideX );
```

#### c_dznrm2_ndarray( N, \*ZX, strideX, offsetX )
#### c_dznrm2_ndarray( N, \*X, strideX, offsetX )

Computes the L2-norm of a complex double-precision floating-point vector using alternative indexing semantics.

```c
const double zx[] = { 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 };
const double X[] = { 0.3, 0.1, 0.5, 0.0, 0.0, 0.5, 0.0, 0.2 };

double norm = c_dznrm2_ndarray( 4, (void *)zx, 1, 0 );
double norm = c_dznrm2_ndarray( 4, (void *)X, 1, 0 );
// returns 0.8
```

The function accepts the following arguments:

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

```c
double c_dznrm2_ndarray( const CBLAS_INT N, const void *ZX, const CBLAS_INT strideX, const CBLAS_INT offsetX );
double c_dznrm2_ndarray( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
```

</section>
Expand All @@ -240,7 +240,7 @@ double c_dznrm2_ndarray( const CBLAS_INT N, const void *ZX, const CBLAS_INT stri

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

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

// Compute the L2-norm:
double norm = c_dznrm2( N, (void *)zx, strideX );
double norm = c_dznrm2( N, (void *)X, strideX );

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

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

// Print the result:
printf( "L2-norm: %lf\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 zx = new Complex128Array( uniform( len*2, -10.0, 10.0, options ) );
var x = new Complex128Array( 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 = dznrm2( zx.length, zx, 1 );
norm = dznrm2( x.length, x, 1 );
if ( isnan( 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 zx = new Complex128Array( uniform( len*2, -10.0, 10.0, options ) );
var x = new Complex128Array( 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 = dznrm2( zx.length, zx, 1 );
norm = dznrm2( x.length, x, 1 );
if ( isnan( 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 zx = new Complex128Array( uniform( len*2, -10.0, 10.0, options ) );
var x = new Complex128Array( 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 = dznrm2( zx.length, zx, 1, 0 );
norm = dznrm2( x.length, x, 1, 0 );
if ( isnan( 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 zx = new Complex128Array( uniform( len*2, -10.0, 10.0, options ) );
var x = new Complex128Array( 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 = dznrm2( zx.length, zx, 1, 0 );
norm = dznrm2( x.length, x, 1, 0 );
if ( isnan( 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 double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark1( int iterations, int len ) {
double zx[ len*2 ];
double X[ len*2 ];
double elapsed;
double norm;
double t;
int i;

for ( i = 0; i < len*2; i += 2 ) {
zx[ i ] = ( rand_double()*10000.0 ) - 5000.0;
zx[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0;
X[ i ] = ( rand_double()*10000.0 ) - 5000.0;
X[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0;
}
norm = 0.0;
t = tic();
for ( i = 0; i < iterations; i++ ) {
norm = c_dznrm2( len, (void *)zx, 1 );
norm = c_dznrm2( 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 ) {
double zx[ len*2 ];
double X[ len*2 ];
double elapsed;
double norm;
double t;
int i;

for ( i = 0; i < len*2; i += 2 ) {
zx[ i ] = ( rand_double()*10000.0 ) - 5000.0;
zx[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0;
X[ i ] = ( rand_double()*10000.0 ) - 5000.0;
X[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0;
}
norm = 0.0;
t = tic();
for ( i = 0; i < iterations; i++ ) {
norm = c_dznrm2_ndarray( len, (void *)zx, 1, 0 );
norm = c_dznrm2_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
double precision function dznrm2( N, zx, strideX )
complex(kind=kind(0.0d0)) :: zx(*)
double precision function dznrm2( N, x, strideX )
complex(kind=kind(0.0d0)) :: x(*)
integer :: strideX, N
end function dznrm2
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