Then, in the derivative function I am filling those arrays:
for i=1:1:g+1
views[i] = view(x,:,:,i)
A_mul_B!(lay1mul[i], views[i], views[i])
end
(x is generated with ‘rand(n,n,g+1)’ )
I expected lay1mul to contain g+1 possibly different arrays of type Array{Float64,2}.
But all g+1 elements are the same.
It means that running ‘A_mul_B!(lay1mul[1], views[1], views[1])’ fills all elements of lay1mul to the same value.
Ow, you are right, that initialization was a problem.
But I have one more question. Looking more at the variables I noticed that
julia> lay1mul[1]===lay1mul[2]
true
But views (after for loop) contains different elements and
julia> views[1]===views[2]
false
What is the reason for this behavior? Is it because after using view() elements of views point at different parts of memory and they are not linked anymore?
@yha Thanks! I’ve been looking for 15 minutes for one-liner to do it.