Esempio n. 1
0
def Gain(k):
    """
    :param k: gain parameter
    :returns: ``SystemFunction`` representing a system that multiplies
     the input signal by ``k``.
    """
    return SystemFunction(poly.Polynomial([k]), poly.Polynomial([1]))
Esempio n. 2
0
def Gain(k):
    """
    @param k: gain parameter
    @returns: C{SystemFunction} representing a system that multiplies
    the input signal by C{k}.
    """
    return SystemFunction(poly.Polynomial([k]), poly.Polynomial([1]))
Esempio n. 3
0
 def systemFunction(self):
     """
     :returns: A ``SystemFunction`` equivalent to this difference
      equation
     """
     return SystemFunction(
             poly.Polynomial(util.reverseCopy(self.dCoeffs)),
             poly.Polynomial([-c for c in util.reverseCopy(self.cCoeffs)] \
                             + [1]))
Esempio n. 4
0
def FeedbackAdd(sf1, sf2=None):
    """
    :param sf1: ``SystemFunction``
    :param sf2: ``SystemFunction``
    :returns: ``SystemFunction`` representing the result of feeding the
     output of ``sf1`` back, with (optionally)
     ``sf2`` on the feedback path, adding it to the input, and
     feeding the resulting signal into ``sf1``.
    """
    if sf2 == None:
        sf2 = SystemFunction(poly.Polynomial([1]), poly.Polynomial([1]))
    (n1, d1) = (sf1.numerator, sf1.denominator)
    (n2, d2) = (sf2.numerator, sf2.denominator)
    return SystemFunction(n1 * d2, d1 * d2 - n1 * n2)
Esempio n. 5
0
def FeedbackAdd(sf1, sf2=None):
    """
    @param sf1: C{SystemFunction}
    @param sf2: C{SystemFunction}
    @returns: C{SystemFunction} representing the result of feeding the
    output of C{sf1} back, with (optionally)
    C{sf2} on the feedback path, adding it to the input, and
    feeding the resulting signal into C{sf1}.
    """
    if sf2 == None:
        sf2 = SystemFunction(poly.Polynomial([1]), poly.Polynomial([1]))
    (n1, d1) = (sf1.numerator, sf1.denominator)
    (n2, d2) = (sf2.numerator, sf2.denominator)
    return SystemFunction(n1 * d2, d1 * d2 - n1 * n2)
Esempio n. 6
0
def FeedbackSubtract(sf1, sf2=None):
    #!    pass
    """
    :param sf1: ``SystemFunction``
    :param sf2: ``SystemFunction``
    :returns: ``SystemFunction`` representing the result of feeding the
     output of ``sf1`` back, with (optionally)
     ``sf2`` on the feedback path, subtracting it from the input, and
     feeding the resulting signal into ``sf1``.  This situation can be
     characterized with Black's formula. 
    """
    if sf2 == None:
        sf2 = SystemFunction(poly.Polynomial([1]), poly.Polynomial([1]))
    (n1, d1) = (sf1.numerator, sf1.denominator)
    (n2, d2) = (sf2.numerator, sf2.denominator)
    return SystemFunction(n1 * d2, d1 * d2 + n1 * n2)
Esempio n. 7
0
    def poles(self):
        """
        :returns: a list of the poles of the system
        """
        # The poles of a system are the roots of the denominator
        # polynomial in z, which is 1/R.  To get that polynomial,
        # reverse the coefficients of our polynomial (which is in R).

        # make polynomials of z
        num = util.reverseCopy(self.numerator.coeffs)
        den = util.reverseCopy(self.denominator.coeffs)
        # kill off zero-valued leading coeffs (although they don't
        # seem to bother numpy)
        while len(num) > 1 and num[0] == 0:
            num = num[1:]
        while len(den) > 1 and den[0] == 0:
            den = den[1:]
        # cancel poles at zero with zeros at zero
        while len(num) > 0 and len(den) > 0 and num[-1] == den[-1] == 0:
            num = num[:-1]
            den = den[:-1]
        return poly.Polynomial(den).roots()
Esempio n. 8
0
def R():
    """
    :returns: ``SystemFunction`` representing a system that delays
     the input signal by one step.
    """
    return SystemFunction(poly.Polynomial([1, 0]), poly.Polynomial([1]))