import numpy as np
import sympy as sp


def eigenstuff(R):
    # Calculate their eigenvalues, eigenvectors, and
    #  conditioning numbers

    eigenvalues, eigenvectors = np.linalg.eig(R)
    conditioning_number = max(eigenvalues) / min(eigenvalues)

    # Setando a precisão para 3 pro print ficar mais bonito.
    np.set_printoptions(precision=3)

    print(f'A matriz R:')
    print(R)
    print('\n')
    print(f'Autovalores de R: {eigenvalues}')
    print(f'Autovetores de R:')
    print(eigenvectors)
    print(f'Número de condicionamento de R: {conditioning_number:.3f}')


def symbolic_eigevalues(R):

    print('\n')
    print(f'Autovalores e suas multiplicidades:')
    print(R.eigenvals())


def symbolic_eigenstuff(R):
    print('\n')
    print('Autovalores, multiplicidade e autoveores:')
    print(R.eigenvects())


def symbolic_diagonalize(R):
    P, D = R.diagonalize()
    print('\n \n')
    print('Diagonalização da matriz R:')
    print(P)
    print(D)
    print(P**-1)
