problem with parfor due to sympref
5 views (last 30 days)
Show older comments
Dear All,
I would greatly appreciate it if someone can make a comment on the following problem:
for some reason I turned sympref('FloatingPointOutput',true). I am running a code that includes a loop where I take numerical integrals over Hermit polynomials, see the below code. After I turned sympref('FloatingPointOutput',true) I noticed this part of the code never gets finished in a resonable amount of time. Then I turned sympref('FloatingPointOutput',false). In this case, I can only run the below code if I use a "for" loop- and if I use "parfor" the code again takes an infinite amount of time. Any idea what can be wrong here? the code with parfor was perfectly fine before I put sympref('FloatingPointOutput',true) at the first place.
Thanks a lot!
psi_nx = @(x,n) (2^n*factorial(n))^(-1/2)*(1/pi)^(1/4)*exp(-0.5*x.^2).*hermiteH(n,x);
parfor n=1:Mx
OvxHx3x4(n) = integral(@(x) psi_0x(x).*psi_nx(x,n-1),x3,x4);
OvxHx4(n) = integral(@(x) psi_0x(x).*psi_nx(x,n-1),x4 ,7);
OvxHx2x3(n) = integral(@(x) psi_0x(x).*psi_nx(x,n-1),x2,x3);
OvxHx2x1(n) = integral(@(x) psi_0x(x).*psi_nx(x,n-1),x1,x2);
OvxHx1(n) = integral(@(x) psi_0x(x).*psi_nx(x,n-1),-7,x1);
% the numbers x1,x2, x3 and x4, are pre-set
end
2 Comments
Alvaro
on 1 Dec 2022
Edited: Alvaro
on 1 Dec 2022
It is not clear to me how sympref would be affecting parfor but I would note that instead of sympref('FloatingPointOutput',false) I would try sympref('FloatingPointOutput','default').
Could you provide a working version of your code? I cannot run it at the moment without knowing Mx, x1, etc.
Walter Roberson
on 1 Dec 2022
psi_nx = @(x,n) (2^n*factorial(n))^(-1/2)*(1/pi)^(1/4)*exp(-0.5*x.^2).*hermiteH(n,x);
I note that hermiteH is implemented by the Symbolic Toolbox. When it is passed strictly numeric inputs then symbolic/@double/hermiteH.m will take the numeric inputs, convert them to symbolic, run the symbolic function, and convert the results back to double.
So that is why the symbolic toolbox is involved at all.
(But at the moment I do not know why the sympref is affecting the calculation.)
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!