/// Returns the cross-spectral density magnitude and phase of the two input series.
#[derive(
    Debug,
    Clone,
    conjure_object::serde::Serialize,
    conjure_object::serde::Deserialize,
    conjure_object::private::DeriveWith
)]
#[serde(crate = "conjure_object::serde")]
#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct Cpsd {
    #[builder(custom(type = super::NumericSeries, convert = Box::new))]
    #[serde(rename = "x")]
    x: Box<super::NumericSeries>,
    #[builder(custom(type = super::NumericSeries, convert = Box::new))]
    #[serde(rename = "y")]
    y: Box<super::NumericSeries>,
    #[builder(
        default,
        custom(
            type = impl
            Into<Option<super::StftOptions>>,
            convert = |v|v.into().map(Box::new)
        )
    )]
    #[serde(rename = "stftOptions", skip_serializing_if = "Option::is_none", default)]
    stft_options: Option<Box<super::StftOptions>>,
    #[builder(default, into)]
    #[serde(
        rename = "magnitudeScaling",
        skip_serializing_if = "Option::is_none",
        default
    )]
    magnitude_scaling: Option<super::MagnitudeScaling>,
    #[builder(default, into)]
    #[serde(
        rename = "outputFrequencyType",
        skip_serializing_if = "Option::is_none",
        default
    )]
    output_frequency_type: Option<super::OutputFrequencyType>,
    #[builder(default, into)]
    #[serde(rename = "unwrapPhase", skip_serializing_if = "Option::is_none", default)]
    unwrap_phase: Option<bool>,
    #[builder(default, into)]
    #[serde(
        rename = "outputPhaseUnit",
        skip_serializing_if = "Option::is_none",
        default
    )]
    output_phase_unit: Option<super::OutputPhaseUnit>,
}
impl Cpsd {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(x: super::NumericSeries, y: super::NumericSeries) -> Self {
        Self::builder().x(x).y(y).build()
    }
    #[inline]
    pub fn x(&self) -> &super::NumericSeries {
        &*self.x
    }
    #[inline]
    pub fn y(&self) -> &super::NumericSeries {
        &*self.y
    }
    #[inline]
    pub fn stft_options(&self) -> Option<&super::StftOptions> {
        self.stft_options.as_ref().map(|o| &**o)
    }
    /// The scaling to apply to the output magnitude. Defaults to MAGNITUDE_DB_10 if not specified.
    #[inline]
    pub fn magnitude_scaling(&self) -> Option<&super::MagnitudeScaling> {
        self.magnitude_scaling.as_ref().map(|o| &*o)
    }
    /// The type of the output frequency. Defaults to LINEAR if not specified. Changing the output frequency type
    /// may also rescale the magnitude of the output in order to ensure the density of the output is consistent.
    #[inline]
    pub fn output_frequency_type(&self) -> Option<&super::OutputFrequencyType> {
        self.output_frequency_type.as_ref().map(|o| &*o)
    }
    /// Unwrap the phase of the output. Defaults to true if not specified.
    #[inline]
    pub fn unwrap_phase(&self) -> Option<bool> {
        self.unwrap_phase.as_ref().map(|o| *o)
    }
    /// The unit of the output phase. Defaults to RADIANS if not specified.
    #[inline]
    pub fn output_phase_unit(&self) -> Option<&super::OutputPhaseUnit> {
        self.output_phase_unit.as_ref().map(|o| &*o)
    }
}
