Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit c3ab752

Browse files
authored
Add basic docstrings to some functions (#337)
* Add docstring to Bessel functions * Add docstrings to logarithm functions * Add docstrings to pow functions * Specify argument bit-size of the Bessel functions * Specify argument bit-size for pow functions * Specify argument bit-size for logarithms * Add docstrings to sin, cos, sincos and sinh functions * Add docstrings to sqrt * Add docstrings to tan and tanh functions * Add an inline link to https://en.wikipedia.org/wiki/Bessel_function to the docstrings of all Bessel functions.
1 parent 3f2db72 commit c3ab752

30 files changed

+61
-0
lines changed

src/math/cos.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ use super::{k_cos, k_sin, rem_pio2};
4141
// Accuracy:
4242
// TRIG(x) returns trig(x) nearly rounded
4343
//
44+
45+
/// The cosine of `x` (f64).
46+
///
47+
/// `x` is specified in radians.
4448
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
4549
pub fn cos(x: f64) -> f64 {
4650
let ix = (f64::to_bits(x) >> 32) as u32 & 0x7fffffff;

src/math/cosf.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const C2_PIO2: f64 = 2. * FRAC_PI_2; /* 0x400921FB, 0x54442D18 */
2424
const C3_PIO2: f64 = 3. * FRAC_PI_2; /* 0x4012D97C, 0x7F3321D2 */
2525
const C4_PIO2: f64 = 4. * FRAC_PI_2; /* 0x401921FB, 0x54442D18 */
2626

27+
/// The cosine of `x` (f32).
28+
///
29+
/// `x` is specified in radians.
2730
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
2831
pub fn cosf(x: f32) -> f32 {
2932
let x64 = x as f64;

src/math/j0.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const S02: f64 = 1.16926784663337450260e-04; /* 0x3F1EA6D2, 0xDD57DBF4 */
109109
const S03: f64 = 5.13546550207318111446e-07; /* 0x3EA13B54, 0xCE84D5A9 */
110110
const S04: f64 = 1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */
111111

112+
/// Zeroth order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f64).
112113
pub fn j0(mut x: f64) -> f64 {
113114
let z: f64;
114115
let r: f64;
@@ -162,6 +163,7 @@ const V02: f64 = 7.60068627350353253702e-05; /* 0x3F13ECBB, 0xF578C6C1 */
162163
const V03: f64 = 2.59150851840457805467e-07; /* 0x3E91642D, 0x7FF202FD */
163164
const V04: f64 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */
164165

166+
/// Zeroth order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f64).
165167
pub fn y0(x: f64) -> f64 {
166168
let z: f64;
167169
let u: f64;

src/math/j0f.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const S02: f32 = 1.1692678527e-04; /* 0x38f53697 */
6262
const S03: f32 = 5.1354652442e-07; /* 0x3509daa6 */
6363
const S04: f32 = 1.1661400734e-09; /* 0x30a045e8 */
6464

65+
/// Zeroth order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f32).
6566
pub fn j0f(mut x: f32) -> f32 {
6667
let z: f32;
6768
let r: f32;
@@ -107,6 +108,7 @@ const V02: f32 = 7.6006865129e-05; /* 0x389f65e0 */
107108
const V03: f32 = 2.5915085189e-07; /* 0x348b216c */
108109
const V04: f32 = 4.4111031494e-10; /* 0x2ff280c2 */
109110

111+
/// Zeroth order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f32).
110112
pub fn y0f(x: f32) -> f32 {
111113
let z: f32;
112114
let u: f32;

src/math/j1.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ const S03: f64 = 1.17718464042623683263e-06; /* 0x3EB3BFF8, 0x333F8498 */
113113
const S04: f64 = 5.04636257076217042715e-09; /* 0x3E35AC88, 0xC97DFF2C */
114114
const S05: f64 = 1.23542274426137913908e-11; /* 0x3DAB2ACF, 0xCFB97ED8 */
115115

116+
/// First order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f64).
116117
pub fn j1(x: f64) -> f64 {
117118
let mut z: f64;
118119
let r: f64;
@@ -158,6 +159,7 @@ const V0: [f64; 5] = [
158159
1.66559246207992079114e-11, /* 0x3DB25039, 0xDACA772A */
159160
];
160161

162+
/// First order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f64).
161163
pub fn y1(x: f64) -> f64 {
162164
let z: f64;
163165
let u: f64;

src/math/j1f.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const S03: f32 = 1.1771846857e-06; /* 0x359dffc2 */
6363
const S04: f32 = 5.0463624390e-09; /* 0x31ad6446 */
6464
const S05: f32 = 1.2354227016e-11; /* 0x2d59567e */
6565

66+
/// First order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f32).
6667
pub fn j1f(x: f32) -> f32 {
6768
let mut z: f32;
6869
let r: f32;
@@ -107,6 +108,7 @@ const V0: [f32; 5] = [
107108
1.6655924903e-11, /* 0x2d9281cf */
108109
];
109110

111+
/// First order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f32).
110112
pub fn y1f(x: f32) -> f32 {
111113
let z: f32;
112114
let u: f32;

src/math/jn.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use super::{cos, fabs, get_high_word, get_low_word, j0, j1, log, sin, sqrt, y0,
3838

3939
const INVSQRTPI: f64 = 5.64189583547756279280e-01; /* 0x3FE20DD7, 0x50429B6D */
4040

41+
/// Integer order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f64).
4142
pub fn jn(n: i32, mut x: f64) -> f64 {
4243
let mut ix: u32;
4344
let lx: u32;
@@ -247,6 +248,7 @@ pub fn jn(n: i32, mut x: f64) -> f64 {
247248
if sign { -b } else { b }
248249
}
249250

251+
/// Integer order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f64).
250252
pub fn yn(n: i32, x: f64) -> f64 {
251253
let mut ix: u32;
252254
let lx: u32;

src/math/jnf.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use super::{fabsf, j0f, j1f, logf, y0f, y1f};
1717

18+
/// Integer order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f32).
1819
pub fn jnf(n: i32, mut x: f32) -> f32 {
1920
let mut ix: u32;
2021
let mut nm1: i32;
@@ -191,6 +192,7 @@ pub fn jnf(n: i32, mut x: f32) -> f32 {
191192
if sign { -b } else { b }
192193
}
193194

195+
/// Integer order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f32).
194196
pub fn ynf(n: i32, x: f32) -> f32 {
195197
let mut ix: u32;
196198
let mut ib: u32;

src/math/log.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const LG5: f64 = 1.818357216161805012e-01; /* 3FC74664 96CB03DE */
7070
const LG6: f64 = 1.531383769920937332e-01; /* 3FC39A09 D078C69F */
7171
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
7272

73+
/// The natural logarithm of `x` (f64).
7374
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
7475
pub fn log(mut x: f64) -> f64 {
7576
let x1p54 = f64::from_bits(0x4350000000000000); // 0x1p54 === 2 ^ 54

src/math/log10.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const LG5: f64 = 1.818357216161805012e-01; /* 3FC74664 96CB03DE */
3131
const LG6: f64 = 1.531383769920937332e-01; /* 3FC39A09 D078C69F */
3232
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
3333

34+
/// The base 10 logarithm of `x` (f64).
3435
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
3536
pub fn log10(mut x: f64) -> f64 {
3637
let x1p54 = f64::from_bits(0x4350000000000000); // 0x1p54 === 2 ^ 54

0 commit comments

Comments
 (0)