convert a 2D numpy array to a 2D numpy matrix convert a 2D numpy array to a 2D numpy matrix numpy numpy

convert a 2D numpy array to a 2D numpy matrix


If you have a list of lists (as you mentioned), you need to convert it first to a numpy array; see how to convert 2d list to 2d numpy array?

A short example is given here:

import numpy as npa = [[  0. +0.j,   1.j,   2. -2.j],     [  4. -4.j,   5. -5.j,   6. -1.j],     [  8. -8.j,   9. -9.j,  10.]]b = np.matrix(np.array(a))b_inv = np.linalg.inv(b)