Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Compute Jordan normal form of matrix in Python / NumPy

In [1]: import numpy as np

In [2]: from sympy import Matrix

In [3]: a = np.array([[5, 4, 2, 1], [0, 1, -1, -1], [-1, -1, 3, 0], [1, 1, -1, 2]])

In [4]: m = Matrix(a)

In [5]: m
Out[5]: 
Matrix([
[ 5,  4,  2,  1],
[ 0,  1, -1, -1],
[-1, -1,  3,  0],
[ 1,  1, -1,  2]])

In [6]: P, J = m.jordan_form()

In [7]: J
Out[7]: 
Matrix([
[1, 0, 0, 0],
[0, 2, 0, 0],
[0, 0, 4, 1],
[0, 0, 0, 4]])
Comment

PREVIOUS NEXT
Code Example
Python :: p and c in python 
Python :: set environment variable heroku django 
Python :: python remove middle of string 
Python :: tkinter mouse loading cursor 
Python :: nibabel expand dimension 
Python :: python tupel from string 
Python :: relation api profile does not exist django 
Python :: geopandas nan to 0 
Python :: python reverse words and swap case 
Python :: Optimize images in python using pillow 
Python :: pytest using tempfile 
Python :: violajones python opencv 
Python :: pprint dic without sorting 
Python :: print hello in python 
Python :: powershell not printing until ctrl c 
Python :: how to install python on visual studio code 
Python :: python 3.10 windows 7 
Python :: yesterday date in python 
Python :: np.all() 
Python :: python index 
Python :: python multiprocessing queue 
Python :: python destructor 
Python :: readline python 
Python :: getting the number of missing values in pandas 
Python :: list from dataframe python 
Python :: python list remove all elements 
Python :: python max with custom function 
Python :: how to make capitalize text in python 
Python :: characters python 
Python :: tuple unpacking 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =