Single Precision by Default? ... lots of auxiliary variables to cast

62 views (last 30 days)
MikeStein
MikeStein on 3 Jun 2011
Commented: Stephen on 11 Sep 2018
Hi all,
I have an algorithm that I'd like to run using single precision instead of the default double precision. However, this algorithm uses many many auxiliary variables to store physical parameters that I'm simulating, and I really don't want to cast each and every one of them... Is there a way to set single precision to be the default? Otherwise, do you all have any suggestions?
Another complication that may matter... I set up the simulation parameters in an outside script, before calling a function with my primary algorithm. Both the outside script and the algorithm function contain a number of theses auxiliary variables (changing spatial grids, electromagnetic fields, and other physical parameters)

Accepted Answer

Walter Roberson
Walter Roberson on 3 Jun 2011
There is no way to set single precision by default.
  3 Comments

Sign in to comment.

More Answers (1)

Sean de Wolski
Sean de Wolski on 3 Jun 2011
How does it hurt if the other variables are double precision, the lowest precision will be kept.
single(magic(3)).*magic(3);
class(ans)
ans =
single
  1 Comment
MikeStein
MikeStein on 3 Jun 2011
Thanks both of you for your replies! I did find a way to 'trickle' down the single precision by casting a limited set of initial variables. I wish there was a Matlab feature for this though...
-Mike

Sign in to comment.

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!