nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
conversion.hpp
Go to the documentation of this file.
1
3// toolboxes/control/include/nk/control/conversion/conversion.hpp
4//
5// Inter-form converters between tf / zpk / ss representations. These
6// are the matrix forms that operate directly on the coefficient
7// arrays (so a script can use them either with raw num/den/A/B/C/D
8// or with struct-tagged tf/zpk/ss values).
9
10#pragma once
11
12#include <memory_resource>
13#include <nk/value/value.hpp>
14#include <utility>
15
16namespace nk::control {
17
20
21
28
32struct StateSpace {
33 Value A;
34 Value B;
35 Value C;
36 Value D;
37};
38
56Tf2ZpResult tf2zp(const Value &num, const Value &den,
57 std::pmr::memory_resource *mr = nullptr);
58
72std::pair<Value, Value>
73zp2tf(const Value &z, const Value &p, const Value &k,
74 std::pmr::memory_resource *mr = nullptr);
75
99StateSpace tf2ss(const Value &num, const Value &den,
100 std::pmr::memory_resource *mr = nullptr);
101
125std::pair<Value, Value>
126ss2tf(const Value &A, const Value &B,
127 const Value &C, const Value &D, int iu,
128 std::pmr::memory_resource *mr = nullptr);
129
148Value minreal(const Value &sys, double tol = 0.0,
149 std::pmr::memory_resource *mr = nullptr);
150
151
153} // namespace nk::control
Core MATLAB-compatible multidimensional array and scalar value type.
Definition value.hpp:61
Tf2ZpResult tf2zp(const Value &num, const Value &den, std::pmr::memory_resource *mr=nullptr)
Convert tf coefficients to zero-pole-gain form.
Value minreal(const Value &sys, double tol=0.0, std::pmr::memory_resource *mr=nullptr)
Minimal realization — cancel pole/zero pairs (sysr = minreal(sys, tol)).
std::pair< Value, Value > ss2tf(const Value &A, const Value &B, const Value &C, const Value &D, int iu, std::pmr::memory_resource *mr=nullptr)
Convert state-space to tf coefficients.
StateSpace tf2ss(const Value &num, const Value &den, std::pmr::memory_resource *mr=nullptr)
Convert tf coefficients to controllable canonical state-space.
std::pair< Value, Value > zp2tf(const Value &z, const Value &p, const Value &k, std::pmr::memory_resource *mr=nullptr)
Convert zero-pole-gain form to tf coefficients.
State-space realisation (A, B, C, D), the result of tf2ss.
Result of tf2zp — zeros, poles, and gain from tf coefficients.
Value k
Gain (scalar = num[0] / den[0] after stripping leading zeros).
Value p
Poles (column vector, complex if needed).
Value z
Zeros (column vector, complex if needed).