1#![cfg(any(feature = "std", feature = "libm"))]
2
3use core::ops::Neg;
4
5use crate::{Float, Num, NumCast};
6
7pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
18 fn min_value() -> Self;
29
30 fn min_positive_value() -> Self;
41
42 fn epsilon() -> Self;
58
59 fn max_value() -> Self;
69
70 fn floor(self) -> Self;
82
83 fn ceil(self) -> Self;
95
96 fn round(self) -> Self;
109
110 fn trunc(self) -> Self;
122
123 fn fract(self) -> Self;
137
138 fn abs(self) -> Self;
157
158 fn signum(self) -> Self;
176
177 fn is_sign_positive(self) -> bool;
194
195 fn is_sign_negative(self) -> bool;
212
213 fn mul_add(self, a: Self, b: Self) -> Self;
232
233 fn recip(self) -> Self;
244
245 fn powi(self, n: i32) -> Self;
258
259 fn powf(self, n: Self) -> Self;
270
271 fn sqrt(self) -> Self;
291
292 fn exp(self) -> Self;
307
308 fn exp2(self) -> Self;
321
322 fn ln(self) -> Self;
341
342 fn log(self, base: Self) -> Self;
364
365 fn log2(self) -> Self;
382
383 fn log10(self) -> Self;
401
402 fn to_degrees(self) -> Self;
414
415 fn to_radians(self) -> Self;
427
428 fn max(self, other: Self) -> Self;
439
440 fn min(self, other: Self) -> Self;
451
452 fn abs_sub(self, other: Self) -> Self;
470
471 fn cbrt(self) -> Self;
484
485 fn hypot(self, other: Self) -> Self;
500
501 fn sin(self) -> Self;
514
515 fn cos(self) -> Self;
528
529 fn tan(self) -> Self;
541
542 fn asin(self) -> Self;
563
564 fn acos(self) -> Self;
585
586 fn atan(self) -> Self;
600
601 fn atan2(self, other: Self) -> Self;
629
630 fn sin_cos(self) -> (Self, Self);
647
648 fn exp_m1(self) -> Self;
662
663 fn ln_1p(self) -> Self;
683
684 fn sinh(self) -> Self;
701
702 fn cosh(self) -> Self;
719
720 fn tanh(self) -> Self;
737
738 fn asinh(self) -> Self;
751
752 fn acosh(self) -> Self;
765
766 fn atanh(self) -> Self;
780}
781
782impl<T: Float> Real for T {
783 forward! {
784 Float::min_value() -> Self;
785 Float::min_positive_value() -> Self;
786 Float::epsilon() -> Self;
787 Float::max_value() -> Self;
788 }
789 forward! {
790 Float::floor(self) -> Self;
791 Float::ceil(self) -> Self;
792 Float::round(self) -> Self;
793 Float::trunc(self) -> Self;
794 Float::fract(self) -> Self;
795 Float::abs(self) -> Self;
796 Float::signum(self) -> Self;
797 Float::is_sign_positive(self) -> bool;
798 Float::is_sign_negative(self) -> bool;
799 Float::mul_add(self, a: Self, b: Self) -> Self;
800 Float::recip(self) -> Self;
801 Float::powi(self, n: i32) -> Self;
802 Float::powf(self, n: Self) -> Self;
803 Float::sqrt(self) -> Self;
804 Float::exp(self) -> Self;
805 Float::exp2(self) -> Self;
806 Float::ln(self) -> Self;
807 Float::log(self, base: Self) -> Self;
808 Float::log2(self) -> Self;
809 Float::log10(self) -> Self;
810 Float::to_degrees(self) -> Self;
811 Float::to_radians(self) -> Self;
812 Float::max(self, other: Self) -> Self;
813 Float::min(self, other: Self) -> Self;
814 Float::abs_sub(self, other: Self) -> Self;
815 Float::cbrt(self) -> Self;
816 Float::hypot(self, other: Self) -> Self;
817 Float::sin(self) -> Self;
818 Float::cos(self) -> Self;
819 Float::tan(self) -> Self;
820 Float::asin(self) -> Self;
821 Float::acos(self) -> Self;
822 Float::atan(self) -> Self;
823 Float::atan2(self, other: Self) -> Self;
824 Float::sin_cos(self) -> (Self, Self);
825 Float::exp_m1(self) -> Self;
826 Float::ln_1p(self) -> Self;
827 Float::sinh(self) -> Self;
828 Float::cosh(self) -> Self;
829 Float::tanh(self) -> Self;
830 Float::asinh(self) -> Self;
831 Float::acosh(self) -> Self;
832 Float::atanh(self) -> Self;
833 }
834}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4