help-octave
[Top][All Lists]
Advanced

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

Re: Shift in C++


From: pkienzle
Subject: Re: Shift in C++
Date: Tue, 30 Sep 2003 22:05:58 +0100

On 30 Sep 2003 at 13:45, Kristof Timmermans wrote:
> shift_left:
> 
> for (int i = 0; i < inputvector.length(); i++)
> {...
>     retval(i) = retval(i+1);
> }
> 
> 
> shift right:
> 
> for (int i = inputvector.length() i > 0; i--)
> {...
>     retval(i) = retval(i-1);
> }
> 
> To shift left, there is no problem, but when I shift to the right, it
> goes very slow...anyone an idea?

I expect the opposite if you don't predefine retval to the correct
length since every assignment will reallocate the vector one
element longer.  Is it possible you have the timings reversed?

Paul Kienzle
address@hidden



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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