[julia-users] What is the best way to element-wise right shift an array?

2016-09-18 Thread David P. Sanders
You should also benchmark the simple for loop. Please report back with the 
results. 

Re: [julia-users] What is the best way to element-wise right shift an array?

2016-09-18 Thread Tim Holy
On Sunday, September 18, 2016 2:55:46 AM CDT K leo wrote:
> I have been using simply A=[0; A[1:end-1]], but found it to be somehow
> quite expensive.  I saw that there is unshift! but it has to be followed up
> with deleteat! to make the array the same size, i.e. there need to be two
> operations.  So how can I get a better performance doing the shift?

If A will always have the same length, you might use CircularBuffer. If A will 
have some predictable maximum size, you could use CircularDeque. Both of these 
are in https://github.com/JuliaLang/DataStructures.jl

--Tim





[julia-users] What is the best way to element-wise right shift an array?

2016-09-18 Thread K leo
I have been using simply A=[0; A[1:end-1]], but found it to be somehow 
quite expensive.  I saw that there is unshift! but it has to be followed up 
with deleteat! to make the array the same size, i.e. there need to be two 
operations.  So how can I get a better performance doing the shift?