
'''simple docstring'''







from __future__ import annotations







def        SCREAMING_SNAKE_CASE__			(     __A    ,       __A			) ->			bool:
	_snake_case     		=	get_failure_array(__A			)

	# 2) Step through text searching for pattern
	_snake_case		,				_snake_case     		=	0, 0  # index into text, pattern
	while i < len(__A			):
		if pattern[j] == text[i]:
			if j == (len(__A			) - 1):
				return True
			j += 1

		# if this is a prefix in our pattern
		# just go back far enough to continue
		elif j > 0:
			_snake_case     		=	failure[j - 1]
			continue
		i += 1
	return False







def        SCREAMING_SNAKE_CASE__			(     __A			) ->			list[int]:
	_snake_case     		=	[0]
	_snake_case     		=	0
	_snake_case     		=	1
	while j < len(__A			):
		if pattern[i] == pattern[j]:
			i += 1
		elif i > 0:
			_snake_case     		=	failure[i - 1]
			continue
		j += 1
		failure.append(__A			)
	return failure


if __name__ == "__main__":
					# Test 1)
					lowercase					:							str   =      "abc1abc12"
					lowercase					:							Dict   =      "alskfjaldsabc1abc1abc12k23adsfabcabc"
					lowercase					:							Dict   =      "alskfjaldsk23adsfabcabc"
					assert kmp(pattern, texta) and not kmp(pattern, texta)

					# Test 2)
					lowercase					:							str   =      "ABABX"
					lowercase					:							Union[str, Any]   =      "ABABZABABYABABX"
					assert kmp(pattern, text)

					# Test 3)
					lowercase					:							int   =      "AAAB"
					lowercase					:							str   =      "ABAAAAAB"
					assert kmp(pattern, text)

					# Test 4)
					lowercase					:							Any   =      "abcdabcy"
					lowercase					:							Dict   =      "abcxabcdabxabcdabcdabcy"
					assert kmp(pattern, text)

					# Test 5)
					lowercase					:							Any   =      "aabaabaaa"
					assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]



'''simple docstring'''







from typing import Any

import numpy as np







def        SCREAMING_SNAKE_CASE__			(     __A			) ->			bool:
	return np.array_equal(__A    ,       matrix.conjugate().T			)







def        SCREAMING_SNAKE_CASE__			(     __A    ,       __A			) ->			Any:
	_snake_case     		=	v.conjugate().T
	_snake_case     		=	v_star.dot(__A			)
	assert isinstance(__A    ,       np.ndarray			)
	return (v_star_dot.dot(__A			)) / (v_star.dot(__A			))







def        SCREAMING_SNAKE_CASE__			(     ) ->			None:
	_snake_case     		=	np.array([[2, 2 + 1j, 4], [2 - 1j, 3, 1j], [4, -1j, 1]]			)
	_snake_case     		=	np.array([[1], [2], [3]]			)
	assert is_hermitian(__A			), F'{a} is not hermitian.'
	print(rayleigh_quotient(__A    ,       __A			)			)

	_snake_case     		=	np.array([[1, 2, 4], [2, 3, -1], [4, -1, 1]]			)
	assert is_hermitian(__A			), F'{a} is not hermitian.'
	assert rayleigh_quotient(__A    ,       __A			) == float(3			)


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					tests()

