-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpolmatmult.py
40 lines (27 loc) · 1.03 KB
/
polmatmult.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 04 16:59:32 2016
@author: Max
after Matlab function by Gerald Schuller
Modified July 2016, Gerald Schuller
"""
import numpy as np
def polmatmult( A,B ):
"""polmatmult(A,B)
multiplies two polynomial matrices (arrays) A and B, where each matrix entry is a polynomial.
Those polynomial entries are in the 3rd dimension
The thirs dimension can also be interpreted as containing the (2D) coefficient
exponent of z^-1.
Result is C=A*B;"""
[NAx, NAy, NAz] = np.shape(A);
[NBx, NBy, NBz] = np.shape(B);
"Degree +1 of resulting polynomial, with NAz-1 and NBz-1 being the degree of the..."
Deg = NAz + NBz -1;
#initialize (with complex zeros):
C = np.zeros((NAx,NBy,Deg))#*(1+1j);
"Convolution of matrices:"
for n in range(0,(Deg)):
for m in range(0,n+1):
if ((n-m)<NAz and m<NBz):
C[:,:,n] = C[:,:,n]+ np.dot(A[:,:,(n-m)],B[:,:,m]);
return C