



'''simple docstring'''







from math import sqrt







def  SCREAMING_SNAKE_CASE__ (				SCREAMING_SNAKE_CASE     ):
		SCREAMING_SNAKE_CASE_						:Tuple										=      [1]
		for i in range(2 ,		int(sqrt(SCREAMING_SNAKE_CASE     )     ) + 1 ,		1     ):
				if number % i == 0:
						values.append(SCREAMING_SNAKE_CASE     )
						if int(number // i     ) != i:
								values.append(int(number // i     )     )
		return sorted(SCREAMING_SNAKE_CASE     )







def  SCREAMING_SNAKE_CASE__ (				SCREAMING_SNAKE_CASE     ):
		return sum(factors(SCREAMING_SNAKE_CASE     )     ) > n







def  SCREAMING_SNAKE_CASE__ (				SCREAMING_SNAKE_CASE     ):
		SCREAMING_SNAKE_CASE_						:List[Any]										=      factors(SCREAMING_SNAKE_CASE     )
		SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      len(SCREAMING_SNAKE_CASE     )
		SCREAMING_SNAKE_CASE_						:Dict										=      [[0 for i in range(number + 1     )] for j in range(r + 1     )]
		for i in range(r + 1     ):
				SCREAMING_SNAKE_CASE_						:Tuple										=      True

		for i in range(1 ,		number + 1     ):
				SCREAMING_SNAKE_CASE_						:Optional[Any]										=      False

		for i in range(1 ,		r + 1     ):
				for j in range(1 ,		number + 1     ):
						if j < values[i - 1]:
								SCREAMING_SNAKE_CASE_						:int										=      subset[i - 1][j]
						else:
								SCREAMING_SNAKE_CASE_						:Optional[Any]										=      subset[i - 1][j] or subset[i - 1][j - values[i - 1]]

		return subset[r][number] != 0







def  SCREAMING_SNAKE_CASE__ (				SCREAMING_SNAKE_CASE     ):
		return abundant(SCREAMING_SNAKE_CASE     ) and not semi_perfect(SCREAMING_SNAKE_CASE     )


if __name__ == "__main__":
							import doctest

							doctest.testmod(verbose=True)
							for number in (69, 70, 71):
														print(f"""{number} is {"" if weird(number) else "not "}weird.""")




from typing import Any

import numpy as np






def  _UpperCAmelCase						( __lowerCamelCase							)		->bool:


 '''simple docstring'''
 assert np.shape(__lowerCamelCase							)[0] == np.shape(__lowerCamelCase							)[1]

 # If matrix not symmetric, exit right away.
 if np.allclose(__lowerCamelCase			,  matrix.T							) is False:
  return False

 # Get eigenvalues and eignevectors for a symmetric matrix.
 snake_case	,       snake_case :			int							=   np.linalg.eigh(__lowerCamelCase							)

 # Check sign of all eigenvalues.
 # np.all returns a value of type np.bool_
 return bool(np.all(eigen_values > 0							)							)






def  _UpperCAmelCase						( __lowerCamelCase							)		->Any:


 '''simple docstring'''
 snake_case :			Dict							=   np.random.randn(__lowerCamelCase			,  __lowerCamelCase							)
 snake_case :			List[Any]							=   np.dot(__lowerCamelCase			,  random_matrix.T							)
 assert _is_matrix_spd(__lowerCamelCase							)
 return spd_matrix






def  _UpperCAmelCase						( __lowerCamelCase			,  __lowerCamelCase			,  __lowerCamelCase = 1000			,  __lowerCamelCase = 1E-8			,  )		->Any:


 '''simple docstring'''
 assert np.shape(__lowerCamelCase							)[0] == np.shape(__lowerCamelCase							)[1]
 assert np.shape(__lowerCamelCase							)[0] == np.shape(__lowerCamelCase							)[0]
 assert _is_matrix_spd(__lowerCamelCase							)

 # Initialize solution guess, residual, search direction.
 snake_case :			Any							=   np.zeros((np.shape(__lowerCamelCase							)[0], 1)							)
 snake_case :			Optional[int]							=   np.copy(__lowerCamelCase							)
 snake_case :			Optional[Any]							=   np.copy(__lowerCamelCase							)

 # Set initial errors in solution guess and residual.
 snake_case :			Optional[Any]							=   1E9
 snake_case :			List[Any]							=   1E9
 snake_case :			List[str]							=   1E9

 # Set iteration counter to threshold number of iterations.
 snake_case :			List[str]							=   0

 while error > tol:
  # Save this value so we only calculate the matrix-vector product once.
  snake_case :			str							=   np.dot(__lowerCamelCase			,  __lowerCamelCase							)

  # The main algorithm.

  # Update search direction magnitude.
  snake_case :			List[str]							=   np.dot(ra.T			,  __lowerCamelCase							) / np.dot(pa.T			,  __lowerCamelCase							)
  # Update solution guess.
  snake_case :			Optional[int]							=   xa + alpha * pa
  # Calculate new residual.
  snake_case :			str							=   ra - alpha * w
  # Calculate new Krylov subspace scale.
  snake_case :			List[str]							=   np.dot(r.T			,  __lowerCamelCase							) / np.dot(ra.T			,  __lowerCamelCase							)
  # Calculate new A conjuage search direction.
  snake_case :			List[Any]							=   r + beta * pa

  # Calculate errors.
  snake_case :			List[Any]							=   np.linalg.norm(r - ra							)
  snake_case :			Any							=   np.linalg.norm(x - xa							)
  snake_case :			str							=   np.maximum(__lowerCamelCase			,  __lowerCamelCase							)

  # Update variables.
  snake_case :			Tuple							=   np.copy(__lowerCamelCase							)
  snake_case :			Tuple							=   np.copy(__lowerCamelCase							)
  snake_case :			List[str]							=   np.copy(__lowerCamelCase							)

  # Update number of iterations.
  iterations += 1
  if iterations > max_iterations:
   break

 return x






def  _UpperCAmelCase						( )		->None:


 '''simple docstring'''
 snake_case :			str							=   3
 snake_case :			Dict							=   _create_spd_matrix(__lowerCamelCase							)
 snake_case :			str							=   np.random.randn(__lowerCamelCase			,  1							)
 snake_case :			str							=   np.dot(__lowerCamelCase			,  __lowerCamelCase							)

 # Numpy solution.
 snake_case :			Any							=   np.linalg.solve(__lowerCamelCase			,  __lowerCamelCase							)

 # Our implementation.
 snake_case :			List[str]							=   conjugate_gradient(__lowerCamelCase			,  __lowerCamelCase							)

 # Ensure both solutions are close to x_true (and therefore one another).
 assert np.linalg.norm(x_numpy - x_true							) <= 1E-6
 assert np.linalg.norm(x_conjugate_gradient - x_true							) <= 1E-6


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  test_conjugate_gradient()






