Skip to content

Commit b31e68e

Browse files
committed
applied reviewed changes
1 parent 15cb501 commit b31e68e

File tree

11 files changed

+158
-142
lines changed

11 files changed

+158
-142
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# minmax
2222

23-
> Return the minimum and maximum values.
23+
> Returns the minimum and maximum values.
2424
2525
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
2626

@@ -148,25 +148,25 @@ for ( i = 0; i < 100; i++ ) {
148148

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

151-
Gives the minimum and maximum value.
151+
Returns the minimum and maximum value.
152152

153153
```c
154154
double min;
155155
double max;
156156
stdlib_base_minmax( 4.2, 3.14, &min, &max );
157-
// min = 3.14, max = 4.2
158157

159158
stdlib_base_minmax( 0.0, -0.0, &min, &max );
160-
// min = -0.0, max = 0.0
161159
```
162160
163161
The function accepts the following arguments:
164162
165163
- **x**: `[in] double` input value.
166164
- **y**: `[in] double` input value.
165+
- **min**: `[out] double` destination for minimum value.
166+
- **max**: `[out] double` destination for maximum value.
167167
168168
```c
169-
double stdlib_base_minmax( const double x, const double y, double* min, double* max );
169+
void stdlib_base_minmax( const double x, const double y, double* min, double* max );
170170
```
171171

172172
</section>
@@ -193,10 +193,10 @@ double stdlib_base_minmax( const double x, const double y, double* min, double*
193193
#include <stdio.h>
194194

195195
int main( void ) {
196-
double x;
197-
double y;
198196
double min;
199197
double max;
198+
double x;
199+
double y;
200200
int i;
201201

202202
for ( i = 0; i < 100; i++ ) {

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ bench( pkg, function benchmark( b ) {
3737
var z;
3838
var i;
3939

40+
x = ( randu()*1000.0 ) - 500.0;
41+
y = ( randu()*1000.0 ) - 500.0;
42+
4043
b.tic();
4144
for ( i = 0; i < b.iterations; i++ ) {
42-
x = ( randu()*1000.0 ) - 500.0;
43-
y = ( randu()*1000.0 ) - 500.0;
4445
z = minmax( x, y );
4546
if ( z.length !== 2 ) {
4647
b.fail( 'should have expected length' );
@@ -63,10 +64,11 @@ bench( pkg+':assign', function benchmark( b ) {
6364

6465
out = [ 0.0, 0.0 ];
6566

67+
x = ( randu()*1000.0 ) - 500.0;
68+
y = ( randu()*1000.0 ) - 500.0;
69+
6670
b.tic();
6771
for ( i = 0; i < b.iterations; i++ ) {
68-
x = ( randu()*1000.0 ) - 500.0;
69-
y = ( randu()*1000.0 ) - 500.0;
7072
z = minmax.assign( x, y, out, 1, 0 );
7173
if ( z.length !== 2 ) {
7274
b.fail( 'should have expected length' );
@@ -86,10 +88,11 @@ bench( pkg+'::min,max', function benchmark( b ) {
8688
var z;
8789
var i;
8890

91+
x = ( randu()*1000.0 ) - 500.0;
92+
y = ( randu()*1000.0 ) - 500.0;
93+
8994
b.tic();
9095
for ( i = 0; i < b.iterations; i++ ) {
91-
x = ( randu()*1000.0 ) - 500.0;
92-
y = ( randu()*1000.0 ) - 500.0;
9396
z = [ min( x, y ), max( x, y ) ];
9497
if ( z.length !== 2 ) {
9598
b.fail( 'should have expected length' );
@@ -111,10 +114,11 @@ bench( pkg+'::min,max,memory_reuse', function benchmark( b ) {
111114

112115
z = [ 0.0, 0.0 ];
113116

117+
x = ( randu()*1000.0 ) - 500.0;
118+
y = ( randu()*1000.0 ) - 500.0;
119+
114120
b.tic();
115121
for ( i = 0; i < b.iterations; i++ ) {
116-
x = ( randu()*1000.0 ) - 500.0;
117-
y = ( randu()*1000.0 ) - 500.0;
118122
z[ 0 ] = min( x, y );
119123
z[ 1 ] = max( x, y );
120124
if ( z.length !== 2 ) {

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var randu = require( '@stdlib/random/base/uniform' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
@@ -44,17 +44,18 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4444
var v;
4545
var i;
4646

47+
x = ( randu() * 20.0 ) - 10.0;
48+
y = ( randu() * 20.0 ) - 10.0;
49+
4750
b.tic();
4851
for ( i = 0; i < b.iterations; i++ ) {
49-
x = ( randu() * 20.0 ) - 10.0;
50-
y = ( randu() * 20.0 ) - 10.0;
5152
v = minmax( x, y );
52-
if ( isnan( v[0] ) || isnan( v[1] )) {
53+
if ( isnan( v[ 0 ] ) || isnan( v[ 1 ] )) {
5354
b.fail( 'should not return NaN' );
5455
}
5556
}
5657
b.toc();
57-
if ( isnan( v[0] ) || isnan( v[1] ) ) {
58+
if ( isnan( v[ 0 ] ) || isnan( v[ 1 ] ) ) {
5859
b.fail( 'should not return NaN' );
5960
}
6061
b.pass( 'benchmark finished' );

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ static double rand_double( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
double x1[100];
95-
double x2[100];
94+
double x1[ 100 ];
95+
double x2[ 100 ];
9696
double min;
9797
double max;
9898
double t;
@@ -106,13 +106,13 @@ static double benchmark( void ) {
106106
t = tic();
107107
for ( i = 0; i < ITERATIONS; i++ ) {
108108
stdlib_base_minmax( x1[ i % 100 ], x2[ i % 100 ], &min, &max );
109-
if ( min != min && max != max ) {
109+
if ( min != min || max != max ) {
110110
printf( "should not return NaN\n" );
111111
break;
112112
}
113113
}
114114
elapsed = tic() - t;
115-
if ( min != min && max != max ) {
115+
if ( min != min || max != max ) {
116116
printf( "should not return NaN\n" );
117117
}
118118
return elapsed;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@
2020
#include <stdio.h>
2121

2222
int main(void) {
23-
24-
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 };
23+
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 };
2524
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 };
2625

26+
double min;
27+
double max;
2728
int i;
2829
for ( i = 0; i < 10; i++ ) {
29-
double min;
30-
double max;
3130
stdlib_base_minmax( x1[ i ], x2[ i ], &min, &max );
3231
printf( "x1[ %d ]: %lf, x2[ %d ]: %lf, minmax( x1[ %d ], x2[ %d ] ): ( %lf, %lf )\n", i, x1[ i ], i, x2[ i ], i, i, min, max );
3332
}

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,9 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Evaluates the min and max of two values.
31-
*
32-
* @param x First value
33-
* @param y Second value
34-
* @param min double to store minimum value
35-
* @param max double to store maximum value
30+
* Returns the minimum and maximum values.
3631
*/
37-
void stdlib_base_minmax(const double x, const double y, double* min, double* max );
32+
void stdlib_base_minmax( const double x, const double y, double* min, double* max );
3833

3934
#ifdef __cplusplus
4035
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var addon = require( './../src/addon.node' );
2727
// MAIN //
2828

2929
/**
30-
* Returns the minimum and maximum value, ignoring NaN.
30+
* Returns the minimum and maximum values.
3131
*
3232
* @private
3333
* @param {number} x - first number
Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,72 @@
11
{
2-
"options": {
3-
"task": "build"
2+
"options": {
3+
"task": "build"
4+
},
5+
"fields": [
6+
{
7+
"field": "src",
8+
"resolve": true,
9+
"relative": true
410
},
5-
"fields": [
6-
{
7-
"field": "src",
8-
"resolve": true,
9-
"relative": true
10-
},
11-
{
12-
"field": "include",
13-
"resolve": true,
14-
"relative": true
15-
},
16-
{
17-
"field": "libraries",
18-
"resolve": false,
19-
"relative": false
20-
},
21-
{
22-
"field": "libpath",
23-
"resolve": true,
24-
"relative": false
25-
}
26-
],
27-
"confs": [
28-
{
29-
"task": "build",
30-
"src": [
31-
"./src/main.c"
32-
],
33-
"include": [
34-
"./include"
35-
],
36-
"libraries": [],
37-
"libpath": [],
38-
"dependencies": [
39-
"@stdlib/math/base/napi/binary",
40-
"@stdlib/math/base/assert/is-nan"
41-
]
42-
},
43-
{
44-
"task": "benchmark",
45-
"src": [
46-
"./src/main.c"
47-
],
48-
"include": [
49-
"./include"
50-
],
51-
"libraries": [],
52-
"libpath": [],
53-
"dependencies": [
54-
"@stdlib/math/base/assert/is-nan"
55-
]
56-
},
57-
{
58-
"task": "examples",
59-
"src": [
60-
"./src/main.c"
61-
],
62-
"include": [
63-
"./include"
64-
],
65-
"libraries": [],
66-
"libpath": [],
67-
"dependencies": [
68-
"@stdlib/math/base/assert/is-nan"
69-
]
70-
}
71-
]
72-
}
73-
11+
{
12+
"field": "include",
13+
"resolve": true,
14+
"relative": true
15+
},
16+
{
17+
"field": "libraries",
18+
"resolve": false,
19+
"relative": false
20+
},
21+
{
22+
"field": "libpath",
23+
"resolve": true,
24+
"relative": false
25+
}
26+
],
27+
"confs": [
28+
{
29+
"task": "build",
30+
"src": [
31+
"./src/main.c"
32+
],
33+
"include": [
34+
"./include"
35+
],
36+
"libraries": [],
37+
"libpath": [],
38+
"dependencies": [
39+
"@stdlib/math/base/napi/binary",
40+
"@stdlib/math/base/assert/is-nan"
41+
]
42+
},
43+
{
44+
"task": "benchmark",
45+
"src": [
46+
"./src/main.c"
47+
],
48+
"include": [
49+
"./include"
50+
],
51+
"libraries": [],
52+
"libpath": [],
53+
"dependencies": [
54+
"@stdlib/math/base/assert/is-nan"
55+
]
56+
},
57+
{
58+
"task": "examples",
59+
"src": [
60+
"./src/main.c"
61+
],
62+
"include": [
63+
"./include"
64+
],
65+
"libraries": [],
66+
"libpath": [],
67+
"dependencies": [
68+
"@stdlib/math/base/assert/is-nan"
69+
]
70+
}
71+
]
72+
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
6868
return NULL;
6969
}
7070

71+
napi_valuetype vtype2;
72+
status = napi_typeof( env, argv[ 2 ], &vtype1 );
73+
assert( status == napi_ok );
74+
if ( vtype2 != napi_number ) {
75+
status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." );
76+
assert( status == napi_ok );
77+
return NULL;
78+
}
79+
7180
napi_typedarray_type vtype0;
7281
size_t len;
7382
void *Out;

0 commit comments

Comments
 (0)