Skip to content

Commit 79dc5cf

Browse files
authored
bench: generate numbers outside loops in math/base/special/cfloorf
PR-URL: #3113 Ref: 6556a46#diff-391d6421c716339880525f3190cd9bfcc3ca2e56bc7ba33de60591c7d2ec178eR25 Private-ref: stdlib-js/todo#2293 Reviewed-by: Athan Reines <[email protected]>
1 parent 47cfa90 commit 79dc5cf

File tree

12 files changed

+26
-22
lines changed

12 files changed

+26
-22
lines changed

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

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

2121
# cfloorf
2222

23-
> Round a single-precision complex floating-point number toward negative infinity.
23+
> Round each component of a single-precision complex floating-point number toward negative infinity.
2424
2525
<section class="usage">
2626

@@ -32,7 +32,7 @@ var cfloorf = require( '@stdlib/math/base/special/cfloorf' );
3232

3333
#### cfloorf( z )
3434

35-
Rounds a single-precision complex floating-point number toward negative infinity.
35+
Rounds each component of a single-precision complex floating-point number toward negative infinity.
3636

3737
```javascript
3838
var Complex64 = require( '@stdlib/complex/float32/ctor' );
@@ -132,7 +132,7 @@ for ( i = 0; i < 100; i++ ) {
132132

133133
#### stdlib_base_cfloorf( z )
134134

135-
Rounds a single-precision complex floating-point number toward negative infinity.
135+
Rounds each component of a single-precision complex floating-point number toward negative infinity.
136136

137137
```c
138138
#include "stdlib/complex/float32/ctor.h"

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
24+
var randu = require( '@stdlib/random/array/uniform' );
2525
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2626
var Complex64 = require( '@stdlib/complex/float32/ctor' );
2727
var real = require( '@stdlib/complex/float32/real' );
@@ -66,11 +66,12 @@ bench( pkg+'::manual', function benchmark( b ) {
6666
var y;
6767
var i;
6868

69+
re = randu( 10, -500.0, 500.0 );
70+
im = randu( 10, -500.0, 500.0 );
71+
6972
b.tic();
7073
for ( i = 0; i < b.iterations; i++ ) {
71-
re = ( randu()*1000.0 ) - 500.0;
72-
im = ( randu()*1000.0 ) - 500.0;
73-
y = [ floorf( re ), floorf( im ) ];
74+
y = [ floorf( re[ i % re.length ] ), floorf( i % im.length ) ];
7475
if ( y.length === 0 ) {
7576
b.fail( 'should not be empty' );
7677
}

lib/node_modules/@stdlib/math/base/special/cfloorf/benchmark/c/benchmark.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ static float rand_float( void ) {
9393
*/
9494
static double benchmark( void ) {
9595
double elapsed;
96-
float re;
97-
float im;
96+
float re[ 100 ];
97+
float im[ 100 ];
9898
double t;
9999
int i;
100100

@@ -103,11 +103,14 @@ static double benchmark( void ) {
103103
float a;
104104
float b;
105105

106+
for ( i = 0; i < 100; i++ ) {
107+
re[ i ] = ( 1000.0f * rand_float() ) - 500.0f;
108+
im[ i ] = ( 1000.0f * rand_float() ) - 500.0f;
109+
}
110+
106111
t = tic();
107112
for ( i = 0; i < ITERATIONS; i++ ) {
108-
re = ( 1000.0f * rand_float() ) - 500.0f;
109-
im = ( 1000.0f * rand_float() ) - 500.0f;
110-
z = stdlib_complex64( re, im );
113+
z = stdlib_complex64( re[ i % 100 ], im[ i % 100 ] );
111114
y = stdlib_base_cfloorf( z );
112115
stdlib_complex64_reim( y, &a, &b );
113116
if ( a != a || b != b ) {

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

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

22
{{alias}}( z )
3-
Rounds a single-precision complex floating-point number toward negative
4-
infinity.
3+
Rounds each component of a single-precision complex floating-point number
4+
toward negative infinity.
55

66
Parameters
77
----------

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import { Complex64 } from '@stdlib/types/complex';
2424

2525
/**
26-
* Rounds a single-precision complex floating-point number toward negative infinity.
26+
* Rounds each component of a single-precision complex floating-point number toward negative infinity.
2727
*
2828
* @param z - input value
2929
* @returns result

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import cfloorf = require( './index' );
2222

2323
// TESTS //
2424

25-
// The function returns an array of numbers...
25+
// The function returns a complex number...
2626
{
2727
cfloorf( new Complex64( 1.0, 2.0 ) ); // $ExpectType Complex64
2828
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern "C" {
2929
#endif
3030

3131
/**
32-
* Rounds a single-precision complex floating-point number toward negative infinity.
32+
* Rounds each component of a single-precision complex floating-point number toward negative infinity.
3333
*/
3434
stdlib_complex64_t stdlib_base_cfloorf( const stdlib_complex64_t z );
3535

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Round a single-precision floating-point complex number toward negative infinity.
22+
* Round each component of a single-precision complex floating-point number toward negative infinity.
2323
*
2424
* @module @stdlib/math/base/special/cfloorf
2525
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var imag = require( '@stdlib/complex/float32/imag' );
2929
// MAIN //
3030

3131
/**
32-
* Rounds a single-precision floating-point complex number toward negative infinity.
32+
* Rounds each component of a single-precision complex floating-point number toward negative infinity.
3333
*
3434
* @param {Complex64} z - complex number
3535
* @returns {Complex64} result

lib/node_modules/@stdlib/math/base/special/cfloorf/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-
* Rounds a single-precision floating-point complex number toward negative infinity.
30+
* Rounds each component of a single-precision complex floating-point number toward negative infinity.
3131
*
3232
* @private
3333
* @param {Complex64} z - complex number

0 commit comments

Comments
 (0)