Hi lovely Matlab experts,
Could you please let me know the rationale behind the speed-up stated below? Is it a random case or not? Hope there's something I can keep in mind to have faster run.
symMat=subs(sym,{},{});%symMat is a complex matrix whose elements are too long to show in command window
symMat %*elapsed time ~20s*, digits=32 as default
vpa(symMat,32) % *elapsed time ~5s*
More surprisingly is the following 'for' or 'parfor' loop will be 10 times faster after being 'vpa'ed as shown below, and I thought there's 'vpa' in the loop so escaping another vpa outside loop is good:
ticfor i=1:1000 digits(4) vpa(subs(symMat(:,1),,))); digits(32) vpa(subs(symMat(:,2),,)));end toc %%*the above elapse ~1200s*
VpasymMat=vpa(symMat,32)tic for i=1:1000 digits(4) vpa(subs(VpasymMat(:,1),,))); digits(32) vpa(subs(VpasymMat(:,2),,))); end toc %%*the above elapse 60-100s*
thanks,
best
J
Best Answer