I’m trying to apply a matrix A to a single column of each element of X and accumulate into X, where X is a tuple of arrays.
N = 2
A = rand(N,N)
X = (ones(N,N),ones(N,N))
for fld in eachindex(X)
X[fld][:,1] += A*X[fld][:,1]
end
I can apply A*X[fld][:,1] to all fields using map and broadcasted getindex, but I get an error if I try to set or accumulate into the columns of elements of the tuple
getindex.(X,(:),1) .+= map(x->A*x,getindex.(X,(:),1)) # doesn't work
Is there a way to do this without looping over the elements of the struct?