14
14
15
15
mod math;
16
16
17
- #[ cfg( todo) ]
18
17
use core:: { f32, f64} ;
19
18
20
19
pub use math:: * ;
21
20
22
21
/// Approximate equality with 1 ULP of tolerance
23
22
#[ doc( hidden) ]
23
+ #[ inline]
24
24
pub fn _eqf ( a : u32 , b : u32 ) -> bool {
25
25
( a as i32 ) . wrapping_sub ( b as i32 ) . abs ( ) <= 1
26
26
}
27
27
28
28
#[ doc( hidden) ]
29
+ #[ inline]
29
30
pub fn _eq ( a : u64 , b : u64 ) -> bool {
30
31
( a as i64 ) . wrapping_sub ( b as i64 ) . abs ( ) <= 1
31
32
}
32
33
33
34
/// Math support for `f32`
34
35
///
35
36
/// This trait is sealed and cannot be implemented outside of `libm`.
36
- pub trait F32Ext : private:: Sealed {
37
+ pub trait F32Ext : private:: Sealed + Sized {
37
38
fn floor ( self ) -> Self ;
38
39
39
40
fn ceil ( self ) -> Self ;
@@ -44,20 +45,17 @@ pub trait F32Ext: private::Sealed {
44
45
45
46
fn fdim ( self , rhs : Self ) -> Self ;
46
47
47
- #[ cfg( todo) ]
48
48
fn fract ( self ) -> Self ;
49
49
50
50
fn abs ( self ) -> Self ;
51
51
52
- # [ cfg ( todo ) ]
53
- fn signum ( self ) -> Self ;
52
+ // NOTE depends on unstable intrinsics::copysignf32
53
+ // fn signum(self) -> Self;
54
54
55
55
fn mul_add ( self , a : Self , b : Self ) -> Self ;
56
56
57
- #[ cfg( todo) ]
58
57
fn div_euc ( self , rhs : Self ) -> Self ;
59
58
60
- #[ cfg( todo) ]
61
59
fn mod_euc ( self , rhs : Self ) -> Self ;
62
60
63
61
// NOTE depends on unstable intrinsics::powif32
@@ -97,9 +95,11 @@ pub trait F32Ext: private::Sealed {
97
95
98
96
fn atan2 ( self , other : Self ) -> Self ;
99
97
100
- #[ cfg( todo) ]
101
98
#[ inline]
102
- fn sin_cos ( self ) -> ( Self , Self ) {
99
+ fn sin_cos ( self ) -> ( Self , Self )
100
+ where
101
+ Self : Copy ,
102
+ {
103
103
( self . sin ( ) , self . cos ( ) )
104
104
}
105
105
@@ -113,13 +113,10 @@ pub trait F32Ext: private::Sealed {
113
113
114
114
fn tanh ( self ) -> Self ;
115
115
116
- #[ cfg( todo) ]
117
116
fn asinh ( self ) -> Self ;
118
117
119
- #[ cfg( todo) ]
120
118
fn acosh ( self ) -> Self ;
121
119
122
- #[ cfg( todo) ]
123
120
fn atanh ( self ) -> Self ;
124
121
}
125
122
@@ -149,7 +146,6 @@ impl F32Ext for f32 {
149
146
fdimf ( self , rhs)
150
147
}
151
148
152
- #[ cfg( todo) ]
153
149
#[ inline]
154
150
fn fract ( self ) -> Self {
155
151
self - self . trunc ( )
@@ -165,7 +161,6 @@ impl F32Ext for f32 {
165
161
fmaf ( self , a, b)
166
162
}
167
163
168
- #[ cfg( todo) ]
169
164
#[ inline]
170
165
fn div_euc ( self , rhs : Self ) -> Self {
171
166
let q = ( self / rhs) . trunc ( ) ;
@@ -175,7 +170,6 @@ impl F32Ext for f32 {
175
170
q
176
171
}
177
172
178
- #[ cfg( todo) ]
179
173
#[ inline]
180
174
fn mod_euc ( self , rhs : f32 ) -> f32 {
181
175
let r = self % rhs;
@@ -296,7 +290,6 @@ impl F32Ext for f32 {
296
290
tanhf ( self )
297
291
}
298
292
299
- #[ cfg( todo) ]
300
293
#[ inline]
301
294
fn asinh ( self ) -> Self {
302
295
if self == f32:: NEG_INFINITY {
@@ -306,7 +299,6 @@ impl F32Ext for f32 {
306
299
}
307
300
}
308
301
309
- #[ cfg( todo) ]
310
302
#[ inline]
311
303
fn acosh ( self ) -> Self {
312
304
match self {
@@ -315,7 +307,6 @@ impl F32Ext for f32 {
315
307
}
316
308
}
317
309
318
- #[ cfg( todo) ]
319
310
#[ inline]
320
311
fn atanh ( self ) -> Self {
321
312
0.5 * ( ( 2.0 * self ) / ( 1.0 - self ) ) . ln_1p ( )
@@ -325,7 +316,7 @@ impl F32Ext for f32 {
325
316
/// Math support for `f64`
326
317
///
327
318
/// This trait is sealed and cannot be implemented outside of `libm`.
328
- pub trait F64Ext : private:: Sealed {
319
+ pub trait F64Ext : private:: Sealed + Sized {
329
320
fn floor ( self ) -> Self ;
330
321
331
322
fn ceil ( self ) -> Self ;
@@ -336,20 +327,17 @@ pub trait F64Ext: private::Sealed {
336
327
337
328
fn fdim ( self , rhs : Self ) -> Self ;
338
329
339
- #[ cfg( todo) ]
340
330
fn fract ( self ) -> Self ;
341
331
342
332
fn abs ( self ) -> Self ;
343
333
344
- # [ cfg ( todo ) ]
345
- fn signum ( self ) -> Self ;
334
+ // NOTE depends on unstable intrinsics::copysignf64
335
+ // fn signum(self) -> Self;
346
336
347
337
fn mul_add ( self , a : Self , b : Self ) -> Self ;
348
338
349
- #[ cfg( todo) ]
350
339
fn div_euc ( self , rhs : Self ) -> Self ;
351
340
352
- #[ cfg( todo) ]
353
341
fn mod_euc ( self , rhs : Self ) -> Self ;
354
342
355
343
// NOTE depends on unstable intrinsics::powif64
@@ -382,7 +370,6 @@ pub trait F64Ext: private::Sealed {
382
370
383
371
fn tan ( self ) -> Self ;
384
372
385
- #[ cfg( todo) ]
386
373
fn asin ( self ) -> Self ;
387
374
388
375
fn acos ( self ) -> Self ;
@@ -393,9 +380,11 @@ pub trait F64Ext: private::Sealed {
393
380
#[ cfg( todo) ]
394
381
fn atan2 ( self , other : Self ) -> Self ;
395
382
396
- #[ cfg( todo) ]
397
383
#[ inline]
398
- fn sin_cos ( self ) -> ( Self , Self ) {
384
+ fn sin_cos ( self ) -> ( Self , Self )
385
+ where
386
+ Self : Copy ,
387
+ {
399
388
( self . sin ( ) , self . cos ( ) )
400
389
}
401
390
@@ -410,13 +399,10 @@ pub trait F64Ext: private::Sealed {
410
399
411
400
fn tanh ( self ) -> Self ;
412
401
413
- #[ cfg( todo) ]
414
402
fn asinh ( self ) -> Self ;
415
403
416
- #[ cfg( todo) ]
417
404
fn acosh ( self ) -> Self ;
418
405
419
- #[ cfg( todo) ]
420
406
fn atanh ( self ) -> Self ;
421
407
}
422
408
@@ -445,7 +431,7 @@ impl F64Ext for f64 {
445
431
fn fdim ( self , rhs : Self ) -> Self {
446
432
fdim ( self , rhs)
447
433
}
448
- # [ cfg ( todo ) ]
434
+
449
435
#[ inline]
450
436
fn fract ( self ) -> Self {
451
437
self - self . trunc ( )
@@ -461,7 +447,6 @@ impl F64Ext for f64 {
461
447
fma ( self , a, b)
462
448
}
463
449
464
- #[ cfg( todo) ]
465
450
#[ inline]
466
451
fn div_euc ( self , rhs : Self ) -> Self {
467
452
let q = ( self / rhs) . trunc ( ) ;
@@ -471,9 +456,8 @@ impl F64Ext for f64 {
471
456
q
472
457
}
473
458
474
- #[ cfg( todo) ]
475
459
#[ inline]
476
- fn mod_euc ( self , rhs : f32 ) -> f32 {
460
+ fn mod_euc ( self , rhs : f64 ) -> f64 {
477
461
let r = self % rhs;
478
462
if r < 0.0 {
479
463
r + rhs. abs ( )
@@ -548,7 +532,6 @@ impl F64Ext for f64 {
548
532
tan ( self )
549
533
}
550
534
551
- #[ cfg( todo) ]
552
535
#[ inline]
553
536
fn asin ( self ) -> Self {
554
537
asin ( self )
@@ -597,7 +580,6 @@ impl F64Ext for f64 {
597
580
tanh ( self )
598
581
}
599
582
600
- #[ cfg( todo) ]
601
583
#[ inline]
602
584
fn asinh ( self ) -> Self {
603
585
if self == f64:: NEG_INFINITY {
@@ -607,7 +589,6 @@ impl F64Ext for f64 {
607
589
}
608
590
}
609
591
610
- #[ cfg( todo) ]
611
592
#[ inline]
612
593
fn acosh ( self ) -> Self {
613
594
match self {
@@ -616,7 +597,6 @@ impl F64Ext for f64 {
616
597
}
617
598
}
618
599
619
- #[ cfg( todo) ]
620
600
#[ inline]
621
601
fn atanh ( self ) -> Self {
622
602
0.5 * ( ( 2.0 * self ) / ( 1.0 - self ) ) . ln_1p ( )
0 commit comments