Skip to content

Commit 8fc4c74

Browse files
committed
feat: add math/base/special/ellipkf
--- 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - 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: passed - task: lint_license_headers status: passed ---
1 parent 313e5de commit 8fc4c74

File tree

30 files changed

+241
-1281
lines changed

30 files changed

+241
-1281
lines changed

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

Lines changed: 30 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2022 The Stdlib Authors.
5+
Copyright (c) 2025 The Stdlib Authors.
66
77
Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
@@ -18,9 +18,9 @@ limitations under the License.
1818
1919
-->
2020

21-
# ellipk
21+
# ellipkf
2222

23-
> Compute the [complete elliptic integral of the first kind][elliptic-integral].
23+
> Compute the [complete elliptic integral of the first kind][elliptic-integral] for a single-precision floating-point number.
2424
2525
<section class="intro">
2626

@@ -32,11 +32,6 @@ The [complete elliptic integral of the first kind][elliptic-integral] is defined
3232
K(m)=\int_0^\tfrac{\pi}{2} \frac{d\theta}{\sqrt{1-m \sin^2\theta}}
3333
```
3434

35-
<!-- <div class="equation" align="center" data-raw-text="K(m)=\int_0^\tfrac{\pi}{2} \frac{d\theta}{\sqrt{1-m \sin^2\theta}}" data-equation="eq:complete_elliptic_integral_first_kind">
36-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@fa2cf1d471224644251a972f9424f30bde62c2c3/lib/node_modules/@stdlib/math/base/special/ellipk/docs/img/equation_complete_elliptic_integral_first_kind.svg" alt="Complete elliptic integral of the first kind">
37-
<br>
38-
</div> -->
39-
4035
<!-- </equation> -->
4136

4237
where the parameter `m` is related to the modulus `k` by `m = k^2`.
@@ -50,30 +45,30 @@ where the parameter `m` is related to the modulus `k` by `m = k^2`.
5045
## Usage
5146

5247
```javascript
53-
var ellipk = require( '@stdlib/math/base/special/ellipk' );
48+
var ellipkf = require( '@stdlib/math/base/special/ellipkf' );
5449
```
5550

56-
#### ellipk( m )
51+
#### ellipkf( m )
5752

58-
Computes the [complete elliptic integral of the first kind][elliptic-integral].
53+
Computes the [complete elliptic integral of the first kind][elliptic-integral] for a single-precision floating-point number.
5954

6055
```javascript
61-
var v = ellipk( 0.5 );
56+
var v = ellipkf( 0.5 );
6257
// returns ~1.854
6358

64-
v = ellipk( -1.0 );
59+
v = ellipkf( -1.0 );
6560
// returns ~1.311
6661

67-
v = ellipk( 2.0 );
62+
v = ellipkf( 2.0 );
6863
// returns NaN
6964

70-
v = ellipk( Infinity );
65+
v = ellipkf( Infinity );
7166
// returns NaN
7267

73-
v = ellipk( -Infinity );
68+
v = ellipkf( -Infinity );
7469
// returns NaN
7570

76-
v = ellipk( NaN );
71+
v = ellipkf( NaN );
7772
// returns NaN
7873
```
7974

@@ -100,14 +95,14 @@ v = ellipk( NaN );
10095
```javascript
10196
var uniform = require( '@stdlib/random/array/uniform' );
10297
var logEachMap = require( '@stdlib/console/log-each-map' );
103-
var ellipk = require( '@stdlib/math/base/special/ellipk' );
98+
var ellipkf = require( '@stdlib/math/base/special/ellipkf' );
10499

105100
var opts = {
106-
'dtype': 'float64'
101+
'dtype': 'float32'
107102
};
108103
var m = uniform( 100, -1.0, 1.0, opts );
109104

