Skip to content

Commit

Permalink
chore: update descriptions, update test descriptions, and refactor be…
Browse files Browse the repository at this point in the history
…nchmarks
  • Loading branch information
kgryte committed Aug 23, 2024
1 parent 7f52faf commit dce2b90
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 49 deletions.
14 changes: 7 additions & 7 deletions lib/node_modules/@stdlib/math/base/special/minf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.

# minf

> Return the minimum value (single-precision).
> Return the minimum single-precision floating-point number.
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

Expand All @@ -42,7 +42,7 @@ var minf = require( '@stdlib/math/base/special/minf' );

#### minf( x, y )

Returns the minimum value (single-precision).
Returns the minimum single-precision floating-point number.

```javascript
var v = minf( 4.2, 3.14 );
Expand Down Expand Up @@ -131,14 +131,14 @@ for ( i = 0; i < 100; i++ ) {

#### stdlib_base_minf( x, y )

Returns the minimum value (single-precision).
Returns the minimum single-precision floating-point number.

```c
float out = stdlib_base_minf( 4.2, 3.14 );
// returns 3.14
float out = stdlib_base_minf( 4.2f, 3.14f );
// returns 3.14f

out = stdlib_base_minf( 0.0, -0.0 );
// returns -0.0
out = stdlib_base_minf( 0.0f, -0.0f );
// returns -0.0f
```

The function accepts the following arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var randu = require( '@stdlib/random/array/uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var pkg = require( './../package.json' ).name;
var minf = require( './../lib' );
Expand All @@ -35,11 +35,12 @@ bench( pkg, function benchmark( b ) {
var z;
var i;

x = randu( 100, -100.0, 100.0 );
y = randu( 100, -100.0, 100.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 1000.0 ) - 500.0;
y = ( randu() * 1000.0 ) - 500.0;
z = minf( x, y );
z = minf( x[ i%x.length ], y[ i%y.length ] );
if ( isnanf( z ) ) {
b.fail( 'should not return NaN' );
}
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 randu = require( '@stdlib/random/base/randu' );
var randu = require( '@stdlib/random/array/uniform' );
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
Expand All @@ -44,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var z;
var i;

x = randu( 100, -100.0, 100.0 );
y = randu( 100, -100.0, 100.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 200.0 ) - 100.0;
y = ( randu() * 200.0 ) - 100.0;
z = minf( x, y );
z = minf( x[ i%x.length ], y[ i%y.length ] );
if ( isnanf( z ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,19 @@ static float rand_float( void ) {
static double benchmark( void ) {
double elapsed;
double t;
float x;
float y;
float x[ 100 ];
float y[ 100 ];
float z;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = ( 200.0f * rand_float() ) - 100.0f;
y[ i ] = ( 200.0f * rand_float() ) - 100.0f;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = ( 200.0f * rand_float() ) - 100.0f;
y = ( 200.0f * rand_float() ) - 100.0f;
z = stdlib_base_minf( x, y );
z = stdlib_base_minf( x[ i%100 ], y[ i%100 ] );
if ( z != z ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

{{alias}}( x, y )
Returns the minimum value (single-precision).
Returns the minimum single-precision floating-point number.

If any argument is `NaN`, the function returns `NaN`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// TypeScript Version: 4.1

/**
* Returns the minimum value (single-precision).
* Returns the minimum single-precision floating-point number.
*
* @param x - first number
* @param y - second number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" {
#endif

/**
* Returns the minimum value (single-precision).
* Returns the minimum single-precision floating-point number.
*/
float stdlib_base_minf( const float x, const float y );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'use strict';

/**
* Return the minimum value (single-precision).
* Return the minimum single-precision floating-point number.
*
* @module @stdlib/math/base/special/minf
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var NINF = require( '@stdlib/constants/float32/ninf' );
// MAIN //

/**
* Returns the minimum value (single-precision).
* Returns the minimum single-precision floating-point number.
*
* @param {number} x - first number
* @param {number} y - second number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' );
// MAIN //

/**
* Return the minimum value (single-precision).
* Returns the minimum single-precision floating-point number.
*
* @private
* @param {number} x - first number
Expand Down
6 changes: 4 additions & 2 deletions lib/node_modules/@stdlib/math/base/special/minf/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@stdlib/math/base/special/minf",
"version": "0.0.0",
"description": "Return the minimum value (single-precision).",
"description": "Return the minimum single-precision floating-point number.",
"license": "Apache-2.0",
"author": {
"name": "The Stdlib Authors",
Expand Down Expand Up @@ -59,6 +59,8 @@
"math.min",
"minimum",
"min",
"smallest"
"smallest",
"float32",
"float"
]
}
10 changes: 5 additions & 5 deletions lib/node_modules/@stdlib/math/base/special/minf/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
#include "stdlib/constants/float32/ninf.h"

/**
* Return the minimum value (single-precision).
* Returns the minimum single-precision floating-point number.
*
* @param x first number
* @param y second number
* @return minimum value
*
* @example
* float v = stdlib_base_minf( 3.14, 4.2 );
* // returns 3.14
* float v = stdlib_base_minf( 3.14f, 4.2f );
* // returns 3.14f
*
* @example
* float v = stdlib_base_minf( 0.0, -0.0 );
* // returns -0.0
* float v = stdlib_base_minf( 0.0f, -0.0f );
* // returns -0.0f
*/
float stdlib_base_minf( const float x, const float y ) {
if ( stdlib_base_is_nanf( x ) || stdlib_base_is_nanf( y ) ) {
Expand Down
16 changes: 8 additions & 8 deletions lib/node_modules/@stdlib/math/base/special/minf/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ tape( 'the function returns `-Infinity` if provided `-Infinity`', function test(
var v;

v = minf( NINF, 3.14 );
t.strictEqual( v, NINF, 'returns -infinity' );
t.strictEqual( v, NINF, 'returns expected value' );

v = minf( 3.14, NINF );
t.strictEqual( v, NINF, 'returns -infinity' );
t.strictEqual( v, NINF, 'returns expected value' );

t.end();
});
Expand All @@ -65,16 +65,16 @@ tape( 'the function returns a correctly signed zero', function test( t ) {
var v;

v = minf( +0.0, -0.0 );
t.strictEqual( isNegativeZerof( v ), true, 'returns -0' );
t.strictEqual( isNegativeZerof( v ), true, 'returns expected value' );

v = minf( -0.0, +0.0 );
t.strictEqual( isNegativeZerof( v ), true, 'returns -0' );
t.strictEqual( isNegativeZerof( v ), true, 'returns expected value' );

v = minf( -0.0, -0.0 );
t.strictEqual( isNegativeZerof( v ), true, 'returns -0' );
t.strictEqual( isNegativeZerof( v ), true, 'returns expected value' );

v = minf( +0.0, +0.0 );
t.strictEqual( isPositiveZerof( v ), true, 'returns +0' );
t.strictEqual( isPositiveZerof( v ), true, 'returns expected value' );

t.end();
});
Expand All @@ -83,10 +83,10 @@ tape( 'the function returns the minimum value', function test( t ) {
var v;

v = minf( float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ) );
t.strictEqual( v, float64ToFloat32( 3.14 ), 'returns min value' );
t.strictEqual( v, float64ToFloat32( 3.14 ), 'returns expected value' );

v = minf( float64ToFloat32( -4.2 ), float64ToFloat32( 3.14 ) );
t.strictEqual( v, float64ToFloat32( -4.2 ), 'returns min value' );
t.strictEqual( v, float64ToFloat32( -4.2 ), 'returns expected value' );

t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ tape( 'the function returns `-Infinity` if provided `-Infinity`', opts, function
var v;

v = minf( NINF, 3.14 );
t.strictEqual( v, NINF, 'returns -infinity' );
t.strictEqual( v, NINF, 'returns expected value' );

v = minf( 3.14, NINF );
t.strictEqual( v, NINF, 'returns -infinity' );
t.strictEqual( v, NINF, 'returns expected value' );

t.end();
});
Expand All @@ -74,16 +74,16 @@ tape( 'the function returns a correctly signed zero', opts, function test( t ) {
var v;

v = minf( +0.0, -0.0 );
t.strictEqual( isNegativeZerof( v ), true, 'returns -0' );
t.strictEqual( isNegativeZerof( v ), true, 'returns expected value' );

v = minf( -0.0, +0.0 );
t.strictEqual( isNegativeZerof( v ), true, 'returns -0' );
t.strictEqual( isNegativeZerof( v ), true, 'returns expected value' );

v = minf( -0.0, -0.0 );
t.strictEqual( isNegativeZerof( v ), true, 'returns -0' );
t.strictEqual( isNegativeZerof( v ), true, 'returns expected value' );

v = minf( +0.0, +0.0 );
t.strictEqual( isPositiveZerof( v ), true, 'returns +0' );
t.strictEqual( isPositiveZerof( v ), true, 'returns expected value' );

t.end();
});
Expand All @@ -92,10 +92,10 @@ tape( 'the function returns the minimum value', opts, function test( t ) {
var v;

v = minf( float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ) );
t.strictEqual( v, float64ToFloat32( 3.14 ), 'returns min value' );
t.strictEqual( v, float64ToFloat32( 3.14 ), 'returns expected value' );

v = minf( float64ToFloat32( -4.2 ), float64ToFloat32( 3.14 ) );
t.strictEqual( v, float64ToFloat32( -4.2 ), 'returns min value' );
t.strictEqual( v, float64ToFloat32( -4.2 ), 'returns expected value' );

t.end();
});

0 comments on commit dce2b90

Please sign in to comment.