I'm in a Julia project and I want to optimize my function oneAttempt in my code below.
A brief explanation of my code below:
- function
oneAttmeptimplements a certain recursive algorithm return the terminal result. - A variable
fis the variable which is updated through the algorithm which I wrote asalgorithm partin the code below(I would omit this part for this question) . - function
oneAttemptwould be called many times (more than 1000 times) under for loop.
function oneAttempt()
n = 30
m = 900
x = rand(Normal(), n, n)
A = ones(n, n) * sum(sum(x, dims = 1))
# f would be passed to the algorithm below.
# f0 is the initial value of f
f0 = ones(n, n) + x - (1 / m) * A
f = copy(f0)
o = zeros(n, n)
#=
algorithm part:
while loop in which f would be updated many times under complicated algorithm
=#
return f;
end
# the function `oneAttempt` would be called many times (more than 1000 times) under for loop.
I guess there are better optimized ways of making f0, since I heard vector calculation would be an ordinary bottleneck in Julia coding.
Is there better ways of coding?
Any information would be appreciated.