Example #1
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]))
Example #2
0
 def systemFunction(self):
     """
     @returns: A C{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]))
Example #3
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()
Example #4
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()
Example #5
0
    def differenceEquation(self):
        """
        :returns: a ``DifferenceEquation`` representation of this same system
        """
        # Orders of the output and input parts
        k = self.denominator.order
        j = self.numerator.order

        # Generate an error if the coefficient of y[n] is 0
        a0 = float(self.denominator.coeffs[-1])
        assert not a0 == 0, "Coefficient of y[n] must be non-zero"

        # Now derive coefficient lists c and d of this form
        # y[n] = c_0 y[n-1] + c_{k-1} y[n-k] +
        #        d_0 x[n] + d_1 x[n-1] + ... + d_j x[n-j]
        # Coefficients for newest state and input are at the front;
        # these are the least delayed, so we have to reverse the
        # coeffs in the polynomials
        cCoeffs = [-a/a0 for a in \
                        util.reverseCopy(self.denominator.coeffs[:-1])]
        dCoeffs = [b/a0 for b in \
                        util.reverseCopy(self.numerator.coeffs)]

        return DifferenceEquation(dCoeffs, cCoeffs)
Example #6
0
    def differenceEquation(self):
        """
        @returns: a C{DifferenceEquation} representation of this same system
        """
        # Orders of the output and input parts
        k = self.denominator.order
        j = self.numerator.order

        # Generate an error if the coefficient of y[n] is 0
        a0 = float(self.denominator.coeffs[-1])
        assert not a0 == 0, "Coefficient of y[n] must be non-zero"

        # Now derive coefficient lists c and d of this form
        # y[n] = c_0 y[n-1] + c_{k-1} y[n-k] +
        #        d_0 x[n] + d_1 x[n-1] + ... + d_j x[n-j]
        # Coefficients for newest state and input are at the front;
        # these are the least delayed, so we have to reverse the
        # coeffs in the polynomials
        cCoeffs = [-a/a0 for a in \
                        util.reverseCopy(self.denominator.coeffs[:-1])]
        dCoeffs = [b/a0 for b in \
                        util.reverseCopy(self.numerator.coeffs)]

        return DifferenceEquation(dCoeffs, cCoeffs)