




'''simple docstring'''







class 	lowerCamelCase_				:




					'''simple docstring'''






					def __init__(       self,    __UpperCamelCase					):
							_snake_case      			=			data
							_snake_case      			=			None
							_snake_case      			=			None






					def __str__(       self					):
							return f'''{self.data}'''





class 	lowerCamelCase_				:




					'''simple docstring'''






					def __init__(       self					):
							_snake_case      			=			None
							_snake_case      			=			None






					def __iter__(       self					):
							_snake_case      			=			self.head
							while node:
									yield node.data
									_snake_case      			=			node.next






					def __str__(       self					):
							return "->".join([str(__UpperCamelCase					) for item in self]					)






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






					def 							__SCREAMING_SNAKE_CASE      (       self,    __UpperCamelCase					):
							self.insert_at_nth(0,    __UpperCamelCase					)






					def 							__SCREAMING_SNAKE_CASE      (       self,    __UpperCamelCase					):
							self.insert_at_nth(len(self					),    __UpperCamelCase					)






					def 							__SCREAMING_SNAKE_CASE      (       self,    __UpperCamelCase,    __UpperCamelCase					):
							_snake_case      			=			len(self					)

							if not 0 <= index <= length:
									raise IndexError("list index out of range"					)
							_snake_case      			=			Node(__UpperCamelCase					)
							if self.head is None:
									_snake_case      			=			_snake_case      			=			new_node
							elif index == 0:
									_snake_case      			=			new_node
									_snake_case      			=			self.head
									_snake_case      			=			new_node
							elif index == length:
									_snake_case      			=			new_node
									_snake_case      			=			self.tail
									_snake_case      			=			new_node
							else:
									_snake_case      			=			self.head
									for _ in range(0,    __UpperCamelCase					):
											_snake_case      			=			temp.next
									_snake_case      			=			new_node
									_snake_case      			=			temp.previous
									_snake_case      			=			temp
									_snake_case      			=			new_node






					def 							__SCREAMING_SNAKE_CASE      (       self					):
							return self.delete_at_nth(0					)






					def 							__SCREAMING_SNAKE_CASE      (       self					):
							return self.delete_at_nth(len(self					) - 1					)






					def 							__SCREAMING_SNAKE_CASE      (       self,    __UpperCamelCase					):
							_snake_case      			=			len(self					)

							if not 0 <= index <= length - 1:
									raise IndexError("list index out of range"					)
							_snake_case      			=			self.head  # default first node
							if length == 1:
									_snake_case      			=			_snake_case      			=			None
							elif index == 0:
									_snake_case      			=			self.head.next
									_snake_case      			=			None
							elif index == length - 1:
									_snake_case      			=			self.tail
									_snake_case      			=			self.tail.previous
									_snake_case      			=			None
							else:
									_snake_case      			=			self.head
									for _ in range(0,    __UpperCamelCase					):
											_snake_case      			=			temp.next
									_snake_case      			=			temp
									_snake_case      			=			temp.previous
									_snake_case      			=			temp.next
							return delete_node.data






					def 							__SCREAMING_SNAKE_CASE      (       self,    __UpperCamelCase					):
							_snake_case      			=			self.head

							while current.data != data:  # Find the position to delete
									if current.next:
											_snake_case      			=			current.next
									else:  # We have reached the end an no value matches
											raise ValueError("No data matching given value"					)

							if current == self.head:
									self.delete_head()

							elif current == self.tail:
									self.delete_tail()

							else:  # Before: 1 <--> 2(current) <--> 3
									_snake_case      			=			current.next  # 1 --> 3
									_snake_case      			=			current.previous  # 1 <--> 3
							return data






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






def 						_lowercase						(      ):



		'''simple docstring'''







		_snake_case      			=			DoublyLinkedList()
		assert linked_list.is_empty() is True
		assert str(lowercase_    ) == ""

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

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

		for i in range(10    ):
				assert len(lowercase_    ) == i
				linked_list.insert_at_nth(lowercase_		,				i + 1    )
		assert str(lowercase_    ) == "->".join(str(lowercase_    ) for i in range(1		,				11    )    )

		linked_list.insert_at_head(0    )
		linked_list.insert_at_tail(11    )
		assert str(lowercase_    ) == "->".join(str(lowercase_    ) for i in range(0		,				12    )    )

		assert linked_list.delete_head() == 0
		assert linked_list.delete_at_nth(9    ) == 10
		assert linked_list.delete_tail() == 11
		assert len(lowercase_    ) == 9
		assert str(lowercase_    ) == "->".join(str(lowercase_    ) for i in range(1		,				10    )    )


if __name__ == "__main__":
						from doctest import testmod

						testmod()











'''simple docstring'''







import numpy as np






def 						_lowercase						(      lowercase_    ):



		'''simple docstring'''







		_snake_case			,       _snake_case      			=			a.shape
		_snake_case      			=			min(lowercase_		,				lowercase_    )
		_snake_case      			=			np.eye(lowercase_    )
		_snake_case      			=			a.copy()

		for k in range(t - 1    ):
				# select a column of modified matrix A':
				_snake_case      			=			r[k:, [k]]
				# construct first basis vector
				_snake_case      			=			np.zeros_like(lowercase_    )
				_snake_case      			=			1.0
				# determine scaling factor
				_snake_case      			=			np.linalg.norm(lowercase_    )
				# construct vector v for Householder reflection
				_snake_case      			=			x + np.sign(x[0]    ) * alpha * ea
				v /= np.linalg.norm(lowercase_    )

				# construct the Householder matrix
				_snake_case      			=			np.eye(m - k    ) - 2.0 * v @ v.T
				# pad with ones and zeros as necessary
				_snake_case      			=			np.block([[np.eye(lowercase_    ), np.zeros((k, m - k)    )], [np.zeros((m - k, k)    ), q_k]]    )

				_snake_case      			=			q @ q_k.T
				_snake_case      			=			q_k @ r

		return q, r


if __name__ == "__main__":
						import doctest

						doctest.testmod()





