Skip to content

Commit

Permalink
docs: update examples
Browse files Browse the repository at this point in the history
PR-URL: #2875
Ref: ff629c7#r146363058
Ref: ff629c7#r146363086
Ref: ff629c7#r146363121
Co-authored-by: Athan Reines <[email protected]>
Reviewed-by: Athan Reines <[email protected]>
  • Loading branch information
gunjjoshi and kgryte authored Sep 7, 2024
1 parent f13d569 commit 4e5bf6f
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 30 deletions.
24 changes: 13 additions & 11 deletions lib/node_modules/@stdlib/math/base/special/maxabsf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ var maxabsf = require( '@stdlib/math/base/special/maxabsf' );
Returns the maximum absolute single-precision floating-point number.

```javascript
var v = maxabsf( -4.2, 3.14 );
// returns ~4.2
var v = maxabsf( -4.0, 3.0 );
// returns 4.0

v = maxabsf( +0.0, -0.0 );
// returns +0.0
Expand Down Expand Up @@ -83,19 +83,21 @@ v = maxabsf( NaN, 3.14 );
<!-- eslint no-undef: "error" -->

```javascript
var randu = require( '@stdlib/random/base/randu' );
var randu = require( '@stdlib/random/array/uniform' );
var maxabsf = require( '@stdlib/math/base/special/maxabsf' );

var x;
var y;
var opts = {
'dtype': 'float32'
};

var x = randu( 100, -500.0, 500.0, opts );
var y = randu( 100, -500.0, 500.0, opts );

var v;
var i;

for ( i = 0; i < 100; i++ ) {
x = ( randu() * 1000.0 ) - 500.0;
y = ( randu() * 1000.0 ) - 500.0;
v = maxabsf( x, y );
console.log( 'maxabsf(%d,%d) = %d', x, y, v );
v = maxabsf( x[ i ], y[ i ] );
console.log( 'maxabsf(%d,%d) = %d', x[ i ], y[ i ], v );
}
```

Expand Down Expand Up @@ -178,7 +180,7 @@ int main( void ) {
float y;
float v;
int i;
for ( i = 0; i < 100; i++ ) {
x = ( ( (float)rand() / (float)RAND_MAX ) * 1000.0f ) - 500.0f;
y = ( ( (float)rand() / (float)RAND_MAX ) * 1000.0f ) - 500.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

Examples
--------
> var v = {{alias}}( 3.14, -4.2 )
~4.2
> var v = {{alias}}( -4.0, 3.0 )
4.0
> v = {{alias}}( 3.14, NaN )
NaN
> v = {{alias}}( +0.0, -0.0 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
* @returns maximum absolute value
*
* @example
* var v = maxabsf( 3.14, -4.2 );
* // returns 4.2
* var v = maxabsf( -4.0, 3.0 );
* // returns 4.0
*
* @example
* var v = maxabsf( 3.14, NaN );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@

'use strict';

var randu = require( '@stdlib/random/base/randu' );
var randu = require( '@stdlib/random/array/uniform' );
var maxabsf = require( './../lib' );

var x;
var y;
var opts = {
'dtype': 'float32'
};

var x = randu( 100, -500.0, 500.0, opts );
var y = randu( 100, -500.0, 500.0, opts );

var v;
var i;

for ( i = 0; i < 100; i++ ) {
x = ( randu() * 1000.0 ) - 500.0;
y = ( randu() * 1000.0 ) - 500.0;
v = maxabsf( x, y );
console.log( 'maxabsf(%d,%d) = %d', x, y, v );
v = maxabsf( x[ i ], y[ i ] );
console.log( 'maxabsf(%d,%d) = %d', x[ i ], y[ i ], v );
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
* @example
* var maxabsf = require( '@stdlib/math/base/special/maxabsf' );
*
* var v = maxabsf( 3.14, -4.2 );
* // returns ~4.2
* var v = maxabsf( -4.0, 3.0 );
* // returns 4.0
*
* v = maxabsf( 3.14, NaN );
* // returns NaN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
* @returns {number} maximum absolute value
*
* @example
* var v = maxabsf( 3.14, -4.2 );
* // returns ~4.2
* var v = maxabsf( -4.0, 3.0 );
* // returns 4.0
*
* @example
* var v = maxabsf( 3.14, NaN );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ var addon = require( './../src/addon.node' );
* @returns {number} maximum absolute value
*
* @example
* var v = maxabsf( -4.2, 3.14 );
* // returns ~4.2
* var v = maxabsf( -4.0, 3.0 );
* // returns 4.0
*
* @example
* var v = maxabsf( 0.0, -0.0 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @example
* float v = stdlib_base_maxabsf( 3.14f, -4.2f );
* // returns ~4.2f
* // returns 4.2f
*
* @example
* float v = stdlib_base_maxabsf( 0.0f, -0.0f );
Expand Down

1 comment on commit 4e5bf6f

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
math/base/special/maxabsf $\color{green}161/161$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}161/161$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.