Skip to content

Commit 883bd8d

Browse files
committed
chore: changes from code review
1 parent 21af19e commit 883bd8d

File tree

13 files changed

+94
-90
lines changed

13 files changed

+94
-90
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ v = lcmf( 48, NaN );
102102

103103
```javascript
104104
var randu = require( '@stdlib/random/base/randu' );
105-
var round = require( '@stdlib/math/base/special/round' );
105+
var roundf = require( '@stdlib/math/base/special/roundf' );
106106
var lcmf = require( '@stdlib/math/base/special/lcmf' );
107107

108108
var a;
@@ -111,8 +111,8 @@ var v;
111111
var i;
112112

113113
for ( i = 0; i < 100; i++ ) {
114-
a = round( randu()*50 );
115-
b = round( randu()*50 );
114+
a = roundf( randu() * 50 );
115+
b = roundf( randu() * 50 );
116116
v = lcmf( a, b );
117117
console.log( 'lcmf(%d,%d) = %d', a, b, v );
118118
}
@@ -153,7 +153,7 @@ for ( i = 0; i < 100; i++ ) {
153153
Computes the [least common multiple][lcm] (lcm) of two single-precision floating-point numbers.
154154

155155
```c
156-
double v = stdlib_base_lcmf( 48.0f, 18.0f );
156+
float v = stdlib_base_lcmf( 48.0f, 18.0f );
157157
// returns 144.0f
158158
```
159159

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -21,8 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
25-
var round = require( '@stdlib/math/base/special/round' );
24+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2625
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2726
var pkg = require( './../package.json' ).name;
2827
var lcmf = require( './../lib' );
@@ -36,11 +35,12 @@ bench( pkg, function benchmark( b ) {
3635
var z;
3736
var i;
3837

38+
x = discreteUniform( 100, 1.0, 100.0 );
39+
y = discreteUniform( 100, 1.0, 100.0 );
40+
3941
b.tic();
4042
for ( i = 0; i < b.iterations; i++ ) {
41-
x = round( randu() * 50.0 );
42-
y = round( randu() * 50.0 );
43-
z = lcmf( x, y );
43+
z = lcmf( x[ i % x.length ], y[ i % y.length ] );
4444
if ( isnanf( z ) ) {
4545
b.fail( 'should not return NaN' );
4646
}

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

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

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
26-
var round = require( '@stdlib/math/base/special/round' );
25+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
2726
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2827
var tryRequire = require( '@stdlib/utils/try-require' );
2928
var pkg = require( './../package.json' ).name;
@@ -45,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4544
var z;
4645
var i;
4746

47+
x = discreteUniform( 100, 1.0, 100.0 );
48+
y = discreteUniform( 100, 1.0, 100.0 );
49+
4850
b.tic();
4951
for ( i = 0; i < b.iterations; i++ ) {
50-
x = round( randu() * 50.0 );
51-
y = round( randu() * 50.0 );
52-
z = lcmf( x, y );
52+
z = lcmf( x[ i % x.length ], y[ i % y.length ] );
5353
if ( isnanf( z ) ) {
5454
b.fail( 'should not return NaN' );
5555
}

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <time.h>
2424
#include <sys/time.h>
2525

26-
#define NAME "lcm"
26+
#define NAME "lcmf"
2727
#define ITERATIONS 1000000
2828
#define REPEATS 3
2929

@@ -91,27 +91,30 @@ static float rand_float( void ) {
9191
*/
9292
static double benchmark( void ) {
9393
double elapsed;
94-
float x;
95-
float y;
96-
float z;
94+
float a[ 100 ];
95+
float b[ 100 ];
9796
double t;
97+
float y;
9898
int i;
9999

100+
for ( i = 0; i < 100; i++ ) {
101+
a[ i ] = roundf( 500.0f * rand_float() );
102+
b[ i ] = roundf( 500.0f * rand_float() );
103+
}
104+
100105
t = tic();
101106
for ( i = 0; i < ITERATIONS; i++ ) {
102-
x = round( rand_float() * 500.0f );
103-
y = round( rand_float() * 500.0f );
104-
z = stdlib_base_lcmf( x, y );
105-
if ( z != z ) {
107+
y = stdlib_base_lcmf( a[ i % 100 ], b[ i % 100 ] );
108+
if ( y != y ) {
106109
printf( "should not return NaN\n" );
107110
break;
108111
}
109112
}
110113
elapsed = tic() - t;
111-
if ( z != z ) {
114+
if ( y != y ) {
112115
printf( "should not return NaN\n" );
113116
}
114-
return elapsed;
117+
return elapsed;
115118
}
116119

117120
/**

lib/node_modules/@stdlib/math/base/special/lcmf/docs/repl.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
{{alias}}( a, b )
3-
Computes the least common multiple (lcm) of two
4-
single-precision floating-point numbers.
3+
Computes the least common multiple (lcm) of two single-precision
4+
floating-point numbers.
55

66
If either `a` or `b` is `0`, the function returns `0`.
77

lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2019 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/math/base/special/lcmf/docs/types/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2019 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/math/base/special/lcmf/examples/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
var randu = require( '@stdlib/random/base/randu' );
22-
var round = require( '@stdlib/math/base/special/round' );
22+
var roundf = require( '@stdlib/math/base/special/roundf' );
2323
var lcmf = require( './../lib' );
2424

2525
var a;
@@ -28,8 +28,8 @@ var v;
2828
var i;
2929

3030
for ( i = 0; i < 100; i++ ) {
31-
a = round( randu() * 50 );
32-
b = round( randu() * 50 );
31+
a = roundf( randu() * 50 );
32+
b = roundf( randu() * 50 );
3333
v = lcmf( a, b );
3434
console.log( 'lcmf(%d,%d) = %d', a, b, v );
3535
}

lib/node_modules/@stdlib/math/base/special/lcmf/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/math/base/special/lcmf/lib/main.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -56,12 +56,13 @@ function lcmf( a, b ) {
5656
if ( b < 0 ) {
5757
b = -b;
5858
}
59+
5960
// Note: we rely on `gcdf` to perform further argument validation...
6061
d = gcdf( a, b );
6162
if ( isnanf( d ) ) {
6263
return d;
6364
}
64-
return (a/d) * b;
65+
return ( a / d ) * b;
6566
}
6667

6768

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* @return least common multiple
2929
*
3030
* @example
31-
* double out = stdlib_base_lcmf( 21.0f, 6.0f );
31+
* float out = stdlib_base_lcmf( 21.0f, 6.0f );
3232
* // returns 42.0f
3333
*/
3434
float stdlib_base_lcmf( const float a, const float b ) {

lib/node_modules/@stdlib/math/base/special/lcmf/test/test.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -39,13 +39,13 @@ tape( 'the function returns `NaN` if either argument is `NaN`', function test( t
3939
var v;
4040

4141
v = lcmf( NaN, 10 );
42-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
42+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
4343

4444
v = lcmf( 10, NaN );
45-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
45+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
4646

4747
v = lcmf( NaN, NaN );
48-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
48+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
4949

5050
t.end();
5151
});
@@ -54,13 +54,13 @@ tape( 'the function returns `NaN` if either argument is `+infinity`', function t
5454
var v;
5555

5656
v = lcmf( PINF, 10 );
57-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
57+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
5858

5959
v = lcmf( 10, PINF );
60-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
60+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
6161

6262
v = lcmf( PINF, PINF );
63-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
63+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
6464

6565
t.end();
6666
});
@@ -69,13 +69,13 @@ tape( 'the function returns `NaN` if either argument is `-infinity`', function t
6969
var v;
7070

7171
v = lcmf( NINF, 10 );
72-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
72+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
7373

7474
v = lcmf( 10, NINF );
75-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
75+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
7676

7777
v = lcmf( NINF, NINF );
78-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
78+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
7979

8080
t.end();
8181
});
@@ -84,26 +84,26 @@ tape( 'the function returns `NaN` if either argument is not an integer value', f
8484
var v;
8585

8686
v = lcmf( 3.14, 10 );
87-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
87+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
8888

8989
v = lcmf( 10, 3.14 );
90-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
90+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
9191

9292
v = lcmf( 3.14, 6.18 );
93-
t.strictEqual( isnanf( v ), true, 'returns NaN' );
93+
t.strictEqual( isnanf( v ), true, 'returns expected value' );
9494

9595
t.end();
9696
});
9797

9898
tape( 'the function returns `0` if either argument is `0`', function test( t ) {
9999
var v = lcmf( 0, 0 );
100-
t.strictEqual( v, 0, 'returns 0' );
100+
t.strictEqual( v, 0, 'returns expected value' );
101101

102102
v = lcmf( 2, 0 );
103-
t.strictEqual( v, 0, 'returns 0' );
103+
t.strictEqual( v, 0, 'returns expected value' );
104104

105105
v = lcmf( 0, -3 );
106-
t.strictEqual( v, 0, 'returns 0' );
106+
t.strictEqual( v, 0, 'returns expected value' );
107107

108108
t.end();
109109
});
@@ -112,37 +112,37 @@ tape( 'the function computes the least common multiple', function test( t ) {
112112
var v;
113113

114114
v = lcmf( 0, 0 );
115-
t.strictEqual( v, 0, 'returns 0' );
115+
t.strictEqual( v, 0, 'returns expected value' );
116116

117117
v = lcmf( 1, 0 );
118-
t.strictEqual( v, 0, 'returns 0' );
118+
t.strictEqual( v, 0, 'returns expected value' );
119119

120120
v = lcmf( 0, 1 );
121-
t.strictEqual( v, 0, 'returns 0' );
121+
t.strictEqual( v, 0, 'returns expected value' );
122122

123123
v = lcmf( 6, 4 );
124-
t.strictEqual( v, 12, 'returns 12' );
124+
t.strictEqual( v, 12, 'returns expected value' );
125125

126126
v = lcmf( 6, -4 );
127-
t.strictEqual( v, 12, 'returns 12' );
127+
t.strictEqual( v, 12, 'returns expected value' );
128128

129129
v = lcmf( -6, -4 );
130-
t.strictEqual( v, 12, 'returns 12' );
130+
t.strictEqual( v, 12, 'returns expected value' );
131131

132132
v = lcmf( 2, 8 );
133-
t.strictEqual( v, 8, 'returns 8' );
133+
t.strictEqual( v, 8, 'returns expected value' );
134134

135135
v = lcmf( 15, 20 );
136-
t.strictEqual( v, 60, 'returns 60' );
136+
t.strictEqual( v, 60, 'returns expected value' );
137137

138138
v = lcmf( 20, 15 );
139-
t.strictEqual( v, 60, 'returns 60' );
139+
t.strictEqual( v, 60, 'returns expected value' );
140140

141141
v = lcmf( 35, -21 );
142-
t.strictEqual( v, 105, 'returns 105' );
142+
t.strictEqual( v, 105, 'returns expected value' );
143143

144144
v = lcmf( 48, 18 );
145-
t.strictEqual( v, 144, 'returns 144' );
145+
t.strictEqual( v, 144, 'returns expected value' );
146146

147147
t.end();
148148
});

0 commit comments

Comments
 (0)