Hi, I have the following error in Codebook Codercise F.1.4:
Error: operands could not be broadcast together with shapes (8,) (4,)
I have run it in my jupyter notebook and I have shape (8,)
Best,
Adin
I am running this code
def fft_multiplication(poly_a, poly_b):
“”"Returns the result of multiplying two polynomials
Args:
poly_a (array[complex]): 1-D array of coefficients
poly_b (array[complex]): 1-D array of coefficients
Returns:
array[complex]: complex coefficients of the product
of the polynomials
"""
##################
# YOUR CODE HERE #
##################
# Calculate the number of values required
value= len(poly_a)+ len(poly_b)+ 1
# Figure out the nearest power of 2
n= nearest_power_of_2(value)
# Pad zeros to the polynomial
poly_a= np.pad(poly_a, (0,n-len(poly_a)))
poly_b= np.pad(poly_b, (0,n-len(poly_b)))
# Convert the polynomials to value representation
value_a= coefficients_to_values(poly_a)
value_b= coefficients_to_values(poly_b)
# Multiply
#value_c= np.zeros((n,),dtype=complex)
#for index in range(n):
# value_c[index]= value_a[index] * value_b[index]
value_c= np.multiply(value_a,value_b)
#print(value_c)
# Convert back to coefficient representation
return values_to_coefficients(value_c)