|
1 #!/usr/bin/python |
|
2 # Superposes two polynomial matrices. |
|
3 |
|
4 import pylab as pl |
|
5 from polyfuncs import polsize |
|
6 |
|
7 def rowjoin(P1, degP1, P2, degP2): |
|
8 |
|
9 rP1, cP1 = polsize(P1, degP1) |
|
10 rP2, cP2 = polsize(P2, degP2) |
|
11 if not cP1 == cP2: |
|
12 print 'rowjoin: Inconsistent numbers of columns' |
|
13 exit() |
|
14 |
|
15 rP = rP1 + rP2 |
|
16 cP = cP1 |
|
17 degP = max(degP1, degP2) |
|
18 |
|
19 P = pl.atleast_2d(pl.zeros((rP,(degP+1)*cP))) |
|
20 P[0:rP1,0:(degP1+1)*cP1] = P1 |
|
21 P[rP1:rP,0:(degP2+1)*cP2] = P2 |
|
22 |
|
23 return P, degP |
|
24 |
|
25 if __name__== "__main__": |
|
26 s = """P = pl.array([[1, 2, 3, 4, 1, 2, 3, 4], |
|
27 [9, 10, 11, 12, 9, 10, 11, 12], |
|
28 [5, 6, 7, 8, 5, 6, 7, 8]])""" |
|
29 print s |
|
30 exec(s) |
|
31 print """rowjoin(P, 3, P, 3)""" |
|
32 print rowjoin(P, 3, P, 3) |