MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / normalizeRational

Function normalizeRational

SLiCAP/SLiCAPmath.py:296–330  ·  view source on GitHub ↗

Normalizes a rational expression to: .. math:: F(s) = gain\\,s^{\\ell} \\frac{1+b_1s + ... + b_ms^m}{1+a_1s + ... + a_ns^n} :param Rational: Rational function of the variable. :type Rational: sympy.Expr :param var: Variable of the rational function :type var: sy

(rational, var=ini.laplace, method='lowest')

Source from the content-addressed store, hash-verified

294 return (gain, numCoeffs, denCoeffs)
295
296def normalizeRational(rational, var=ini.laplace, method='lowest'):
297 """
298 Normalizes a rational expression to:
299
300 .. math::
301
302 F(s) = gain\\,s^{\\ell} \\frac{1+b_1s + ... + b_ms^m}{1+a_1s + ... + a_ns^n}
303
304 :param Rational: Rational function of the variable.
305 :type Rational: sympy.Expr
306
307 :param var: Variable of the rational function
308 :type var: sympy.Symbol
309
310 :param method: Normalization method:
311
312 - "highest": the coefficients of the highest order of
313 <variable> of the denominator will be noramalized to unity.
314 - "lowest": the coefficients of the lowest order of
315 <variable> of the denominator will be noramalized to unity.
316
317 :type method: str
318
319 :return: Normalized rational function of the variable.
320 :rtype: sympy.Expr
321 """
322 gain, numCoeffs, denCoeffs = coeffsTransfer(
323 rational, var=var, method=method)
324 if len(numCoeffs) and len(denCoeffs):
325 numCoeffs = list(reversed(numCoeffs))
326 denCoeffs = list(reversed(denCoeffs))
327 num = sp.Poly(numCoeffs, var).as_expr()
328 den = sp.Poly(denCoeffs, var).as_expr()
329 rational = gain*num/den
330 return rational
331
332def _cancelPZ(poles, zeros):
333 """

Callers 9

_getValuesFunction · 0.90
_doPyLaplaceFunction · 0.90
phaseMarginFunction · 0.85
_makeNumDataFunction · 0.85
_magFunc_fFunction · 0.85
_dB_magFunc_fFunction · 0.85
_phaseFunc_fFunction · 0.85
_delayFunc_fFunction · 0.85
filterFuncFunction · 0.85

Calls 1

coeffsTransferFunction · 0.85

Tested by

no test coverage detected