1quantity! {
4 quantity: Frequency; "frequency";
6 dimension: ISQ<
8 Z0, Z0, N1, Z0, Z0, Z0, Z0>; units {
16 @yottahertz: prefix!(yotta); "YHz", "yottahertz", "yottahertz";
17 @zettahertz: prefix!(zetta); "ZHz", "zettahertz", "zettahertz";
18 @exahertz: prefix!(exa); "EHz", "exahertz", "exahertz";
19 @petahertz: prefix!(peta); "PHz", "petahertz", "petahertz";
20 @terahertz: prefix!(tera); "THz", "terahertz", "terahertz";
21 @gigahertz: prefix!(giga); "GHz", "gigahertz", "gigahertz";
22 @megahertz: prefix!(mega); "MHz", "megahertz", "megahertz";
23 @kilohertz: prefix!(kilo); "kHz", "kilohertz", "kilohertz";
24 @hectohertz: prefix!(hecto); "hHz", "hectohertz", "hectohertz";
25 @decahertz: prefix!(deca); "daHz", "decahertz", "decahertz";
26 @hertz: prefix!(none); "Hz", "hertz", "hertz";
28 @decihertz: prefix!(deci); "dHz", "decihertz", "decihertz";
29 @centihertz: prefix!(centi); "cHz", "centihertz", "centihertz";
30 @millihertz: prefix!(milli); "mHz", "millihertz", "millihertz";
31 @microhertz: prefix!(micro); "µHz", "microhertz", "microhertz";
32 @nanohertz: prefix!(nano); "nHz", "nanohertz", "nanohertz";
33 @picohertz: prefix!(pico); "pHz", "picohertz", "picohertz";
34 @femtohertz: prefix!(femto); "fHz", "femtohertz", "femtohertz";
35 @attohertz: prefix!(atto); "aHz", "attohertz", "attohertz";
36 @zeptohertz: prefix!(zepto); "zHz", "zeptohertz", "zeptohertz";
37 @yoctohertz: prefix!(yocto); "yHz", "yoctohertz", "yoctohertz";
38
39 @cycle_per_day: 1.157_407_407_407_407_4_E-5; "1/d", "cycle per day", "cycles per day";
40 @cycle_per_hour: 2.777_777_777_777_777_E-4; "1/h", "cycle per hour", "cycles per hour";
41 @cycle_per_minute: 1.666_666_666_666_666_6E-2; "1/min", "cycle per minute", "cycles per minute";
42 @cycle_per_shake: 1.0_E8; "100 MHz", "cycle per shake", "cycles per shake";
43 @cycle_per_year: 3.170_979_198_376_458_E-8; "1/a", "cycle per year", "cycles per year";
44 }
45}
46
47#[cfg(test)]
48mod tests {
49 storage_types! {
50 use crate::num::One;
51 use crate::si::frequency as f;
52 use crate::si::quantities::*;
53 use crate::si::time as t;
54 use crate::tests::Test;
55
56 #[test]
57 fn check_dimension() {
58 let _: Time<V> = V::one() / Frequency::new::<f::hertz>(V::one());
59 let _: Frequency<V> = V::one() / Time::new::<t::second>(V::one());
60 }
61
62 #[test]
63 fn check_units() {
64 test::<t::yottasecond, f::yoctohertz>();
65 test::<t::zettasecond, f::zeptohertz>();
66 test::<t::exasecond, f::attohertz>();
67 test::<t::petasecond, f::femtohertz>();
68 test::<t::terasecond, f::picohertz>();
69 test::<t::gigasecond, f::nanohertz>();
70 test::<t::megasecond, f::microhertz>();
71 test::<t::kilosecond, f::millihertz>();
72 test::<t::hectosecond, f::centihertz>();
73 test::<t::decasecond, f::decihertz>();
74 test::<t::second, f::hertz>();
75 test::<t::decisecond, f::decahertz>();
76 test::<t::centisecond, f::hectohertz>();
77 test::<t::millisecond, f::kilohertz>();
78 test::<t::microsecond, f::megahertz>();
79 test::<t::nanosecond, f::gigahertz>();
80 test::<t::picosecond, f::terahertz>();
81 test::<t::femtosecond, f::petahertz>();
82 test::<t::attosecond, f::exahertz>();
83 test::<t::zeptosecond, f::zettahertz>();
84 test::<t::yoctosecond, f::yottahertz>();
85 test::<t::day, f::cycle_per_day>();
86 test::<t::hour, f::cycle_per_hour>();
87 test::<t::minute, f::cycle_per_minute>();
88 test::<t::shake, f::cycle_per_shake>();
89 test::<t::year, f::cycle_per_year>();
90
91 fn test<T: t::Conversion<V>, F: f::Conversion<V>>() {
92 if T::is_valid() {
93 Test::assert_approx_eq(&(V::one() / Time::new::<T>(V::one())),
94 &Frequency::new::<F>(V::one()));
95 }
96
97 if F::is_valid() {
98 Test::assert_approx_eq(&Time::new::<T>(V::one()),
99 &(V::one() / Frequency::new::<F>(V::one())));
100 } }
101 }
102 }
103}