How to speed this up - large variable
Afficher commentaires plus anciens
Hello,
Is there a way to speed this up? This if within a function and i can use codegen - and I do. But I need to speed this up more. I think the problem is that one variable is huge and the access to it takes long? What should be done in such a case?
xElements = 1201;
maxN = 100;
umnHolder = complex(zeros(maxN + 1, maxN + 1));
betaSumSq1 = zeros(xElements, xElements); % preallocate
besselsFisher = zeros(1201, 1201, 101); % just to show the size LARGE, ~780 MB
XY = zeros(xElements, xElements); % just to show the size
acosContainer = XY; % just to show the size
parfor i = 1 : xElements
for j = 1 : xElements
umn = umnHolder;
for n = 0:maxN
mm = 1;
for m = -n:2:n
nn = n + 1; % for indexing
if m > 0
umn(nn, mm) = sqrt(n+1) * XY(i, j) * besselsFisher(i, j, nn) * cos( abs(m)*acosContainer(i, j) );
end
if m < 0
umn(nn, mm) = sqrt(n+1) * XY(i, j) * besselsFisher(i, j, nn) * sin( abs(m)*sign(x(i))*acosContainer(i, j) );
end
if m == 0
umn(nn, mm) = sqrt(n+1) * XY(i, j) * besselsFisher(i, j, nn);
end
mm = mm + 1;
end % m
end % n
beta1 = sum(sum(Aj1.*umn));
betaSumSq1(i, j) = abs(beta1).^2;
beta2 = sum(sum(Aj2.*umn));
betaSumSq2(i, j) = abs(beta2).^2;
end % j
end % i
Best regards, Alex
4 commentaires
Walter Roberson
le 21 Juil 2016
Any hope for a meaningful speed-up is probably going to depend upon the extent to which the unknown function besselsFisher can be vectorized. I do not find that routine anywhere the internet.
Alex Kurek
le 22 Juil 2016
Alex Kurek
le 22 Juil 2016
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Execution Speed dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!