[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: plans for single-precision support?

From: Tim Rueth
Subject: RE: plans for single-precision support?
Date: Wed, 1 Sep 2010 14:21:19 -0700

> > Since it appears Octave defaults to double, I'm still having to 
> > initially allocate memory for twice the space that I need, 
> then I give back half.
> > I'm using ndgrid() to create numerous very large matrices.  
> Is there a 
> > way to invoke ndgrid() so that it just creates single-precision 
> > matrices without recasting them from double back to single?
> > 
> > Thanks,
> > 
> > --Tim
> Create your matrices and vectors initialy as single and do 
> not cast them
>  a = zeros(3,3, "single");
> class(a)
> ans = single
> Pass only "single" arguments to ndgrid.

Great, I did this.  However, I'm seeing a couple of anomalies that I can't

For example, if I run the following:

> amin = single(1); astep = single(0.1); amax = single(10);
> bmin = single(1); bstep = single(0.2); bmax = single(10);
> [a b] = ndgrid([amin:astep:amax], [bmin:bstep:bmax]);
> a_range = single(amin:astep:amax);
> b_range = single(bmin:bstep:bmax);
> [newa newb] = ndgrid(a_range, b_range);

I get both "a" and "b" as being double, but "newa" and "newb" are both
single.  So it looks like if you pass a range made up of singles into
ndgrid(), even though the min/step/max values are single, the range itself
doesn't end up single.  If I explicitly cast the range to single, then
ndgrid() gives me singles.  But wait, there's more:

If I repeat the above code except I just change amax to = single(1), (which
makes that range collapse to just "1"), then not only is "a" double as
before, "newa" is now double also, even though "a_range" is single.  I'm
confused.  Help?  I'm using 3.2.3 on Vista.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]