> In my code, there are such arrays (with BigFloat instead of character 
> string) :
>
> julia> ARRAY = ["a", "b", "c"]
>
> 3-element Array{ASCIIString,1}:
>
>  "a"
>
>  "b"
>
>  "c"
>
>
> and I perform this operation :
>
> julia> SHIFTED_ARRAY = ARRAY[[2:length(ARRAY); 1]] 
>
> 3-element Array{ASCIIString,1}:
>
>  "b"
>
>  "c"
>
>  "a"
>
>
> in order to apply a certain function *F(ARRAY, SHIFTED_ARRAY)*. 

So, my suggestion would translate into defining a 

F(ARRAY, SHIFT)

which will then run its loop with the shift applied.  Instead of making
a shifted array.

say something like
function F(ARRAY, SHIFT)
    acc = 0
    for (i,A) in enumerate(ARRAY)
        acc += A[i] + A[rem1(i+SHIFT, length(ARRAY))]
    end
    return acc
end

> Analogously, in the Linux system you can create *"symbolic links"* to a 
> file, which is somewhat a copy of the file but not taking some space on the 
> hard drive.  Again, I don't know how a programming language works, but is 
> there something analogous to a *"symbolic link to a variable"*, imrproving 
> some performance as compared to a "true" copy ? 

That is what ArrayViews does:

>> If that is not what you need you could look into ArrayViews: 
>> https://github.com/lindahua/ArrayViews.jl 
>> https://github.com/JuliaLang/julia/pull/5556 

> Le lundi 9 juin 2014 20:12:21 UTC+2, Mauro a écrit :
>>
>> This smells of vectorization.  If so, in Julia, you should try to change 
>> your loops rather than change your arrays.  Maybe like so: 
>>
>> julia> a = [1:5]; 
>>
>> julia> la = length(a); 
>>
>> julia> off = 0; 
>>
>> julia> for i=1+off:la+off 
>>            println(a[rem1(i,la)]) 
>>        end 
>> 1 
>> 2 
>> 3 
>> 4 
>> 5 
>>
>> julia> off = 1; 
>>
>> julia> for i=1+off:la+off 
>>            println(a[rem1(i,la)]) 
>>        end 
>> 2 
>> 3 
>> 4 
>> 5 
>> 1 
>>
>> If that is not what you need you could look into ArrayViews: 
>> https://github.com/lindahua/ArrayViews.jl 
>> https://github.com/JuliaLang/julia/pull/5556 
>>
>> On Mon, 2014-06-09 at 18:37, julia...@googlegroups.com <javascript:> 
>> wrote: 
>> > Hi, 
>> > 
>> >  In a program I have some *n*1* arrays, say 
>> > 
>> > *A* 
>> > *B* 
>> > *C* 
>> > *D* 
>> > 
>> > 
>> > and in order to make a certain calculation, for convenience, I construct 
>> > the array 
>> > 
>> > *A B* 
>> > *B C* 
>> > *C D* 
>> > *D A* 
>> > 
>> > 
>> > There will be millions of such arrays generated by my final program, 
>> with 
>> > *n* greater than 4 and the components A, B, C, D, ... are *BigFloat*. 
>> > 
>> > Then I'm wondering how to optimize my copy from the first array to the 
>> > second array. Is there something to gain performance when we duplicate 
>> some 
>> > variables ? 
>>
>>

Reply via email to