Skip to content

Commit c7beac3

Browse files
committed
docs: clean-up
--- 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: passed - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - 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: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent c682a54 commit c7beac3

File tree

10 files changed

+97
-118
lines changed

10 files changed

+97
-118
lines changed

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

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ The [exponential function][exponential-function] is defined as
3232
y = b^x
3333
```
3434

35-
<!-- <div class="equation" align="center" data-raw-text="y = b^x" data-equation="eq:exponential_function">
36-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@bb29798906e119fcb2af99e94b60407a270c9b32/lib/node_modules/@stdlib/math/base/special/powf/docs/img/equation_exponential_function.svg" alt="Exponential function">
37-
<br>
38-
</div> -->
39-
4035
<!-- </equation> -->
4136

4237
where `b` is the **base** and `x` is the **exponent**.
@@ -94,19 +89,17 @@ v = powf( NaN, NaN );
9489
<!-- eslint no-undef: "error" -->
9590

9691
```javascript
97-
var randu = require( '@stdlib/random/base/randu' );
98-
var roundf = require( '@stdlib/math/base/special/roundf' );
92+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
93+
var logEachMap = require( '@stdlib/console/log-each-map' );
9994
var powf = require( '@stdlib/math/base/special/powf' );
10095

101-
var b;
102-
var x;
103-
var i;
96+
var opts = {
97+
'dtype': 'float32'
98+
};
99+
var b = discreteUniform( 100, 0, 10, opts );
100+
var x = discreteUniform( 100, -5, 5, opts );
104101

