Skip to content
Advertisement

Tag: matrix

Combination of rows in numpy.ndarray

I have the following numpy.ndarray I want to find all the possible combinations of sum of each row (sum of individual elements of a row except the last column) of S[0,:,:] with each row of S[1,:,:], i.e., my desired result is (order does not matter): which is a 9-by-2 array resulting from 9 possible combinations of S[0,:,:] and S[1,:,:]. Although

Why is ‘scipy.sparse.linalg.spilu’ less efficient than ‘scipy.linalg.lu’ for sparse matrix?

I posted this question on https://scicomp.stackexchange.com, but received no attention. As long as I get answer in one of them, I will inform in the other. I have a matrix B which is sparse and try to utilize a function scipy.sparse.linalg.spilu specialized for sparse matrix to factorize B. Could you please explain why this function is significantly less efficient than

Create a matrix with np.random.normal

I need to create an nxn matrix in which the numbers in the cells are distributed following a Gaussian distribution. This code may not go well because it fills a cell with a sequence. how can I do? Answer Edited for border of zeros np.random.normal takes a size keyword argument. You can use it like this:

Delete values over the diagonal in a matrix with python

I have the next problem with a matrix in python and numpy given this matrix i want to obtain this: I was trying with np.diag() but doesnt works Thanks! Answer Use np.tril(a) to extract the lower triangular matrix. Refer this : https://docs.scipy.org/doc/numpy/reference/generated/numpy.tril.html

Python-Scipy sparse Matrices – what is A[i, j] doing?

According to my previous question here (Python – Multiply sparse matrix row with non-sparse vector by index) direct indexing of sparse matrices is not possible (at least not if you don’t want to work with the three arrays by which the sparse.csr matrix is defined, data, indices, indptr). But I just found out, that given a csr-sparse matrix A, this

supposedly incorrect output np.reshape function

I have an array called “foto_dct” with shape (16,16,8,8) which means 16×16 matrices of 8×8. When I print foto_dct[0,15], being the last matrix of the first row I get: when i do foto_dct_big = np.reshape(foto_dct,(128,128)) and print foto_dct_big I get this: As you can see is the top righter corner( which is supposed to be the matrix above with all

Advertisement