Skip to content

Commit eaa7381

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents c10f095 + e920ce3 commit eaa7381

45 files changed

Lines changed: 2079 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,15 @@ setReadOnly( special, 'roundn', require( '@stdlib/math/base/special/roundn' ) );
846846
*/
847847
setReadOnly( special, 'roundsd', require( '@stdlib/math/base/special/roundsd' ) );
848848

849+
/**
850+
* @name sici
851+
* @memberof special
852+
* @readonly
853+
* @type {Function}
854+
* @see {@link module:@stdlib/math/base/special/sici}
855+
*/
856+
setReadOnly( special, 'sici', require( '@stdlib/math/base/special/sici' ) );
857+
849858
/**
850859
* @name signum
851860
* @memberof special
@@ -1008,6 +1017,24 @@ setReadOnly( special, 'vercos', require( '@stdlib/math/base/special/vercos' ) );
10081017
*/
10091018
setReadOnly( special, 'versin', require( '@stdlib/math/base/special/versin' ) );
10101019

1020+
/**
1021+
* @name xlog1py
1022+
* @memberof special
1023+
* @readonly
1024+
* @type {Function}
1025+
* @see {@link module:@stdlib/math/base/special/xlog1py}
1026+
*/
1027+
setReadOnly( special, 'xlog1py', require( '@stdlib/math/base/special/xlog1py' ) );
1028+
1029+
/**
1030+
* @name xlogy
1031+
* @memberof special
1032+
* @readonly
1033+
* @type {Function}
1034+
* @see {@link module:@stdlib/math/base/special/xlogy}
1035+
*/
1036+
setReadOnly( special, 'xlogy', require( '@stdlib/math/base/special/xlogy' ) );
1037+
10111038

