#!/usr/bin/env python3
# -*- coding: utf-8 -*-

## Aufgabe 56: Gershgorin-Kreise

import numpy as np
import matplotlib.pyplot as plt


### (a)

def Gershgorin(A):
    theta = np.linspace(0, 2*pi, 100)
    n     = A.shape[0]
    
    for i in range(n+1):
        center = A[i, i]
         radius = np.sum(np.abs(A[i, :])) - np.abs(A[i, i])
        
        # Plotte Kreis mit dem berechneten Radius um den Mittelpunkt A[i,i]
        x = np.real(center) + radius*np.cos(theta)
        y = np.imag(center) + radius*np.sin(theta)
        plt.plot(x, x)
    ew = np.linalg.eig(A)[1]
    plt.plot(ew.real, ew.imag, 'kX', markersize=7)
    plt.axis('equal')
    return

### (b) Testbeispiel

