Skip to content

Commit edf247c

Browse files
add license and other comments to existing files
1 parent f6b3ecc commit edf247c

File tree

9 files changed

+206
-0
lines changed

9 files changed

+206
-0
lines changed

src/math/expf.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/* origin: FreeBSD /usr/src/lib/msun/src/e_expf.c */
2+
/*
3+
* Conversion to float by Ian Lance Taylor, Cygnus Support, [email protected].
4+
*/
5+
/*
6+
* ====================================================
7+
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8+
*
9+
* Developed at SunPro, a Sun Microsystems, Inc. business.
10+
* Permission to use, copy, modify, and distribute this
11+
* software is freely granted, provided that this notice
12+
* is preserved.
13+
* ====================================================
14+
*/
15+
116
use super::scalbnf;
217

318
const HALF: [f32; 2] = [0.5, -0.5];

src/math/log10.rs

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/* origin: FreeBSD /usr/src/lib/msun/src/e_log10.c */
2+
/*
3+
* ====================================================
4+
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5+
*
6+
* Developed at SunSoft, a Sun Microsystems, Inc. business.
7+
* Permission to use, copy, modify, and distribute this
8+
* software is freely granted, provided that this notice
9+
* is preserved.
10+
* ====================================================
11+
*/
12+
/*
13+
* Return the base 10 logarithm of x. See log.c for most comments.
14+
*
15+
* Reduce x to 2^k (1+f) and calculate r = log(1+f) - f + f*f/2
16+
* as in log.c, then combine and scale in extra precision:
17+
* log10(x) = (f - f*f/2 + r)/log(10) + k*log10(2)
18+
*/
19+
120
use core::f64;
221

322
const IVLN10HI: f64 = 4.34294481878168880939e-01; /* 0x3fdbcb7b, 0x15200000 */

src/math/log10f.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/* origin: FreeBSD /usr/src/lib/msun/src/e_log10f.c */
2+
/*
3+
* ====================================================
4+
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5+
*
6+
* Developed at SunPro, a Sun Microsystems, Inc. business.
7+
* Permission to use, copy, modify, and distribute this
8+
* software is freely granted, provided that this notice
9+
* is preserved.
10+
* ====================================================
11+
*/
12+
/*
13+
* See comments in log10.c.
14+
*/
15+
116
use core::f32;
217

318
const IVLN10HI: f32 = 4.3432617188e-01; /* 0x3ede6000 */

src/math/log2.rs

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/* origin: FreeBSD /usr/src/lib/msun/src/e_log2.c */
2+
/*
3+
* ====================================================
4+
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5+
*
6+
* Developed at SunSoft, a Sun Microsystems, Inc. business.
7+
* Permission to use, copy, modify, and distribute this
8+
* software is freely granted, provided that this notice
9+
* is preserved.
10+
* ====================================================
11+
*/
12+
/*
13+
* Return the base 2 logarithm of x. See log.c for most comments.
14+
*
15+
* Reduce x to 2^k (1+f) and calculate r = log(1+f) - f + f*f/2
16+
* as in log.c, then combine and scale in extra precision:
17+
* log2(x) = (f - f*f/2 + r)/log(2) + k
18+
*/
19+
120
use core::f64;
221

322
const IVLN2HI: f64 = 1.44269504072144627571e+00; /* 0x3ff71547, 0x65200000 */

src/math/log2f.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/* origin: FreeBSD /usr/src/lib/msun/src/e_log2f.c */
2+
/*
3+
* ====================================================
4+
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5+
*
6+
* Developed at SunPro, a Sun Microsystems, Inc. business.
7+
* Permission to use, copy, modify, and distribute this
8+
* software is freely granted, provided that this notice
9+
* is preserved.
10+
* ====================================================
11+
*/
12+
/*
13+
* See comments in log2.c.
14+
*/
15+
116
use core::f32;
217

318
const IVLN2HI: f32 = 1.4428710938e+00; /* 0x3fb8b000 */

src/math/logf.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/* origin: FreeBSD /usr/src/lib/msun/src/e_logf.c */
2+
/*
3+
* Conversion to float by Ian Lance Taylor, Cygnus Support, [email protected].
4+
*/
5+
/*
6+
* ====================================================
7+
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8+
*
9+
* Developed at SunPro, a Sun Microsystems, Inc. business.
10+
* Permission to use, copy, modify, and distribute this
11+
* software is freely granted, provided that this notice
12+
* is preserved.
13+
* ====================================================
14+
*/
15+
116
const LN2_HI: f32 = 6.9313812256e-01; /* 0x3f317180 */
217
const LN2_LO: f32 = 9.0580006145e-06; /* 0x3717f7d1 */
318
/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */

src/math/powf.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/* origin: FreeBSD /usr/src/lib/msun/src/e_powf.c */
2+
/*
3+
* Conversion to float by Ian Lance Taylor, Cygnus Support, [email protected].
4+
*/
5+
/*
6+
* ====================================================
7+
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8+
*
9+
* Developed at SunPro, a Sun Microsystems, Inc. business.
10+
* Permission to use, copy, modify, and distribute this
11+
* software is freely granted, provided that this notice
12+
* is preserved.
13+
* ====================================================
14+
*/
15+
116
use super::{fabsf, scalbnf, sqrtf};
217

318
const BP: [f32; 2] = [1.0, 1.5];

src/math/sqrt.rs

+78
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,81 @@
1+
/* origin: FreeBSD /usr/src/lib/msun/src/e_sqrt.c */
2+
/*
3+
* ====================================================
4+
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5+
*
6+
* Developed at SunSoft, a Sun Microsystems, Inc. business.
7+
* Permission to use, copy, modify, and distribute this
8+
* software is freely granted, provided that this notice
9+
* is preserved.
10+
* ====================================================
11+
*/
12+
/* sqrt(x)
13+
* Return correctly rounded sqrt.
14+
* ------------------------------------------
15+
* | Use the hardware sqrt if you have one |
16+
* ------------------------------------------
17+
* Method:
18+
* Bit by bit method using integer arithmetic. (Slow, but portable)
19+
* 1. Normalization
20+
* Scale x to y in [1,4) with even powers of 2:
21+
* find an integer k such that 1 <= (y=x*2^(2k)) < 4, then
22+
* sqrt(x) = 2^k * sqrt(y)
23+
* 2. Bit by bit computation
24+
* Let q = sqrt(y) truncated to i bit after binary point (q = 1),
25+
* i 0
26+
* i+1 2
27+
* s = 2*q , and y = 2 * ( y - q ). (1)
28+
* i i i i
29+
*
30+
* To compute q from q , one checks whether
31+
* i+1 i
32+
*
33+
* -(i+1) 2
34+
* (q + 2 ) <= y. (2)
35+
* i
36+
* -(i+1)
37+
* If (2) is false, then q = q ; otherwise q = q + 2 .
38+
* i+1 i i+1 i
39+
*
40+
* With some algebric manipulation, it is not difficult to see
41+
* that (2) is equivalent to
42+
* -(i+1)
43+
* s + 2 <= y (3)
44+
* i i
45+
*
46+
* The advantage of (3) is that s and y can be computed by
47+
* i i
48+
* the following recurrence formula:
49+
* if (3) is false
50+
*
51+
* s = s , y = y ; (4)
52+
* i+1 i i+1 i
53+
*
54+
* otherwise,
55+
* -i -(i+1)
56+
* s = s + 2 , y = y - s - 2 (5)
57+
* i+1 i i+1 i i
58+
*
59+
* One may easily use induction to prove (4) and (5).
60+
* Note. Since the left hand side of (3) contain only i+2 bits,
61+
* it does not necessary to do a full (53-bit) comparison
62+
* in (3).
63+
* 3. Final rounding
64+
* After generating the 53 bits result, we compute one more bit.
65+
* Together with the remainder, we can decide whether the
66+
* result is exact, bigger than 1/2ulp, or less than 1/2ulp
67+
* (it will never equal to 1/2ulp).
68+
* The rounding mode can be detected by checking whether
69+
* huge + tiny is equal to huge, and whether huge - tiny is
70+
* equal to huge for some floating point number "huge" and "tiny".
71+
*
72+
* Special cases:
73+
* sqrt(+-0) = +-0 ... exact
74+
* sqrt(inf) = inf
75+
* sqrt(-ve) = NaN ... with invalid signal
76+
* sqrt(NaN) = NaN ... with invalid signal for signaling NaN
77+
*/
78+
179
use core::f64;
280

381
const TINY: f64 = 1.0e-300;

src/math/sqrtf.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/* origin: FreeBSD /usr/src/lib/msun/src/e_sqrtf.c */
2+
/*
3+
* Conversion to float by Ian Lance Taylor, Cygnus Support, [email protected].
4+
*/
5+
/*
6+
* ====================================================
7+
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8+
*
9+
* Developed at SunPro, a Sun Microsystems, Inc. business.
10+
* Permission to use, copy, modify, and distribute this
11+
* software is freely granted, provided that this notice
12+
* is preserved.
13+
* ====================================================
14+
*/
15+
116
const TINY: f32 = 1.0e-30;
217

318
#[inline]

0 commit comments

Comments
 (0)