|
From: <kk...@us...> - 2011-02-08 22:18:59
|
Revision: 111
http://python-control.svn.sourceforge.net/python-control/?rev=111&view=rev
Author: kkchen
Date: 2011-02-08 22:18:53 +0000 (Tue, 08 Feb 2011)
Log Message:
-----------
Fixes in xferfcn.py
- Division by a scalar now works.
- _common_den() modified so that the numerator coefficient arrays have the same
size as the common denominator. This is done by padding with zeros.
Kevin K. Chen <kk...@pr...>
Modified Paths:
--------------
branches/control-0.4a/src/xferfcn.py
Modified: branches/control-0.4a/src/xferfcn.py
===================================================================
--- branches/control-0.4a/src/xferfcn.py 2011-02-08 22:18:49 UTC (rev 110)
+++ branches/control-0.4a/src/xferfcn.py 2011-02-08 22:18:53 UTC (rev 111)
@@ -344,14 +344,14 @@
def __div__(self, other):
"""Divide two LTI objects."""
+ # Convert the second argument to a transfer function.
+ other = _convertToTransferFunction(other)
+
if (self.inputs > 1 or self.outputs > 1 or
other.inputs > 1 or other.outputs > 1):
raise NotImplementedError("TransferFunction.__div__ is currently \
implemented only for SISO systems.")
- # Convert the second argument to a transfer function.
- other = _convertToTransferFunction(other)
-
num = polymul(self.num[0][0], other.den[0][0])
den = polymul(self.den[0][0], other.num[0][0])
@@ -487,8 +487,9 @@
computes the single denominator containing all the poles of sys.den, and
reports it as the array d. The output numerator array n is modified to
- use the common denominator. It is an sys.outputs-by-sys.inputs-by-
- [something] array.
+ use the common denominator; the coefficient arrays are also padded with
+ zeros to be the same size as d. n is an sys.outputs-by-sys.inputs-by-
+ len(d) array.
"""
@@ -588,16 +589,12 @@
# Multiply in the missing poles.
for p in missingpoles[i][j]:
num[i][j] = polymul(num[i][j], [1., -p])
- # Find the largest numerator polynomial size.
- largest = 0
+ # Pad all numerator polynomials with zeros so that the numerator arrays
+ # are the same size as the denominator.
for i in range(self.outputs):
for j in range(self.inputs):
- largest = max(largest, len(num[i][j]))
- # Pad all smaller numerator polynomials with zeros.
- for i in range(self.outputs):
- for j in range(self.inputs):
- num[i][j] = insert(num[i][j], zeros(largest - len(num[i][j])),
- zeros(largest - len(num[i][j])))
+ num[i][j] = insert(num[i][j], zeros(len(den) - len(num[i][j])),
+ zeros(len(den) - len(num[i][j])))
# Finally, convert the numerator to a 3-D array.
num = array(num)
# Remove trivial imaginary parts. Check for nontrivial imaginary parts.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|