Answers for "use reshape in python with zeros"

0

use reshape in python with zeros

import numpy as np
...
shape = (6, 6) #This will be some pre-determined size
sigma = np.diag(S) #diagonalise the matrix - this works
sigma.resize(shape) #Resize the matrix and fill with zeros
Posted by: Guest on May-02-2020
0

use reshape in python with zeros

# This assumes that you have a 2-dimensional array
zeros = np.zeros(shape, dtype=np.int32)
zeros[:sigma.shape[0], :sigma.shape[1]] = sigma
Posted by: Guest on May-02-2020

Python Answers by Framework

Browse Popular Code Answers by Language