Skip to content

Commit abf72a2

Browse files
committed
chore: apply suggestions from review
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 76a5eb2 commit abf72a2

File tree

6 files changed

+26
-92
lines changed

6 files changed

+26
-92
lines changed

lib/node_modules/@stdlib/math/base/special/minmax/README.md

+13-20
Original file line numberDiff line numberDiff line change
@@ -147,24 +147,23 @@ for ( i = 0; i < 100; i++ ) {
147147

148148
#### stdlib_base_minmax( x, y, &min, &max )
149149

150-
Returns the minimum and maximum value.
150+
Evaluates the minimum and maximum values in a single pass.
151151

152152
```c
153-
#include <stdint.h>
153+
double x = 3.14;
154+
double y = 2.71;
154155

155156
double min;
156157
double max;
157-
158-
stdlib_base_minmax( 3.14, NaN );
159-
// returns [ NaN, NaN ]
158+
stdlib_base_minmax( x, y, &min, &max );
160159
```
161160
162161
The function accepts the following arguments:
163162
164-
- **x**: `[in] double` input value.
165-
- **y**: `[in] double` input value.
166-
- **min**: `[out] double` destination for minimum value.
167-
- **max**: `[out] double` destination for maximum value.
163+
- **x**: `[in] double` first number.
164+
- **y**: `[in] double` second number.
165+
- **min**: `[out] double` destination for the minimum value.
166+
- **max**: `[out] double` destination for the maximum value.
168167
169168
```c
170169
void stdlib_base_minmax( const double x, const double y, double* min, double* max );
@@ -190,24 +189,18 @@ void stdlib_base_minmax( const double x, const double y, double* min, double* ma
190189

191190
```c
192191
#include "stdlib/math/base/special/minmax.h"
193-
#include <stdlib.h>
194192
#include <stdio.h>
195193

196194
int main( void ) {
195+
const double x[] = { 1.0, 0.45, -0.89, 0.0 / 0.0, -0.78, -0.22, 0.66, 0.11, -0.55, 0.0 };
196+
const double y[] = { -0.22, 0.66, 0.0, -0.55, 0.33, 1.0, 0.0 / 0.0, 0.11, 0.45, -0.78 };
197+
197198
double min;
198199
double max;
199-
double x;
200-
double y;
201200
int i;
202-
203-
const double x1[] = { 1.0, 0.45, -0.89, 0.0 / 0.0, -0.78, -0.22, 0.66, 0.11, -0.55, 0.0 };
204-
const double x2[] = { -0.22, 0.66, 0.0, -0.55, 0.33, 1.0, 0.0 / 0.0, 0.11, 0.45, -0.78 };
205-
206-
for ( i = 0; i < 12; i++ ) {
207-
x = ( ( (double)rand() / (double)RAND_MAX ) * 200.0 ) - 100.0;
208-
y = ( ( (double)rand() / (double)RAND_MAX ) * 200.0 ) - 100.0;
201+
for ( i = 0; i < 10; i++ ) {
209202
stdlib_base_minmax( x[ i ], y[ i ], &min, &max );
210-
printf( "x: %lf => min: %lf, y: %lf, minmax(x, y): %lf\n", x[ i ], y[ i ]min, max );
203+
printf( "x: %lf, y: %lf => min: %lf, max: %lf\n", x[ i ], y[ i ], min, max );
211204
}
212205
}
213206
```

lib/node_modules/@stdlib/math/base/special/minmax/benchmark/benchmark.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ bench( pkg+':assign', function benchmark( b ) {
6666
y = uniform( 100, -500.0, 500.0 );
6767
out = [ 0.0, 0.0 ];
6868

69-
x = discreteUniform( 100, -500, 500 );
70-
y = discreteUniform( 100, -500, 500 );
71-
7269
b.tic();
7370
for ( i = 0; i < b.iterations; i++ ) {
7471
z = minmax.assign( x[ i%x.length ], y[ i%y.length ], out, 1, 0 );
@@ -95,6 +92,7 @@ bench( pkg+'::min,max', function benchmark( b ) {
9592

9693
b.tic();
9794
for ( i = 0; i < b.iterations; i++ ) {
95+
// eslint-disable-next-line max-len
9896
z = [ min( x[ i%x.length ], y[ i%y.length ] ), max( x[ i%x.length ], y[ i%y.length ] ) ];
9997
if ( z.length !== 2 ) {
10098
b.fail( 'should have expected length' );
@@ -118,9 +116,6 @@ bench( pkg+'::min,max,memory_reuse', function benchmark( b ) {
118116
y = uniform( 100, -500.0, 500.0 );
119117
z = [ 0.0, 0.0 ];
120118

121-
x = discreteUniform( 100, -500, 500 );
122-
y = discreteUniform( 100, -500, 500 );
123-
124119
b.tic();
125120
for ( i = 0; i < b.iterations; i++ ) {
126121
z[ 0 ] = min( x[ i%x.length ], y[ i%y.length ] );

lib/node_modules/@stdlib/math/base/special/minmax/benchmark/benchmark.native.js

+7-60
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
26-
var isArray = require( '@stdlib/assert/is-array' );
27-
var min = require( '@stdlib/math/base/special/min' );
28-
var max = require( '@stdlib/math/base/special/max' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
26+
var isFloat64Array = require( '@stdlib/assert/is-float64array' );
2927
var tryRequire = require( '@stdlib/utils/try-require' );
3028
var pkg = require( './../package.json' ).name;
3129

@@ -46,70 +44,19 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4644
var z;
4745
var i;
4846

49-
x = discreteUniform( 100, -500, 500 );
50-
y = discreteUniform( 100, -500, 500 );
47+
x = uniform( 100, -500.0, 500.0 );
48+
y = uniform( 100, -500.0, 500.0 );
5149

5250
b.tic();
5351
for ( i = 0; i < b.iterations; i++ ) {
54-
z = minmax( x, y );
52+
z = minmax( x[ i%x.length ], y[ i%y.length ] );
5553
if ( z.length !== 2 ) {
5654
b.fail( 'should have expected length' );
5755
}
5856
}
5957
b.toc();
60-
if ( !isArray( z ) ) {
61-
b.fail( 'should return an array' );
62-
}
63-
b.pass( 'benchmark finished' );
64-
b.end();
65-
});
66-
67-
bench( pkg+'::min,max', opts, function benchmark( b ) {
68-
var x;
69-
var y;
70-
var z;
71-
var i;
72-
73-
x = discreteUniform( 100, -500, 500 );
74-
y = discreteUniform( 100, -500, 500 );
75-
76-
b.tic();
77-
for ( i = 0; i < b.iterations; i++ ) {
78-
z = [ min( x, y ), max( x, y ) ];
79-
if ( z.length !== 2 ) {
80-
b.fail( 'should have expected length' );
81-
}
82-
}
83-
b.toc();
84-
if ( !isArray( z ) ) {
85-
b.fail( 'should return an array' );
86-
}
87-
b.pass( 'benchmark finished' );
88-
b.end();
89-
});
90-
91-
bench( pkg+'::min,max,memory_reuse', opts, function benchmark( b ) {
92-
var x;
93-
var y;
94-
var z;
95-
var i;
96-
97-
z = [ 0.0, 0.0 ];
98-
99-
x = discreteUniform( 100, -500, 500 );
100-
y = discreteUniform( 100, -500, 500 );
101-
102-
b.tic();
103-
for ( i = 0; i < b.iterations; i++ ) {
104-
z[ 0 ] = min( x, y );
105-
z[ 1 ] = max( x, y );
106-
if ( z.length !== 2 ) {
107-
b.fail( 'should have expected length' );
108-
}
109-
}
110-
b.toc();
111-
if ( !isArray( z ) ) {
112-
b.fail( 'should return an array' );
58+
if ( !isFloat64Array( z ) ) {
59+
b.fail( 'should return a Float64Array' );
11360
}
11461
b.pass( 'benchmark finished' );
11562
b.end();

lib/node_modules/@stdlib/math/base/special/minmax/examples/c/example.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ int main( void ) {
2626
double min;
2727
double max;
2828
int i;
29-
3029
for ( i = 0; i < 10; i++ ) {
3130
stdlib_base_minmax( x[ i ], y[ i ], &min, &max );
32-
printf( "x: %lf => min: %lf, y: %lf, minmax(x, y): %lf\n", x[ i ], y[ i ], min, max );
31+
printf( "x: %lf, y: %lf => min: %lf, max: %lf\n", x[ i ], y[ i ], min, max );
3332
}
3433
}

lib/node_modules/@stdlib/math/base/special/minmax/include/stdlib/math/base/special/minmax.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Evaluates the minimum and maximum values.
30+
* Evaluates the minimum and maximum values in a single pass.
3131
*/
3232
void stdlib_base_minmax( const double x, const double y, double *min, double *max );
3333

lib/node_modules/@stdlib/math/base/special/minmax/src/main.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
#include "stdlib/math/base/assert/is_negative_zero.h"
2222

2323
/**
24-
* Evaluates the minimum and maximum values.
24+
* Evaluates the minimum and maximum values in a single pass.
2525
*
2626
* @param x first number
2727
* @param y second number
28-
* @param min destination to store the minimum value
29-
* @param max destination to store the maximum value
28+
* @param min destination for the minimum value
29+
* @param max destination for the maximum value
3030
*
3131
* @example
3232
* double x = 3.14;

0 commit comments

Comments
 (0)