This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Fast way to extract non-zero matrix of a larger matrix

Tags: None
(comma "," separated)
matriza
Registered Member
Posts
17
Karma
0
Hi,

I'm doing least squares with quite large symmetric matrices (kernels) where many columns and rows are zero (but still mostly non-zero). Conceptually, if I could reorder the rows and columns, this would be a block matrix
|X 0|
|0 0|
but it's not one yet so I can't use the nice matrix slicing/block operations.

Are there any other options besides allocating a temporary matrix and copying all the non-zero elements to it? It is possible to make a view with a different ordering of columns and rows and run block operations on that?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Since you're doing least-square solving, at some point you'll have to copy the re-ordered sub matrix anyway, so what I usually do is to apply a symmetric permutation A.twist(P) where P is a PermutationMatrix, and then take the upper-left-corner.


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]