1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
use super::vector_types::*;

/// Marker for types containing real data.
#[derive(Debug, Clone, PartialEq)]
pub struct Real;
impl NumberSpace for Real {
    fn is_complex(&self) -> bool {
        false
    }
    fn to_complex(&mut self) {}
    fn to_real(&mut self) {}
}
impl RealNumberSpace for Real {}

/// Marker for types containing complex data.
#[derive(Debug, Clone, PartialEq)]
pub struct Complex;
impl NumberSpace for Complex {
    fn is_complex(&self) -> bool {
        true
    }
    fn to_complex(&mut self) {}
    fn to_real(&mut self) {}
}
impl ComplexNumberSpace for Complex {}

/// Marker for types containing real or complex data.
#[derive(Debug, Clone, PartialEq)]
pub struct RealOrComplex {
    pub is_complex_current: bool,
}
impl NumberSpace for RealOrComplex {
    fn is_complex(&self) -> bool {
        self.is_complex_current
    }

    fn to_complex(&mut self) {
        self.is_complex_current = true;
    }

    fn to_real(&mut self) {
        self.is_complex_current = false;
    }
}
impl RealNumberSpace for RealOrComplex {}
impl ComplexNumberSpace for RealOrComplex {}

/// Marker for types containing time data.
#[derive(Debug, Clone, PartialEq)]
pub struct Time;
impl Domain for Time {
    fn domain(&self) -> DataDomain {
        DataDomain::Time
    }
    fn to_freq(&mut self) {}
    fn to_time(&mut self) {}
}
impl TimeDomain for Time {}

/// Marker for types containing frequency data.
#[derive(Debug, Clone, PartialEq)]
pub struct Freq;
impl Domain for Freq {
    fn domain(&self) -> DataDomain {
        DataDomain::Frequency
    }
    fn to_time(&mut self) {}
    fn to_freq(&mut self) {}
}
impl FrequencyDomain for Freq {}

/// Marker for types containing time or frequency data.
#[derive(Debug, Clone, PartialEq)]
pub struct TimeOrFreq {
    pub domain_current: DataDomain,
}
impl Domain for TimeOrFreq {
    fn domain(&self) -> DataDomain {
        self.domain_current
    }

    fn to_freq(&mut self) {
        self.domain_current = DataDomain::Frequency;
    }

    fn to_time(&mut self) {
        self.domain_current = DataDomain::Time;
    }
}

impl TimeDomain for TimeOrFreq {}
impl FrequencyDomain for TimeOrFreq {}

impl PosEq<Real> for Real {}
impl PosEq<RealOrComplex> for Real {}
impl PosEq<Real> for RealOrComplex {}
impl PosEq<Complex> for RealOrComplex {}
impl PosEq<RealOrComplex> for RealOrComplex {}
impl PosEq<Complex> for Complex {}
impl PosEq<RealOrComplex> for Complex {}

impl PosEq<Time> for Time {}
impl PosEq<TimeOrFreq> for Time {}
impl PosEq<Time> for TimeOrFreq {}
impl PosEq<Freq> for TimeOrFreq {}
impl PosEq<TimeOrFreq> for TimeOrFreq {}
impl PosEq<Freq> for Freq {}
impl PosEq<TimeOrFreq> for Freq {}