concision_core/ops/fft/cmp/
direction.rs1use scsys::VariantConstructors;
6use strum::{
7 AsRefStr, Display, EnumCount, EnumIs, EnumIter, EnumString, VariantArray, VariantNames,
8};
9
10#[derive(
12 AsRefStr,
13 Clone,
14 Copy,
15 Debug,
16 Default,
17 Display,
18 EnumCount,
19 EnumIs,
20 EnumIter,
21 EnumString,
22 Eq,
23 Hash,
24 Ord,
25 PartialEq,
26 PartialOrd,
27 VariantArray,
28 VariantNames,
29)]
30#[cfg_attr(
31 feature = "serde",
32 derive(serde::Deserialize, serde::Serialize),
33 serde(rename_all = "lowercase", untagged)
34)]
35#[repr(usize)]
36#[strum(serialize_all = "lowercase")]
37pub enum FftDirection {
38 #[default]
39 Forward = 0,
40 Inverse = 1,
41}
42
43impl FftDirection {
44 pub fn forward() -> Self {
45 Self::Forward
46 }
47
48 pub fn inverse() -> Self {
49 Self::Inverse
50 }
51}
52
53impl From<usize> for FftDirection {
54 fn from(direction: usize) -> Self {
55 match direction % Self::COUNT {
56 0 => Self::Forward,
57 _ => Self::Inverse,
58 }
59 }
60}
61impl From<FftDirection> for usize {
62 fn from(direction: FftDirection) -> Self {
63 direction as usize
64 }
65}
66
67#[derive(
69 AsRefStr,
70 Clone,
71 Copy,
72 Debug,
73 Default,
74 Display,
75 EnumCount,
76 EnumIs,
77 EnumIter,
78 EnumString,
79 Eq,
80 Hash,
81 Ord,
82 PartialEq,
83 PartialOrd,
84 VariantArray,
85 VariantConstructors,
86 VariantNames,
87)]
88#[cfg_attr(
89 feature = "serde",
90 derive(serde::Deserialize, serde::Serialize),
91 serde(rename_all = "lowercase", untagged)
92)]
93#[repr(usize)]
94#[strum(serialize_all = "lowercase")]
95pub enum FftMode {
96 #[default]
97 Complex,
98 Real,
99}