Skip to content

Commit 34d60c6

Browse files
committed
feat: add JS implementation for math/base/special/sicif
--- 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: passed - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - 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 6292931 commit 34d60c6

39 files changed

+465
-636
lines changed

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

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2018 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-
# sici
21+
# sicif
2222

23-
> Compute the sine and cosine integrals.
23+
> Compute the sine and cosine integrals in single-precision floating-point format.
2424
2525
<section class="intro">
2626

@@ -32,11 +32,6 @@ The sine integral is defined as
3232
\int_0^x \frac{\sin t}{t}\; dt
3333
```
3434

35-
<!-- <div class="equation" align="center" data-raw-text="\int_0^x \frac{\sin t}{t}\; dt" data-equation="eq:sine_integral">
36-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@9d139bffba6eb2d0113c8412c1a9bf60ca59ac60/lib/node_modules/@stdlib/math/base/special/sici/docs/img/equation_sine_integral.svg" alt="Sine integral.">
37-
<br>
38-
</div> -->
39-
4035
<!-- </equation> -->
4136

4237
and the cosine integral is defined as
@@ -47,11 +42,6 @@ and the cosine integral is defined as
4742
\gamma + \log( x ) + \int_0^x \frac{\cos t - 1}{t}\; dt
4843
```
4944

50-
<!-- <div class="equation" align="center" data-raw-text="\gamma + \log( x ) + \int_0^x \frac{\cos t - 1}{t}\; dt" data-equation="eq:cosine_integral">
51-
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@9d139bffba6eb2d0113c8412c1a9bf60ca59ac60/lib/node_modules/@stdlib/math/base/special/sici/docs/img/equation_cosine_integral.svg" alt="Cosine integral.">
52-
<br>
53-
</div> -->
54-
5545
<!-- </equation> -->
5646

5747
where `γ` is the [Euler-Mascheroni][eulergamma] constant.
@@ -65,38 +55,38 @@ where `γ` is the [Euler-Mascheroni][eulergamma] constant.
6555
## Usage
6656

6757
```javascript
68-
var sici = require( '@stdlib/math/base/special/sici' );
58+
var sicif = require( '@stdlib/math/base/special/sicif' );
6959
```
7060

71-
#### sici( x )
61+
#### sicif( x )
7262

73-
Computes the sine and cosine integrals.
63+
Computes the sine and cosine integrals in single-precision floating-point format.
7464

7565
```javascript
76-
var v = sici( 3.0 );
66+
var v = sicif( 3.0 );
7767
// returns [ ~1.849, ~0.12 ]
7868

79-
v = sici( 0.0 );
69+
v = sicif( 0.0 );
8070
// returns [ 0.0, -Infinity ]
8171

82-
v = sici( -9.0 );
72+
v = sicif( -9.0 );
8373
// returns [ ~-1.665, ~0.055 ]
8474

85-
v = sici( NaN );
75+
v = sicif( NaN );
8676
// returns [ NaN, NaN ]
8777
```
8878

89-
#### sici.assign( x, out, stride, offset )
79+
#### sicif.assign( x, out, stride, offset )
9080

91-
Computes the sine and cosine integrals and assigns results to a provided output array.
81+
Computes the sine and cosine integrals in single-precision floating-point format and assigns results to a provided output array.
9282

9383
```javascript
94-
var Float64Array = require( '@stdlib/array/float64' );
84+
var Float32Array = require( '@stdlib/array/float32' );
9585

96-
var out = new Float64Array( 2 );
86+
var out = new Float32Array( 2 );
9787

98-
var v = sici.assign( 3.0, out, 1, 0 );
99-
// returns <Float64Array>[ ~1.849, ~0.12 ]
88+
var v = sicif.assign( 3.0, out, 1, 0 );
89+
// returns <Float32Array>[ ~1.849, ~0.12 ]
10090

10191
var bool = ( v === out );
10292
// returns true
@@ -114,15 +104,15 @@ var bool = ( v === out );
114104

115105
```javascript
116106
var randu = require( '@stdlib/random/base/randu' );
117-
var sici = require( '@stdlib/math/base/special/sici' );
107+
var sicif = require( '@stdlib/math/base/special/sicif' );
118108

119109
var x;
120110
var y;
121111
var i;
122112

