Skip to main content

nominal_api/conjure/objects/scout/compute/api/
polynomial_curve.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    conjure_object::private::DeriveWith
7)]
8#[serde(crate = "conjure_object::serde")]
9#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
10#[conjure_object::private::staged_builder::staged_builder]
11#[builder(crate = conjure_object::private::staged_builder, update, inline)]
12pub struct PolynomialCurve {
13    #[builder(custom(type = super::IntegerConstant, convert = Box::new))]
14    #[serde(rename = "degree")]
15    degree: Box<super::IntegerConstant>,
16    #[builder(
17        default,
18        custom(
19            type = impl
20            Into<Option<super::DoubleConstant>>,
21            convert = |v|v.into().map(Box::new)
22        )
23    )]
24    #[serde(rename = "intercept", skip_serializing_if = "Option::is_none", default)]
25    intercept: Option<Box<super::DoubleConstant>>,
26}
27impl PolynomialCurve {
28    /// Constructs a new instance of the type.
29    #[inline]
30    pub fn new(degree: super::IntegerConstant) -> Self {
31        Self::builder().degree(degree).build()
32    }
33    /// The highest allowable degree of the fit polynomial.
34    #[inline]
35    pub fn degree(&self) -> &super::IntegerConstant {
36        &*self.degree
37    }
38    /// The y-value at the point x (or t) = 0. If omitted, the y-intercept will also be fit to the data.
39    #[inline]
40    pub fn intercept(&self) -> Option<&super::DoubleConstant> {
41        self.intercept.as_ref().map(|o| &**o)
42    }
43}