105-
for ( i = 0; i < 100; i++ ) {
106-
b = roundf( randu()*10.0 );
107-
x = roundf( randu()*10.0 ) - 5.0;
108-
console.log( '%d^%d = %d', b, x, powf( b, x ) );
109-
}
102+
logEachMap( '%d^%d = %0.4f', b, x, powf );
110103
```
111104

112105
</section>
@@ -141,7 +134,7 @@ for ( i = 0; i < 100; i++ ) {
141134

142135
#### stdlib_base_powf( base, exponent )
143136

144-
Evaluates the exponential function for a single-precision floating-point number.
137+
Evaluates the [exponential function][exponential-function] for a single-precision floating-point number.
145138

146139
```c
147140
float out = stdlib_base_powf( 3.1415927410125732f, 5.0f );
@@ -210,13 +203,6 @@ int main( void ) {
210203

211204
<section class="related">
212205

213-
* * *
214-
215-
## See Also
216-
217-
- <span class="package-name">[`@stdlib/math/base/special/expf`][@stdlib/math/base/special/expf]</span><span class="delimiter">: </span><span class="description">natural exponential function.</span>
218-
- <span class="package-name">[`@stdlib/math/base/special/powm1`][@stdlib/math/base/special/powm1]</span><span class="delimiter">: </span><span class="description">evaluate bˣ - 1.</span>
219-
220206
</section>
221207

222208
<!-- /.related -->
@@ -229,10 +215,6 @@ int main( void ) {
229215

230216
<!-- <related-links> -->
231217

232-
[@stdlib/math/base/special/expf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/expf
233-
234-
[@stdlib/math/base/special/powm1]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/powm1
235-
236218
<!-- </related-links> -->
237219

238220
</section>

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

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,48 +21,30 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
25-
var isnanf = require( '@stdlib/math/base/assert/is-nan' );
24+
var uniform = require( '@stdlib/random/array/uniform' );
25+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2626
var pkg = require( './../package.json' ).name;
2727
var powf = require( './../lib' );
2828

2929

3030
// MAIN //
3131

3232
bench( pkg, function benchmark( b ) {
33+
var opts;
3334
var x;
3435
var y;
3536
var z;
3637
var i;
3738

38-
b.tic();
39-
for ( i = 0; i < b.iterations; i++ ) {
40-
x = ( randu()*100.0 ) - 0.0;
41-
y = ( randu()*100.0 ) - 50.0;
42-
z = powf( x, y );
43-
if ( isnanf( z ) ) {
44-
b.fail( 'should not return NaN' );
45-
}
46-
}
47-
b.toc();
48-
if ( isnanf( z ) ) {
49-
b.fail( 'should not return NaN' );
50-
}
51-
b.pass( 'benchmark finished' );
52-
b.end();
53-
});
54-
55-
bench( pkg+'::built-in', function benchmark( b ) {
56-
var x;
57-
var y;
58-
var z;
59-
var i;
39+
opts = {
40+
'dtype': 'float32'
41+
};
42+
x = uniform( 100, 0.0, 100.0, opts );
43+
y = uniform( 100, -50.0, 50.0, opts );
6044

6145
b.tic();
6246
for ( i = 0; i < b.iterations; i++ ) {
63-
x = ( randu()*100.0 ) - 0.0;
64-
y = ( randu()*100.0 ) - 50.0;
65-
z = Math.powf( x, y ); // eslint-disable-line stdlib/no-builtin-math
47+
z = powf( x[ i%x.length ], y[ i%y.length ] );
6648
if ( isnanf( z ) ) {
6749
b.fail( 'should not return NaN' );
6850
}

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

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

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
26-
var isnanf = require( '@stdlib/math/base/assert/is-nan' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
26+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2727
var tryRequire = require( '@stdlib/utils/try-require' );
2828
var pkg = require( './../package.json' ).name;
2929

@@ -39,22 +39,27 @@ var opts = {
3939
// MAIN //
4040

4141
bench( pkg+'::native', opts, function benchmark( b ) {
42-
var v;
42+
var opts;
4343
var x;
4444
var y;
45+
var z;
4546
var i;
4647

48+
opts = {
49+
'dtype': 'float32'
50+
};
51+
x = uniform( 100, 0.0, 100.0, opts );
52+
y = uniform( 100, -50.0, 50.0, opts );
53+
4754
b.tic();
4855
for ( i = 0; i < b.iterations; i++ ) {
49-
v = ( randu()*100.0 ) - 0.0;
50-
x = ( randu()*100.0 ) - 50.0;
51-
y = powf( v, x );
52-
if ( isnanf( y ) ) {
56+
z = powf( x[ i%x.length ], y[ i%y.length ] );
57+
if ( isnanf( z ) ) {
5358
b.fail( 'should not return NaN' );
5459
}
5560
}
5661
b.toc();
57-
if ( isnanf( y ) ) {
62+
if ( isnanf( z ) ) {
5863
b.fail( 'should not return NaN' );
5964
}
6065
b.pass( 'benchmark finished' );

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,15 @@ static double tic( void ) {
7474
}
7575

7676
/**
77-
* Generates a random number on the interval [0,1).
77+
* Generates a random number on the interval [min,max).
7878
*
79-
* @return random number
79+
* @param min minimum value (inclusive)
80+
* @param max maximum value (exclusive)
81+
* @return random number
8082
*/
81-
static float rand_float( void ) {
82-
int r = rand();
83-
return (float)r / ( (float)RAND_MAX + 1.0f );
83+
static float random_uniform( const float min, const float max ) {
84+
float v = (float)rand() / ( (float)RAND_MAX + 1.0f );
85+
return min + ( v*(max-min) );
8486
}
8587

8688
/**
@@ -90,17 +92,20 @@ static float rand_float( void ) {
9092
*/
9193
static double benchmark( void ) {
9294
double elapsed;
93-
float x;
94-
float y;
95-
float z;
95+
float x[ 100 ];
96+
float y[ 100 ];
9697
double t;
98+
float z;
9799
int i;
98100

101+
for ( i = 0; i < 100; i++ ) {
102+
x[ i ] = random_uniform( 0.0f, 100.0f );
103+
y[ i ] = random_uniform( -50.0f, 50.0f );
104+
}
105+
99106
t = tic();
100107
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = ( 100.0f*rand_float() ) - 0.0f;
102-
y = ( 100.0f*rand_float() ) - 50.0f;
103-
z = powf( x, y );
108+
z = powf( x[ i%100 ], y[ i%100 ] );
104109
if ( z != z ) {
105110
printf( "should not return NaN\n" );
106111
break;

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ static double tic( void ) {
7575
}
7676

7777
/**
78-
* Generates a random number on the interval [0,1).
78+
* Generates a random number on the interval [min,max).
7979
*
80-
* @return random number
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
8183
*/
82-
static float rand_float( void ) {
83-
int r = rand();
84-
return (float)r / ( (float)RAND_MAX + 1.0f );
84+
static float random_uniform( const float min, const float max ) {
85+
float v = (float)rand() / ( (float)RAND_MAX + 1.0f );
86+
return min + ( v*(max-min) );
8587
}
8688

8789
/**
@@ -91,24 +93,27 @@ static float rand_float( void ) {
9193
*/
9294
static double benchmark( void ) {
9395
double elapsed;
94-
float b;
95-
float x;
96-
float y;
96+
float x[ 100 ];
97+
float y[ 100 ];
9798
double t;
99+
float z;
98100
int i;
99101

102+
for ( i = 0; i < 100; i++ ) {
103+
x[ i ] = random_uniform( 0.0f, 100.0f );
104+
y[ i ] = random_uniform( -50.0f, 50.0f );
105+
}
106+
100107
t = tic();
101108
for ( i = 0; i < ITERATIONS; i++ ) {
102-
b = rand_float() * 10.0f;
103-
x = rand_float() * 5.0f;
104-
y = stdlib_base_powf( b, x );
105-
if ( y != y ) {
109+
z = stdlib_base_powf( x[ i%100 ], y[ i%100 ] );
110+
if ( z != z ) {
106111
printf( "should not return NaN\n" );
107112
break;
108113
}
109114
}
110115
elapsed = tic() - t;
111-
if ( y != y ) {
116+
if ( z != z ) {
112117
printf( "should not return NaN\n" );
113118
}
114119
return elapsed;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2025 The Stdlib Authors.
4+
* Copyright (c) 2019 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.
@@ -38,11 +38,11 @@
3838
* // returns 1.0
3939
*
4040
* @example
41-
* var v = powf( 3.1415927410125732, 5.0 );
41+
* var v = powf( 3.141592653589793, 5.0 );
4242
* // returns ~306.0197
4343
*
4444
* @example
45-
* var v = powf( 3.1415927410125732, -0.2 );
45+
* var v = powf( 3.141592653589793, -0.2 );
4646
* // returns ~0.7954
4747
*
4848
* @example

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

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) 2025 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/powf/examples/index.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818

1919
'use strict';
2020

21-
var randu = require( '@stdlib/random/base/randu' );
22-
var roundf = require( '@stdlib/math/base/special/roundf' );
23-
var powf = require('./../lib');
21+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
22+
var logEachMap = require( '@stdlib/console/log-each-map' );
23+
var powf = require( './../lib' );
2424

25-
var b;
26-
var x;
27-
var i;
25+
var opts = {
26+
'dtype': 'float32'
27+
};
28+
var b = discreteUniform( 100, 0, 10, opts );
29+
var x = discreteUniform( 100, -5, 5, opts );
2830

29-
for ( i = 0; i < 100; i++ ) {
30-
b = roundf( randu()*10.0 );
31-
x = roundf( randu()*10.0 ) - 5.0;
32-
console.log( '%d^%d = %d', b, x, powf( b, x ) );
33-
}
31+
logEachMap( '%d^%d = %0.4f', b, x, powf );

lib/node_modules/@stdlib/math/base/special/powf/package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "@stdlib/math/base/special/powf",
2+
"name": "@stdlib/math/base/special/pow",
33
"version": "0.0.0",
4-
"description": "Exponential function.",
4+
"description": "Exponential function for a single-precision floating-point number.",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",
@@ -57,7 +57,8 @@
5757
"stdmath",
5858
"mathematics",
5959
"math",
60-
"math.powf",
60+
"math.pow",
61+
"pow",
6162
"powf",
6263
"power",
6364
"natural",
@@ -68,7 +69,7 @@
6869
"__stdlib__": {
6970
"scaffold": {
7071
"$schema": "math/[email protected]",
71-
"base_alias": "powf",
72+
"base_alias": "pow",
7273
"alias": "powf",
7374
"pkg_desc": "exponential function",
7475
"desc": "exponential function",
@@ -104,9 +105,9 @@
104105
5.5,
105106
100,
106107
8.9,
107-
3.1415927410125732,
108+
3.141592653589793,
108109
11.3,
109-
-3.1415927410125732,
110+
-3.141592653589793,
110111
13.5,
111112
14.6,
112113
-15.7,
@@ -177,11 +178,12 @@
177178
"keywords": [
178179
"natural",
179180
"exponential",
181+
"pow",
180182
"powf",
181183
"power"
182184
],
183185
"extra_keywords": [
184-
"math.powf"
186+
"math.pow"
185187
]
186188
}
187189
}

0 commit comments

Comments
 (0)