110-
logEachMap( 'ellipk(%0.4f) = %0.4f', m, ellipk );
105+
logEachMap( 'ellipkf(%0.4f) = %0.4f', m, ellipkf );
111106
```
112107

113108
</section>
@@ -137,27 +132,27 @@ logEachMap( 'ellipk(%0.4f) = %0.4f', m, ellipk );
137132
### Usage
138133

139134
```c
140-
#include "stdlib/math/base/special/ellipk.h"
135+
#include "stdlib/math/base/special/ellipkf.h"
141136
```
142137

143-
#### stdlib_base_ellipk( m )
138+
#### stdlib_base_ellipkf( m )
144139

145-
Computes the [complete elliptic integral of the first kind][elliptic-integral].
140+
Computes the [complete elliptic integral of the first kind][elliptic-integral] for a single-precision floating-point number.
146141

147142
```c
148-
double out = stdlib_base_ellipk( 0.5 );
149-
// returns ~1.854
143+
float out = stdlib_base_ellipkf( 0.5f );
144+
// returns ~1.854f
150145

151-
out = stdlib_base_ellipk( -1.0 );
152-
// returns ~1.311
146+
out = stdlib_base_ellipkf( -1.0f );
147+
// returns ~1.311f
153148
```
154149

155150
The function accepts the following arguments:
156151

157-
- **x**: `[in] double` input value.
152+
- **x**: `[in] float` input value.
158153

159154
```c
160-
double stdlib_base_ellipk( const double m );
155+
float stdlib_base_ellipkf( const float m );
161156
```
162157
163158
</section>
@@ -179,19 +174,19 @@ double stdlib_base_ellipk( const double m );
179174
### Examples
180175
181176
```c
182-
#include "stdlib/math/base/special/ellipk.h"
177+
#include "stdlib/math/base/special/ellipkf.h"
183178
#include <stdlib.h>
184179
#include <stdio.h>
185180
186181
int main( void ) {
187-
double m;
188-
double v;
182+
float m;
183+
float v;
189184
int i;
190185
191186
for ( i = 0; i < 100; i++ ) {
192-
m = -1.0 + ( ( (double)rand() / (double)RAND_MAX ) * 2.0 );
193-
v = stdlib_base_ellipk( m );
194-
printf( "ellipk(%lf) = %lf\n", m, v );
187+
m = -1.0f + ( ( (float)rand() / (float)RAND_MAX ) * 2.0f );
188+
v = stdlib_base_ellipkf( m );
189+
printf( "ellipkf(%f) = %f\n", m, v );
195190
}
196191
}
197192
```
@@ -208,11 +203,6 @@ int main( void ) {
208203

209204
<section class="references">
210205

211-
## References
212-
213-
- Fukushima, Toshio. 2009. "Fast computation of complete elliptic integrals and Jacobian elliptic functions." _Celestial Mechanics and Dynamical Astronomy_ 105 (4): 305. doi:[10.1007/s10569-009-9228-z][@fukushima:2009a].
214-
- Fukushima, Toshio. 2015. "Precise and fast computation of complete elliptic integrals by piecewise minimax rational function approximation." _Journal of Computational and Applied Mathematics_ 282 (July): 71–76. doi:[10.1016/j.cam.2014.12.038][@fukushima:2015a].
215-
216206
</section>
217207

218208
<!-- /.references -->
@@ -221,13 +211,6 @@ int main( void ) {
221211

222212
<section class="related">
223213

224-
* * *
225-
226-
## See Also
227-
228-
- <span class="package-name">[`@stdlib/math/base/special/ellipe`][@stdlib/math/base/special/ellipe]</span><span class="delimiter">: </span><span class="description">compute the complete elliptic integral of the second kind.</span>
229-
- <span class="package-name">[`@stdlib/math/base/special/ellipj`][@stdlib/math/base/special/ellipj]</span><span class="delimiter">: </span><span class="description">compute the Jacobi elliptic functions sn, cn, and dn.</span>
230-
231214
</section>
232215

233216
<!-- /.related -->
@@ -238,16 +221,8 @@ int main( void ) {
238221

239222
[elliptic-integral]: https://en.wikipedia.org/wiki/Elliptic_integral
240223

241-
[@fukushima:2009a]: https://doi.org/10.1007/s10569-009-9228-z
242-
243-
[@fukushima:2015a]: https://doi.org/10.1016/j.cam.2014.12.038
244-
245224
<!-- <related-links> -->
246225

247-
[@stdlib/math/base/special/ellipe]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/ellipe
248-
249-
[@stdlib/math/base/special/ellipj]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/ellipj
250-
251226
<!-- </related-links> -->
252227

253228
</section>

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

Lines changed: 12 additions & 7 deletions
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) 2025 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,27 +21,32 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
25-
var isnan = 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;
27-
var ellipk = require( './../lib' );
27+
var ellipkf = require( './../lib' );
2828

2929

3030
// MAIN //
3131

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

37+
x = uniform( 100, -1.0, 1.0, {
38+
'dtype': 'float32'
39+
});
40+
3641
b.tic();
3742
for ( i = 0; i < b.iterations; i++ ) {
38-
y = ellipk( randu() );
39-
if ( isnan( y ) ) {
43+
y = ellipkf( x[ i%x.length ] );
44+
if ( isnanf( y ) ) {
4045
b.fail( 'should not return NaN' );
4146
}
4247
}
4348
b.toc();
44-
if ( isnan( y ) ) {
49+
if ( isnanf( y ) ) {
4550
b.fail( 'should not return NaN' );
4651
}
4752
b.pass( 'benchmark finished' );

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2022 The Stdlib Authors.
4+
* Copyright (c) 2025 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.
@@ -22,35 +22,40 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var randu = require( '@stdlib/random/base/randu' );
26-
var isnan = 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

3030

3131
// VARIABLES //
3232

33-
var ellipk = tryRequire( resolve( __dirname, './../lib/native.js' ) );
33+
var ellipkf = tryRequire( resolve( __dirname, './../lib/native.js' ) );
3434
var opts = {
35-
'skip': ( ellipk instanceof Error )
35+
'skip': ( ellipkf instanceof Error )
3636
};
3737

3838

3939
// MAIN //
4040

4141
bench( pkg+'::native', opts, function benchmark( b ) {
42+
var x;
4243
var y;
4344
var i;
4445

46+
x = uniform( 100, -1.0, 1.0, {
47+
'dtype': 'float32'
48+
});
49+
4550
b.tic();
4651
for ( i = 0; i < b.iterations; i++ ) {
47-
y = ellipk( randu() );
48-
if ( isnan( y ) ) {
52+
y = ellipkf( x[ i%x.length ] );
53+
if ( isnanf( y ) ) {
4954
b.fail( 'should not return NaN' );
5055
}
5156
}
5257
b.toc();
53-
if ( isnan( y ) ) {
58+
if ( isnanf( y ) ) {
5459
b.fail( 'should not return NaN' );
5560
}
5661
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/math/base/special/ellipkf/benchmark/c/native/Makefile

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) 2022 The Stdlib Authors.
4+
# Copyright (c) 2025 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/ellipkf/benchmark/c/native/benchmark.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2022 The Stdlib Authors.
4+
* Copyright (c) 2025 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.
@@ -16,14 +16,14 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "stdlib/math/base/special/ellipk.h"
19+
#include "stdlib/math/base/special/ellipkf.h"
2020
#include <stdlib.h>
2121
#include <stdio.h>
2222
#include <math.h>
2323
#include <time.h>
2424
#include <sys/time.h>
2525

26-
#define NAME "ellipk"
26+
#define NAME "ellipkf"
2727
#define ITERATIONS 1000000
2828
#define REPEATS 3
2929

@@ -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 double rand_double( void ) {
83-
int r = rand();
84-
return (double)r / ( (double)RAND_MAX + 1.0 );
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
/**
@@ -90,16 +92,19 @@ static double rand_double( void ) {
9092
* @return elapsed time in seconds
9193
*/
9294
static double benchmark( void ) {
95+
float x[ 100 ];
9396
double elapsed;
94-
double x;
95-
double y;
9697
double t;
98+
float y;
9799
int i;
98100

101+
for ( i = 0; i < 100; i++ ) {
102+
x[ i ] = random_uniform( -1.0f, 1.0f );
103+
}
104+
99105
t = tic();
100106
for ( i = 0; i < ITERATIONS; i++ ) {
101-
x = rand_double();
102-
y = stdlib_base_ellipk( x );
107+
y = stdlib_base_ellipkf( x[ i%100 ] );
103108
if ( y != y ) {
104109
printf( "should not return NaN\n" );
105110
break;

0 commit comments

Comments
 (0)