Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-197

Jordan Block

Problem

Build the n x n Jordan block with eigenvalue lam: lam on the diagonal, 1 on the superdiagonal, and 0 elsewhere.

Jordan blocks are the building blocks of the Jordan canonical form.

Hint

A Jordan block has a single eigenvalue but is not diagonalizable unless n == 1.

Test cases

case 1
in: [2,3]
expected: [[2,1,0],[0,2,1],[0,0,2]]
case 2
in: [5,1]
expected: [[5]]
case 3
in: [0,2]
expected: [[0,1],[0,0]]
case 4
in: [3,2]
expected: [[3,1],[0,3]]
Starter codePython
def jordan_block(lam, n):
    # Your code here
    pass

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