Struct automatica::rational_function::Rf
source · pub struct Rf<T> { /* private fields */ }
Expand description
Rational function
Implementations§
source§impl<T> Rf<T>where
T: Clone + PartialEq + Zero,
impl<T> Rf<T>where T: Clone + PartialEq + Zero,
sourcepub fn num(&self) -> impl Polynomial<T>
pub fn num(&self) -> impl Polynomial<T>
Extract rational function numerator
Example
use automatica::{Polynomial, Rf};
let num = [1., 2.];
let rf = Rf::new(num.clone(), [-4., 6., -2.]);
assert_eq!(num, rf.num().as_slice());
sourcepub fn den(&self) -> impl Polynomial<T>
pub fn den(&self) -> impl Polynomial<T>
Extract rational function denominator
Example
use automatica::{Polynomial, Rf};
let den = [-4., 6., -2.];
let rf = Rf::new([1., 2.], den.clone());
assert_eq!(den, rf.den().as_slice());
source§impl<T: Clone + PartialEq + Zero> Rf<T>
impl<T: Clone + PartialEq + Zero> Rf<T>
sourcepub fn relative_degree(&self) -> i32
pub fn relative_degree(&self) -> i32
Calculate the relative degree between denominator and numerator.
Example
use automatica::{Inv, Rf};
let rf = Rf::new([1., 2.], [-4., 6., -2.]);
let expected = rf.relative_degree();
assert_eq!(expected, 1);
assert_eq!(rf.inv().relative_degree(), -1);
source§impl<T> Rf<T>where
T: Abs + Add<Output = T> + Clone + Copy + Div<Output = T> + EigenConst + Epsilon + Hypot + Inv<Output = T> + Max + Mul<Output = T> + Neg<Output = T> + One + PartialOrd + Pow<T> + Sign + Sqrt + Sub<Output = T> + Zero,
impl<T> Rf<T>where T: Abs + Add<Output = T> + Clone + Copy + Div<Output = T> + EigenConst + Epsilon + Hypot + Inv<Output = T> + Max + Mul<Output = T> + Neg<Output = T> + One + PartialOrd + Pow<T> + Sign + Sqrt + Sub<Output = T> + Zero,
sourcepub fn real_poles(&self) -> Option<Vec<T>>
pub fn real_poles(&self) -> Option<Vec<T>>
Calculate the poles of the rational function
sourcepub fn complex_poles(&self) -> Vec<(T, T)>
pub fn complex_poles(&self) -> Vec<(T, T)>
Calculate the poles of the rational function
sourcepub fn real_zeros(&self) -> Option<Vec<T>>
pub fn real_zeros(&self) -> Option<Vec<T>>
Calculate the zeros of the rational function
sourcepub fn complex_zeros(&self) -> Vec<(T, T)>
pub fn complex_zeros(&self) -> Vec<(T, T)>
Calculate the zeros of the rational function
source§impl<T> Rf<T>where
T: Clone + Div<Output = T> + One + PartialEq + Zero,
impl<T> Rf<T>where T: Clone + Div<Output = T> + One + PartialEq + Zero,
sourcepub fn normalize(&self) -> Self
pub fn normalize(&self) -> Self
Normalization of rational function. If the denominator is zero the same rational function is returned.
from:
b_n*z^n + b_(n-1)*z^(n-1) + ... + b_1*z + b_0
G(z) = ---------------------------------------------
a_n*z^n + a_(n-1)*z^(n-1) + ... + a_1*z + a_0
to:
b'_n*z^n + b'_(n-1)*z^(n-1) + ... + b'_1*z + b'_0
G(z) = -------------------------------------------------
z^n + a'_(n-1)*z^(n-1) + ... + a'_1*z + a'_0
Example
use automatica::Rf;
let rf = Rf::new([1., 2.], [-4., 6., -2.]);
let expected = Rf::new([-0.5, -1.], [2., -3., 1.]);
assert_eq!(expected, rf.normalize());
sourcepub fn normalize_mut(&mut self)
pub fn normalize_mut(&mut self)
In place normalization of rational function. If the denominator is zero no operation is done.
from:
b_n*z^n + b_(n-1)*z^(n-1) + ... + b_1*z + b_0
G(z) = ---------------------------------------------
a_n*z^n + a_(n-1)*z^(n-1) + ... + a_1*z + a_0
to:
b'_n*z^n + b'_(n-1)*z^(n-1) + ... + b'_1*z + b'_0
G(z) = -------------------------------------------------
z^n + a'_(n-1)*z^(n-1) + ... + a'_1*z + a'_0
Example
use automatica::Rf;
let mut rf = Rf::new([1., 2.], [-4., 6., -2.]);
rf.normalize_mut();
let expected = Rf::new([-0.5, -1.], [2., -3., 1.]);
assert_eq!(expected, rf);
source§impl<T> Rf<T>where
T: Clone + PartialEq,
impl<T> Rf<T>where T: Clone + PartialEq,
Trait Implementations§
source§impl<T> Add<&Rf<T>> for &Rf<T>where
T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
impl<T> Add<&Rf<T>> for &Rf<T>where T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
Implementation of rational function addition
source§impl<T> Add<&T> for Rf<T>where
T: Add<Output = T> + Clone + Mul<Output = T> + PartialEq + Zero,
impl<T> Add<&T> for Rf<T>where T: Add<Output = T> + Clone + Mul<Output = T> + PartialEq + Zero,
Implementation of rational function addition
source§impl<T> Add<Rf<T>> for Rf<T>where
T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
impl<T> Add<Rf<T>> for Rf<T>where T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
Implementation of rational function addition
source§impl<T> Add<T> for Rf<T>where
T: Add<Output = T> + Clone + Mul<Output = T> + PartialEq + Zero,
impl<T> Add<T> for Rf<T>where T: Add<Output = T> + Clone + Mul<Output = T> + PartialEq + Zero,
Implementation of rational function addition
source§impl<T> Display for Rf<T>where
T: Clone + Display + One + PartialEq + PartialOrd + Zero,
impl<T> Display for Rf<T>where T: Clone + Display + One + PartialEq + PartialOrd + Zero,
Implementation of rational function printing
source§impl<T> Div<&Rf<T>> for &Rf<T>where
T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
impl<T> Div<&Rf<T>> for &Rf<T>where T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
Implementation of rational function division
source§impl<T> Div<Rf<T>> for Rf<T>where
T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
impl<T> Div<Rf<T>> for Rf<T>where T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
Implementation of rational function division
source§impl<T> Mul<&Rf<T>> for &Rf<T>where
T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
impl<T> Mul<&Rf<T>> for &Rf<T>where T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
Implementation of rational function multiplication
source§impl<T> Mul<&Rf<T>> for Rf<T>where
T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
impl<T> Mul<&Rf<T>> for Rf<T>where T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
Implementation of rational function multiplication
source§impl<T> Mul<Rf<T>> for Rf<T>where
T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
impl<T> Mul<Rf<T>> for Rf<T>where T: Add<Output = T> + Clone + Mul<Output = T> + One + PartialEq + Zero,
Implementation of rational function multiplication
source§impl<T> Neg for &Rf<T>where
T: Clone + Neg<Output = T> + PartialEq + Zero,
impl<T> Neg for &Rf<T>where T: Clone + Neg<Output = T> + PartialEq + Zero,
Implementation of rational function negation. Negative sign is transferred to the numerator.
source§impl<T> Neg for Rf<T>where
T: Clone + Neg<Output = T> + PartialEq,
impl<T> Neg for Rf<T>where T: Clone + Neg<Output = T> + PartialEq,
Implementation of rational function negation. Negative sign is transferred to the numerator.
source§impl<T: PartialEq> PartialEq<Rf<T>> for Rf<T>
impl<T: PartialEq> PartialEq<Rf<T>> for Rf<T>
source§impl<T> Sub<&Rf<T>> for &Rf<T>where
T: Add<Output = T> + Clone + Mul<Output = T> + Neg<Output = T> + PartialEq + Sub<Output = T> + Zero + One,
impl<T> Sub<&Rf<T>> for &Rf<T>where T: Add<Output = T> + Clone + Mul<Output = T> + Neg<Output = T> + PartialEq + Sub<Output = T> + Zero + One,
Implementation of rational function subtraction
source§impl<T> Sub<Rf<T>> for Rf<T>where
T: Add<Output = T> + Clone + Mul<Output = T> + Neg<Output = T> + One + PartialEq + Sub<Output = T> + Zero,
impl<T> Sub<Rf<T>> for Rf<T>where T: Add<Output = T> + Clone + Mul<Output = T> + Neg<Output = T> + One + PartialEq + Sub<Output = T> + Zero,
Implementation of rational function subtraction