123113
for ( i = 0; i < 100; i++ ) {
124114
x = randu() * 100.0;
125-
y = sici( x );
115+
y = sicif( x );
126116
console.log( 'si(%d) = %d, ci(%d) = %d', x, y[ 0 ], x, y[ 1 ] );
127117
}
128118
```

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

Lines changed: 15 additions & 11 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) 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.
@@ -23,9 +23,9 @@
2323
var bench = require( '@stdlib/bench' );
2424
var uniform = require( '@stdlib/random/array/uniform' );
2525
var isArray = require( '@stdlib/assert/is-array' );
26-
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2727
var pkg = require( './../package.json' ).name;
28-
var sici = require( './../lib' );
28+
var sicif = require( './../lib' );
2929

3030

3131
// MAIN //
@@ -35,20 +35,22 @@ bench( pkg, function benchmark( b ) {
3535
var y;
3636
var i;
3737

38-
x = uniform( 100, -50.0, 50.0 );
38+
x = uniform( 100, -50.0, 50.0, {
39+
'dtype': 'float32'
40+
});
3941

4042
b.tic();
4143
for ( i = 0; i < b.iterations; i++ ) {
42-
y = sici( x[ i%x.length ] );
43-
if ( isnan( y[ 0 ] ) ) {
44+
y = sicif( x[ i%x.length ] );
45+
if ( isnanf( y[ 0 ] ) ) {
4446
b.fail( 'should not return NaN' );
4547
}
4648
}
4749
b.toc();
4850
if ( !isArray( y ) ) {
4951
b.fail( 'should return an array' );
5052
}
51-
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
53+
if ( isnanf( y[ 0 ] ) || isnanf( y[ 1 ] ) ) {
5254
b.fail( 'should not return NaN' );
5355
}
5456
b.pass( 'benchmark finished' );
@@ -62,20 +64,22 @@ bench( pkg+':assign', function benchmark( b ) {
6264
var i;
6365

6466
out = [ 0.0, 0.0 ];
65-
x = uniform( 100, -50.0, 50.0 );
67+
x = uniform( 100, -50.0, 50.0, {
68+
'dtype': 'float32'
69+
});
6670

6771
b.tic();
6872
for ( i = 0; i < b.iterations; i++ ) {
69-
y = sici.assign( x[ i%x.length ], out, 1, 0 );
70-
if ( isnan( y[ 0 ] ) ) {
73+
y = sicif.assign( x[ i%x.length ], out, 1, 0 );
74+
if ( isnanf( y[ 0 ] ) ) {
7175
b.fail( 'should not return NaN' );
7276
}
7377
}
7478
b.toc();
7579
if ( !isArray( y ) || y !== out ) {
7680
b.fail( 'should return the output array' );
7781
}
78-
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
82+
if ( isnanf( y[ 0 ] ) || isnanf( y[ 1 ] ) ) {
7983
b.fail( 'should not return NaN' );
8084
}
8185
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/math/base/special/sicif/benchmark/c/cephes/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) 2018 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/sicif/benchmark/c/cephes/benchmark.c

Lines changed: 14 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) 2018 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,14 +22,14 @@
2222
#include <time.h>
2323
#include <sys/time.h>
2424

25-
#define NAME "sici"
25+
#define NAME "sicif"
2626
#define ITERATIONS 1000000
2727
#define REPEATS 3
2828

2929
/**
3030
* Define prototypes for external functions.
3131
*/
32-
extern int sici( double x, double *si, double *ci );
32+
extern int sici( float x, float *si, float *ci );
3333

3434
/**
3535
* Prints the TAP version.
@@ -79,13 +79,15 @@ static double tic( void ) {
7979
}
8080

8181
/**
82-
* Generates a random number on the interval [0,1).
82+
* Generates a random number on the interval [min,max).
8383
*
84-
* @return random number
84+
* @param min minimum value (inclusive)
85+
* @param max maximum value (exclusive)
86+
* @return random number
8587
*/
86-
static double rand_double( void ) {
87-
int r = rand();
88-
return (double)r / ( (double)RAND_MAX + 1.0 );
88+
static float random_uniform( const float min, const float max ) {
89+
float v = (float)rand() / ( (float)RAND_MAX + 1.0f );
90+
return min + ( v*(max-min) );
8991
}
9092

9193
/**
@@ -94,15 +96,15 @@ static double rand_double( void ) {
9496
* @return elapsed time in seconds
9597
*/
9698
static double benchmark( void ) {
97-
double x[ 100 ];
9899
double elapsed;
99-
double y;
100-
double z;
100+
float x[ 100 ];
101101
double t;
102+
float y;
103+
float z;
102104
int i;
103105

104106
for ( i = 0; i < 100; i++ ) {
105-
x[ i ] = ( 100.0*rand_double() ) - 50.0;
107+
x[ i ] = random_uniform( -50.0f, 50.0f );
106108
}
107109

108110
t = tic();

lib/node_modules/@stdlib/math/base/special/sicif/benchmark/python/scipy/benchmark.py

Lines changed: 0 additions & 97 deletions
This file was deleted.

0 commit comments

Comments
 (0)