[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Vectorizing simple loops

From: pawelz
Subject: Re: Vectorizing simple loops
Date: Thu, 3 Dec 2015 04:04:21 -0800 (PST)

Brian - sure, you are welcome. I learned a lot to reuse later too. Indeed the
solution is very elegant, I never suspected such would be possible. I am
pasting it here too, for reference:

in = [ 1 0 2 0 7 7 7 0 5 0 0 0 9 ]
out = nonzeros(in).'(cumsum(in~=0))

Btw -  this second challenge <>  
is still unanswered. Given that I thought the same about the first one, I
don't trust my judgment entirely, but to me the second challenge seems more
difficult - if able to be vectorized at all...

View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]