Initalizing a matrix to infinity in python -


this question has answer here:

how initalize matrix large number, infinity.

similar initalizing elements zero: sample = np.matrix((np.zeros(50,50))

i want initalize infinity

how in python?

there np.infin numpy

>>> sample = np.matrix(np.ones((50,50)) * np.inf) >>> sample matrix([[ inf,  inf,  inf, ...,  inf,  inf,  inf],     [ inf,  inf,  inf, ...,  inf,  inf,  inf],     [ inf,  inf,  inf, ...,  inf,  inf,  inf],     ...,      [ inf,  inf,  inf, ...,  inf,  inf,  inf],     [ inf,  inf,  inf, ...,  inf,  inf,  inf],     [ inf,  inf,  inf, ...,  inf,  inf,  inf]]) 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -