Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rounding off final values to 2 and minor changes
  • Loading branch information
subhendudash02 committed Feb 25, 2023
commit 944b0004f6fe748467d1ae267ae33694ddadc305
9 changes: 6 additions & 3 deletions electronics/circular_convolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def circular_convolution(self) -> list[float]:

# fills the smaller signal with zeros to make both signals of same length
if length_first_signal < length_second_signal:
self.second_signal = self.second_signal + np.zeros(max_length)
self.second_signal += np.zeros(max_length)
elif length_first_signal > length_second_signal:
self.first_signal = self.first_signal + np.zeros(max_length)
self.first_signal += np.zeros(max_length)

"""
Fills the matrix in the following way assuming 'x' is the signal
Expand All @@ -86,9 +86,12 @@ def circular_convolution(self) -> list[float]:
matrix = list(np.transpose(matrix))

# multiply the matrix with the first signal
self.first_signal = np.transpose(self.first_signal)
np.transpose(self.first_signal)
final_signal = list(np.matmul(matrix, self.first_signal))

# rounding-off to two decimal places
final_signal = [round(i, 2) for i in final_signal]

return final_signal


Expand Down