Skip to content

Commit

Permalink
chore: apply review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-095 committed Jun 6, 2024
1 parent 8d8e966 commit a37d108
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 25 deletions.
102 changes: 99 additions & 3 deletions lib/node_modules/@stdlib/blas/base/scabs1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,114 @@ var Complex64 = require( '@stdlib/complex/float32/ctor' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var scabs1 = require( '@stdlib/blas/base/scabs1' );

var z;
var c;
var i;
for ( i = 0; i < 100; i++ ) {
z = new Complex64( discreteUniform( -50, 50 ), discreteUniform( -50, 50 ) );
console.log( 'scabs1(%s) = %d', z.toString(), scabs1( z ) );
c = new Complex64( discreteUniform( -50, 50 ), discreteUniform( -50, 50 ) );
console.log( 'scabs1(%s) = %d', c.toString(), scabs1( c ) );
}
```

</section>

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/blas/base/scabs1.h"
```

#### c_scabs1( c )

Computes the sum of the [absolute values][absolute-value] of the real and imaginary components of a single-precision [complex][@stdlib/complex/float32/ctor] floating-point number.

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

const stdlib_complex64_t c = stdlib_complex64( 3.14f, 1.0f );

c_scabs1( c );
```
The function accepts the following arguments:
- **c**: `[in] stdlib_complex64_t` complex number.
```c
void c_scabs1( const stdlib_complex64_t c );
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
#include "stdlib/blas/base/scabs1.h"
#include "stdlib/complex/float32/ctor.h"
#include "stdlib/complex/realf.h"
#include "stdlib/complex/imagf.h"
#include <stdio.h>

int main( void ) {
const stdlib_complex64_t x[] = {
stdlib_complex64( 3.14f, 1.0f ),
stdlib_complex64( -3.14f, -1.0f ),
stdlib_complex64( 0.0f, 0.0f ),
stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f )
};

float y;
int i;
for ( i = 0; i < 4; i++ ) {
y = c_scabs1( x[ i ] );
printf( "f(%f + %f) = %f\n", stdlib_realf( x[ i ] ), stdlib_imagf( x[ i ] ), y );
}
}
```
</section>
<!-- /.examples -->
</section>
<!-- /.c -->
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
<section class="related">
Expand Down
13 changes: 3 additions & 10 deletions lib/node_modules/@stdlib/blas/base/scabs1/benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,13 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var pkg = require( './../package.json' ).name;
var scabs1 = require( './../lib' );


// VARIABLES //

var options = {
'dtype': 'float32'
};


// MAIN //

bench( pkg, function benchmark( b ) {
Expand All @@ -43,8 +36,8 @@ bench( pkg, function benchmark( b ) {
var i;

values = [
new Complex64( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ), // eslint-disable-line max-len
new Complex64( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ) // eslint-disable-line max-len
new Complex64( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ), // eslint-disable-line max-len
new Complex64( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ) // eslint-disable-line max-len
];

b.tic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var tryRequire = require( '@stdlib/utils/try-require' );
Expand All @@ -35,9 +35,6 @@ var scabs1 = tryRequire( resolve( __dirname, './../lib/native.js' ) );
var opts = {
'skip': ( scabs1 instanceof Error )
};
var options = {
'dtype': 'float32'
};


// MAIN //
Expand All @@ -48,8 +45,8 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var i;

values = [
new Complex64( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ), // eslint-disable-line max-len
new Complex64( uniform( -500.0, 500.0, options ), uniform( -500.0, 500.0, options ) ) // eslint-disable-line max-len
new Complex64( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ), // eslint-disable-line max-len
new Complex64( discreteUniform( -500.0, 500.0 ), discreteUniform( -500.0, 500.0 ) ) // eslint-disable-line max-len
];

b.tic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ LIBRARIES ?=
LIBPATH ?=

# List of C targets:
c_targets := benchmark.length.out
c_targets := benchmark.out


# RULES #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ INCLUDE ?=
SOURCE_FILES ?= ../../src/scabs1.f

# List of Fortran targets:
f_targets := benchmark.length.out
f_targets := benchmark.out


# RULES #
Expand Down
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/blas/base/scabs1/examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@

'use strict';

var Complex128 = require( '@stdlib/complex/float64/ctor' );
var Complex64 = require( '@stdlib/complex/float32/ctor' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
var scabs1 = require( './../lib' );

// Create a PRNG to generate uniformly distributed pseudorandom integers:
var rand = discreteUniform( -50, 50 );

// Compute the sum of the absolute values of real and imaginary parts for a set of complex numbers...
var z;
var c;
var i;
for ( i = 0; i < 100; i++ ) {
z = new Complex128( rand(), rand() );
console.log( 'scabs1(%s) = %d', z.toString(), scabs1( z ) );
c = new Complex64( rand(), rand() );
console.log( 'scabs1(%s) = %d', c.toString(), scabs1( c ) );
}

0 comments on commit a37d108

Please sign in to comment.