I’m new julia programmer. I want to write a program that can calculate multiple and inverse iteratively. But I can’t return result. It’s my code.
addprocs(4);
@everywhere using Distributed ,
DistributedArrays
C=dzeros(1000000);
@time @distributed for i in 1:100
A=rand(10000,200);
B=rand(10000,1);
P=localpart(C);
P[1+(i-1)%Int(100/nworkers())]=
Vec((A×A')\B);
end
When I wanna see c as result. C is `0.
How do I fix my code?
I wanna calculate inv(A)×B that both of them matrices. This action must do several times on different data. I wanna use 4 process for doing it. When I use one process, everything is OK. I wanna speed up with multi processes. Result is zero. It is my problem.
The expression will error. @distributed gives back a Task object, which will collect exceptions from the worker processes. Check this for the error.
One reason why your expression won’t work, is that you try to assign a vector A*A'\B to a float P[1+(i-1)...]. The latter is a single entry of the array P. Make sure to assign the former to a chunk of P of proper length.
Also, it’s vec, not Vec. But that shouldn’t be needed anyway.
By the way, which Julia version are you on? I tried the code on 1.5.3 and the \times symbol for multiplication is no longer valid. Same on 1.6.