#[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 PolynomialCurveFit {
#[builder(custom(type = super::CurveFitVariable, convert = Box::new))]
#[serde(rename = "independentVariable")]
independent_variable: Box<super::CurveFitVariable>,
#[builder(custom(type = super::IntegerConstant, convert = Box::new))]
#[serde(rename = "degree")]
degree: Box<super::IntegerConstant>,
#[builder(
default,
custom(
type = impl
Into<Option<super::DoubleConstant>>,
convert = |v|v.into().map(Box::new)
)
)]
#[serde(rename = "intercept", skip_serializing_if = "Option::is_none", default)]
intercept: Option<Box<super::DoubleConstant>>,
}
impl PolynomialCurveFit {
#[inline]
pub fn new(
independent_variable: super::CurveFitVariable,
degree: super::IntegerConstant,
) -> Self {
Self::builder().independent_variable(independent_variable).degree(degree).build()
}
#[inline]
pub fn independent_variable(&self) -> &super::CurveFitVariable {
&*self.independent_variable
}
#[inline]
pub fn degree(&self) -> &super::IntegerConstant {
&*self.degree
}
#[inline]
pub fn intercept(&self) -> Option<&super::DoubleConstant> {
self.intercept.as_ref().map(|o| &**o)
}
}