10121039
// EXPORTS //
10131040

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# sici
2+
3+
> Compute the sine and cosine integrals.
4+
5+
6+
<section class="intro">
7+
8+
The sine integral is defined as
9+
10+
<!-- <equation class="equation" label="eq:sine_integral" align="center" raw="\int_0^x \frac{\sin t}{t}\; dt" alt="Sine integral."> -->
11+
12+
<div class="equation" align="center" data-raw-text="\int_0^x \frac{\sin t}{t}\; dt" data-equation="eq:sine_integral">
13+
<img src="" alt="Sine integral.">
14+
<br>
15+
</div>
16+
17+
<!-- </equation> -->
18+
19+
and the cosine integral is
20+
21+
<!-- <equation class="equation" label="eq:cosine_integral" align="center" raw="\gamma + \log( x ) + \int_0^x \frac{\cos t - 1}{t}\; dt" alt="Sine integral."> -->
22+
23+
<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">
24+
<img src="" alt="Cosine integral.">
25+
<br>
26+
</div>
27+
28+
<!-- </equation> -->
29+
30+
where `γ` is the [Euler-Mascheroni][eulergamma] constant.
31+
32+
</section>
33+
34+
<!-- /.intro -->
35+
36+
<section class="usage">
37+
38+
## Usage
39+
40+
``` javascript
41+
var sici = require( '@stdlib/math/base/special/sici' );
42+
```
43+
44+
#### sici( x )
45+
46+
Computes the sine and cosine integrals.
47+
48+
``` javascript
49+
var v = sici( 3.0 );
50+
// returns [ ~1.849, ~0.12 ]
51+
```
52+
53+
The first element of the returned `array` is the sine integral and the second is the cosine integral.
54+
55+
``` javascript
56+
var v = sici( 0.0 );
57+
// returns [ 0.0, Number.NEGATIVE_INFINITY ]
58+
59+
v = sici( -9.0 );
60+
// returns [ ~-1.665, ~0.055 ]
61+
62+
v = sici( NaN );
63+
// returns [ NaN, NaN ]
64+
```
65+
66+
</section>
67+
68+
<!-- /.usage -->
69+
70+
71+
<section class="examples">
72+
73+
## Examples
74+
75+
``` javascript
76+
var randu = require( '@stdlib/math/base/random/randu' );
77+
var sici = require( '@stdlib/math/base/special/sici' );
78+
79+
var x;
80+
var y;
81+
var i;
82+
83+
for ( i = 0; i < 100; i++ ) {
84+
x = randu() * 100.0;
85+
y = sici( x );
86+
console.log( 'si( %d ) = %d, ci( %d ) = %d', x, y[ 0 ], x, y[ 1 ] );
87+
}
88+
```
89+
90+
</section>
91+
92+
<!-- /.examples -->
93+
94+
95+
<section class="links">
96+
97+
[eulergamma]: http://mathworld.wolfram.com/Euler-MascheroniConstant.html
98+
99+
</section>
100+
101+
<!-- /.links -->
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
// MODULES //
4+
5+
var bench = require( '@stdlib/bench' );
6+
var randu = require( '@stdlib/math/base/random/randu' );
7+
var isArray = require( '@stdlib/assert/is-array' );
8+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
9+
var pkg = require( './../package.json' ).name;
10+
var sici = require( './../lib' );
11+
12+
13+
// MAIN //
14+
15+
bench( pkg, function benchmark( b ) {
16+
var x;
17+
var y;
18+
var i;
19+
20+
b.tic();
21+
for ( i = 0; i < b.iterations; i++ ) {
22+
x = ( randu() * 100.0 ) - 50.0;
23+
y = sici( x );
24+
if ( !isArray( y ) ) {
25+
b.fail( 'should return an array' );
26+
}
27+
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
28+
b.fail( 'should not return NaN' );
29+
}
30+
}
31+
b.toc();
32+
if ( !isArray( y ) ) {
33+
b.fail( 'should return an array' );
34+
}
35+
if ( isnan( y[ 0 ] ) || isnan( y[ 1 ] ) ) {
36+
b.fail( 'should not return NaN' );
37+
}
38+
b.pass( 'benchmark finished' );
39+
b.end();
40+
});
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env python
2+
"""Benchmark scipy.special.sici."""
3+
4+
from __future__ import print_function
5+
import timeit
6+
7+
NAME = "sici"
8+
REPEATS = 3
9+
ITERATIONS = 1000000
10+
11+
12+
def print_version():
13+
"""Print the TAP version."""
14+
print("TAP version 13")
15+
16+
17+
def print_summary(total, passing):
18+
"""Print the benchmark summary.
19+
20+
# Arguments
21+
22+
* `total`: total number of tests
23+
* `passing`: number of passing tests
24+
25+
"""
26+
print("#")
27+
print("1.." + str(total)) # TAP plan
28+
print("# total " + str(total))
29+
print("# pass " + str(passing))
30+
print("#")
31+
print("# ok")
32+
33+
34+
def print_results(elapsed):
35+
"""Print benchmark results.
36+
37+
# Arguments
38+
39+
* `elapsed`: elapsed time (in seconds)
40+
41+
# Examples
42+
43+
``` python
44+
python> print_results(0.131009101868)
45+
```
46+
"""
47+
rate = ITERATIONS / elapsed
48+
49+
print(" ---")
50+
print(" iterations: " + str(ITERATIONS))
51+
print(" elapsed: " + str(elapsed))
52+
print(" rate: " + str(rate))
53+
print(" ...")
54+
55+
56+
def benchmark():
57+
"""Run the benchmark and print benchmark results."""
58+
setup = "from scipy.special import sici; from random import random;"
59+
stmt = "y = sici(100.0*random()-50.0)"
60+
61+
t = timeit.Timer(stmt, setup=setup)
62+
63+
print_version()
64+
65+
for i in xrange(REPEATS):
66+
print("# python::" + NAME)
67+
elapsed = t.timeit(number=ITERATIONS)
68+
print_results(elapsed)
69+
print("ok " + str(i+1) + " benchmark finished")
70+
71+
print_summary(REPEATS, REPEATS)
72+
73+
74+
def main():
75+
"""Run the benchmark."""
76+
benchmark()
77+
78+
79+
if __name__ == "__main__":
80+
main()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
{{alias}}( x )
3+
Computes the sine and cosine integrals.
4+
5+
Parameters
6+
----------
7+
x: number
8+
Input value.
9+
10+
Returns
11+
-------
12+
out: Array<number>
13+
Two element array containing the sine and cosine integrals (in that order).
14+
15+
Examples
16+
--------
17+
> var y = {{alias}}( 3.0 )
18+
[ ~1.849, ~0.12 ]
19+
> y = {{alias}}( 0.0 )
20+
[ 0.0, -infinity ]
21+
> y = {{alias}}( -9.0 )
22+
[ ~-1.665, ~0.055 ]
23+
> y = {{alias}}( NaN )
24+
[ NaN, NaN ]
25+
26+
See Also
27+
--------
28+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
var randu = require( '@stdlib/math/base/random/randu' );
4+
var sici = require( './../lib' );
5+
6+
var x;
7+
var y;
8+
var i;
9+
10+
for ( i = 0; i < 100; i++ ) {
11+
x = randu() * 100.0;
12+
y = sici( x );
13+
console.log( 'si( %d ) = %d, ci( %d ) = %d', x, y[ 0 ], x, y[ 1 ] );
14+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
/**
4+
* Compute the sine and cosine integrals.
5+
*
6+
* @module @stdlib/math/base/special/sici
7+
*
8+
* @example
9+
* var sici = require( '@stdlib/math/base/special/sici' );
10+
*
11+
* var v = sici( 3.0 );
12+
* // returns [ ~1.849, ~0.12 ]
13+
*
14+
* v = sici( 0.0 );
15+
* // returns [ 0.0, Number.NEGATIVE_INFINITY ]
16+
*
17+
* v = sici( -9.0 );
18+
* // returns [ ~-1.665, ~0.055 ]
19+
*
20+
* v = sici( NaN );
21+
* // returns [ NaN, NaN ]
22+
*/
23+
24+
// MODULES //
25+
26+
var sici = require( './sici.js' );
27+
28+
29+
// EXPORTS //
30+
31+
module.exports = sici;

0 commit comments

Comments
 (0)