
'''simple docstring'''
from __future__ import annotations

from collections.abc import Iterator
from typing import Any






class    UpperCAmelCase_				:





 def __init__(    self ,       lowercase_):
     snake_case_ :    Any     			=						data
     snake_case_ :    Node | None     			=						None






class    UpperCAmelCase_				:





 def __init__(    self):
     snake_case_ :    Any     			=						None
     snake_case_ :    List[str]     			=						None





 def __iter__(    self):
     snake_case_ :    Dict     			=						self.head
     while self.head:
         yield node.data
         snake_case_ :    Tuple     			=						node.next
         if node == self.head:
             break





 def __len__(    self):
     return sum(1 for _ in self)





 def __repr__(    self):
     return "->".join(str(lowercase_) for item in iter(self))





 def        snake_case__		(    self ,       lowercase_):
     self.insert_nth(len(self) ,       lowercase_)





 def        snake_case__		(    self ,       lowercase_):
     self.insert_nth(0 ,       lowercase_)





 def        snake_case__		(    self ,       lowercase_ ,       lowercase_):
     if index < 0 or index > len(self):
         raise IndexError("list index out of range.")
     snake_case_ :    List[str]     			=						Node(lowercase_)
     if self.head is None:
         snake_case_ :    List[Any]     			=						new_node  # first node points itself
         snake_case_ :    Dict     			=						new_node
     elif index == 0:  # insert at head
         snake_case_ :    Any     			=						self.head
         snake_case_ :    str     			=						new_node
     else:
         snake_case_ :    List[Any]     			=						self.head
         for _ in range(index - 1):
             snake_case_ :    Optional[Any]     			=						temp.next
         snake_case_ :    str     			=						temp.next
         snake_case_ :    List[str]     			=						new_node
         if index == len(self) - 1:  # insert at tail
             snake_case_ :    Optional[int]     			=						new_node





 def        snake_case__		(    self):
     return self.delete_nth(0)





 def        snake_case__		(    self):
     return self.delete_nth(len(self) - 1)





 def        snake_case__		(    self ,       lowercase_ = 0):
     if not 0 <= index < len(self):
         raise IndexError("list index out of range.")
     snake_case_ :    str     			=						self.head
     if self.head == self.tail:  # just one node
         snake_case_ :    List[str]     			=						None
     elif index == 0:  # delete head node
         snake_case_ :    str     			=						self.tail.next.next
         snake_case_ :    List[str]     			=						self.head.next
     else:
         snake_case_ :    Any     			=						self.head
         for _ in range(index - 1):
             snake_case_ :    str     			=						temp.next
         snake_case_ :    Tuple     			=						temp.next
         snake_case_ :    Dict     			=						temp.next.next
         if index == len(self) - 1:  # delete at tail
             snake_case_ :    int     			=						temp
     return delete_node.data





 def        snake_case__		(    self):
     return len(self) == 0


def 						UpperCamelCase_     (	):
    """simple docstring"""






    snake_case_ :    str     			=						CircularLinkedList()
    assert len(__SCREAMING_SNAKE_CASE       ) == 0
    assert circular_linked_list.is_empty() is True
    assert str(__SCREAMING_SNAKE_CASE       ) == ""

    try:
        circular_linked_list.delete_front()
        raise AssertionError  # This should not happen
    except IndexError:
        assert True  # This should happen

    try:
        circular_linked_list.delete_tail()
        raise AssertionError  # This should not happen
    except IndexError:
        assert True  # This should happen

    try:
        circular_linked_list.delete_nth(-1       )
        raise AssertionError
    except IndexError:
        assert True

    try:
        circular_linked_list.delete_nth(0       )
        raise AssertionError
    except IndexError:
        assert True

    assert circular_linked_list.is_empty() is True
    for i in range(5       ):
        assert len(__SCREAMING_SNAKE_CASE       ) == i
        circular_linked_list.insert_nth(__SCREAMING_SNAKE_CASE,		i + 1       )
    assert str(__SCREAMING_SNAKE_CASE       ) == "->".join(str(__SCREAMING_SNAKE_CASE       ) for i in range(1,		6       )       )

    circular_linked_list.insert_tail(6       )
    assert str(__SCREAMING_SNAKE_CASE       ) == "->".join(str(__SCREAMING_SNAKE_CASE       ) for i in range(1,		7       )       )
    circular_linked_list.insert_head(0       )
    assert str(__SCREAMING_SNAKE_CASE       ) == "->".join(str(__SCREAMING_SNAKE_CASE       ) for i in range(0,		7       )       )

    assert circular_linked_list.delete_front() == 0
    assert circular_linked_list.delete_tail() == 6
    assert str(__SCREAMING_SNAKE_CASE       ) == "->".join(str(__SCREAMING_SNAKE_CASE       ) for i in range(1,		6       )       )
    assert circular_linked_list.delete_nth(2       ) == 3

    circular_linked_list.insert_nth(2,		3       )
    assert str(__SCREAMING_SNAKE_CASE       ) == "->".join(str(__SCREAMING_SNAKE_CASE       ) for i in range(1,		6       )       )

    assert circular_linked_list.is_empty() is False


if __name__ == "__main__":
  import doctest

  doctest.testmod()






'''simple docstring'''
import doctest
from collections import deque

import numpy as np






class    UpperCAmelCase_				:





 def __init__(    self):
     snake_case_ :    List[Any]     			=						[2, 1, 2, -1]
     snake_case_ :    int     			=						[1, 2, 3, 4]





 def        snake_case__		(    self):
     snake_case_ :    str     			=						len(self.first_signal)
     snake_case_ :    Any     			=						len(self.second_signal)

     snake_case_ :    List[Any]     			=						max(lowercase_ ,       lowercase_)

     # create a zero matrix of max_length x max_length
     snake_case_ :    Dict     			=						[[0] * max_length for i in range(lowercase_)]

     # fills the smaller signal with zeros to make both signals of same length
     if length_first_signal < length_second_signal:
         self.first_signal += [0] * (max_length - length_first_signal)
     elif length_first_signal > length_second_signal:
         self.second_signal += [0] * (max_length - length_second_signal)
     for i in range(lowercase_):
         snake_case_ :    List[str]     			=						deque(self.second_signal)
         rotated_signal.rotate(lowercase_)
         for j, item in enumerate(lowercase_):
             matrix[i][j] += item

        # multiply the matrix with the first signal
     snake_case_ :    Any     			=						np.matmul(np.transpose(lowercase_) ,       np.transpose(self.first_signal))

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


if __name__ == "__main__":
  doctest.testmod()




