Improved execution speed.

Removed some calls to bsxfun which is not optimal on sparse matrices. I
only removed the calls where I identified bottlenecks (with a Smets and
Wouters model), more tests are needed to decide if we have to remove other
occurences of bsxfun on sparse matrices.
time-shift
Stéphane Adjemian (Hermes) 2015-12-30 13:29:28 +01:00 committed by Stéphane Adjemian (Charybdis)
parent be0f6230ad
commit ee78ad2049
1 changed files with 3 additions and 3 deletions

View File

@ -537,7 +537,7 @@ end
I1a = I(Indexset==1 & alpha_l==1);
if any(I1a)
H2(I1a,:) = bsxfun(@times,x(I1a)-lb(I1a),DFx(I1a,:))+...
H2(I1a,:) = spdiags(x(I1a)-lb(I1a), 0, length(I1a), length(I1a))*DFx(I1a,:) +...
sparse(1:length(I1a),I1a,Fx(I1a),length(I1a),n,length(I1a));
end
@ -619,7 +619,7 @@ if any(I3a)
sparse(1:length(I3a),I3a,Fx(I3a),length(I3a),n,length(I3a));
end
H1 = bsxfun(@times,Db,DFx);
H1 = spdiags(diag(H1)+Da,0,H1);
H1 = spdiags(Db,0,length(Db),length(Db))*DFx;
H1 = H1 + spdiags(Da, 0, length(Da), length(Da));
H = [lambda1*H1; lambda2*H2];