From: Matt Fig on 22 Apr 2010 12:46 If you are really concerned about memory, you could consider using sparse storage for the imaginary part of the array (assuming the imaginary part is indeed sparse). % Example data M = complex(rand(6,1),rand(6,1)./(10.^ceil(rand(6,1)*14))) % Storage scheme R = real(M); I = imag(M); clear M % Otherwise what is the point? I(I<tol) = 0; % tol as you wish I = sparse(I);
From: James Tursa on 22 Apr 2010 12:58 "Matt Fig" <spamanon(a)yahoo.com> wrote in message <hqpugu$k1u$1(a)fred.mathworks.com>... > If you are really concerned about memory, you could consider using sparse storage for the imaginary part of the array (assuming the imaginary part is indeed sparse). > > > % Example data > M = complex(rand(6,1),rand(6,1)./(10.^ceil(rand(6,1)*14))) > > % Storage scheme > R = real(M); > I = imag(M); > clear M % Otherwise what is the point? > I(I<tol) = 0; % tol as you wish > I = sparse(I); I had thought of this and almost included that in my post, but decided not to because of the limited usefulness of this setup IMO. If you wanted to work with it in any way that required the parts to be combined together as a complex array (e.g., maybe as an argument to a pre-existing function) then there goes your memory savings. And writing loops to work with the elements individually would likely be painfully slow. But, admittedly, the usefulness of the sparse approach depends on how OP intends to use the arrays downstream. James Tursa
From: Matt Fig on 22 Apr 2010 13:25 "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message > I had thought of this and almost included that in my post, but decided not to because of the limited usefulness of this setup IMO. If you wanted to work with it in any way that required the parts to be combined together as a complex array (e.g., maybe as an argument to a pre-existing function) then there goes your memory savings. And writing loops to work with the elements individually would likely be painfully slow. But, admittedly, the usefulness of the sparse approach depends on how OP intends to use the arrays downstream. > > James Tursa True enough, James. It will be up to the OP to figure out what is really needed. I should have added that in accessing the elements of the array with the above storage scheme, these are equivalent: M(n) % After tolerance applied. complex(R(n),I(n)) But as James points out, the usefulness of this scheme (or lack thereof) will depend on what is being done with the data.
First
|
Prev
|
Pages: 1 2 Prev: convert a sound file to bit stream Next: how to cluster points into n-unknown groups? |