Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
memory of permutation verse multiplication of sparse matrices

Subject: memory of permutation verse multiplication of sparse matrices

From: Rich

Date: 13 Feb, 2009 10:02:02

Message: 1 of 1

this is related to a previous post I made, and to a few in the archive - but I'm getting a strange quirk that I can't explain from what I've read

Using a large sparse matrix A, I want to permute the rows using a vector p.

Now the usual way,
A(p,:) overloads memory

so the work around is creating a permtuation matrix
p1 = sparse(1:length(p), p, ones(1,length(p)));
and pre-mutiplying

which proceeds fine, giving desired result.

So as the first method is the desired, more eloquent way, is there a reason why can't matlab handle it?


PS -
To my eyes,
A(p,:) appears to store 0 values when doing the permutation.
As when I limit the system to a size that memory can handle,
A(p,:)*1 has the same final memory requirements as p1*A
As far as I understand, arithmatic on a sparse matrix rids zero values.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us