I've got a code from my supervisor to implement MDCT polyphase analysis and synthesis. Unfortunately, this code includes one very slow function with 2 loops. If somebody can help me to simplify this function and make it faster I will appreciate your help. This is part of the code:
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 third dimension can also be interpreted as containing the (2D) coefficient matrices of exponent of z^-1.
Result is C=A*B;"""
print("np.shape(A)", np.shape(A))
print("np.shape(B)", np.shape(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 input polynomials:"
Deg = NAz + NBz - 1;
print("Deg", Deg)
C = np.zeros((NAx, NBy, Deg));
"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
A,B?