Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-176

Gershgorin Discs

Problem

For each row of square matrix A, return its Gershgorin disc as [center, radius], where

center = A[i][i] and radius = sum of |A[i][j]| over j != i.

Every eigenvalue of A lies in the union of these discs.

Hint

The Gershgorin circle theorem bounds the spectrum by row-wise discs.

Test cases

case 1
in: [[[2,1],[1,3]]]
expected: [[2,1],[3,1]]
case 2
in: [[[1,2,3],[4,5,6],[7,8,9]]]
expected: [[1,5],[5,10],[9,15]]
case 3
in: [[[0,0],[0,0]]]
expected: [[0,0],[0,0]]
case 4
in: [[[1.5,-2.5],[0,3]]]
expected: [[1.5,2.5],[3,0]]
Starter codePython
def gershgorin_discs(A):
    # Your code here
    pass

4 test cases · run your code against them in the editor