首页 > 解决方案 > Get symmetric elements of a non-symmetric sparse matrix

问题描述

I am having a non-symmetric (csr) matrix A and given the indexes of the non-zero elements, in the i-th row, A[i].indices, I want to obtain the corresponding elements in the i-th column A[A[i].indices, :]. However, as the matrix is not symmetric the returned elements are not of the same size as the A[i].indices. I suppose some indices in A[i].indices correspond to zero elements in the i-th column. For example, with index starting from zero, in matrix A below, A[0].indices=[1,2] and A[A[0].indices, :]=[a_{31}].

Is it possible to obtain efficiently all elements (including zeros) that correspond in A[A[0].indices, :]? That is, to obtain A[A[0].indices, :] = [a_{21}, a_{31}], with a_{21}=0.

Thank you you advance.

标签: pythonscipysparse-matrix

解决方案


推荐阅读