From 6449c4d7bba3f45274b78a51871f64d429d82f8b Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 12 Feb 2024 23:58:46 +0100 Subject: Make Nyquist and Bode work --- src/control.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/control.h') diff --git a/src/control.h b/src/control.h index 587b80e..61dcd0f 100644 --- a/src/control.h +++ b/src/control.h @@ -13,7 +13,8 @@ #define CT_ASSERT(x) (assert(x)) #define CT_SMALL_TOL 1e-6 -#define CT_ASSERT_SMALL(x) (assert(std::abs(x) < CT_SMALL_TOL)) +#define CT_SMALL(x) (std::abs(x) < CT_SMALL_TOL) +#define CT_ASSERT_SMALL(x) (assert(CT_SMALL)) namespace ct { @@ -98,12 +99,14 @@ namespace ct struct TransferFn { - complex gain; math::PolyCx num; math::PolyCx den; TransferFn(void); TransferFn(math::PolyCx num, math::PolyCx den); + TransferFn(const TransferFn& other) + : num(other.num) + , den(other.den) {} inline void add_pole(complex p) { den.add_root(p); } inline void add_zero(complex z) { num.add_root(z); }; @@ -114,6 +117,8 @@ namespace ct bool is_strictly_proper() const; void canonicalize(); + + TransferFn& operator = (const TransferFn& other); }; TransferFn operator + (const TransferFn& g, const TransferFn& h); @@ -125,6 +130,7 @@ namespace ct // inline TransferFn operator / (const TransferFn& + TransferFn cancel_zp(const TransferFn& tf, double tol = CT_SMALL_TOL); TransferFn feedback(const TransferFn& tf, complex k = -1); struct LocusSeries @@ -139,7 +145,7 @@ namespace ct }; void rlocus(const TransferFn& tf, LocusSeries& ls); - + void nyquist(const TransferFn& tf, LocusSeries& ls); struct SSModel { -- cgit v1.2.1