Prev: Dhrystone
Next: Learning Ada
From: Simon Wright on
Jeffrey Carter <spam.jrcarter.not(a)spam.not.acm.org> writes:

> On 08/05/2010 10:24 AM, Ada novice wrote:
>>
>> They are much more accurate and better results of course. I wonder why
>> Matlab tends to be give very "accurate" answers. Normally 15 digits of
>> precision is also used there.
>
> You requested 15 decimal digits; your results are zero to 15 decimal
> places. If you output in non-scientific notation you'd get zero;
> presumably that's what Matlab is doing.

The attached update uses fixed notation, looks rather better.

Note that the reason for the lack of precision in the Test16 results is
likely because the inputs are only specified to 6 digits.

From: John B. Matthews on
In article <m2k4o4dcxy.fsf(a)pushface.org>,
Simon Wright <simon(a)pushface.org> wrote:

> Jeffrey Carter <spam.jrcarter.not(a)spam.not.acm.org> writes:
>
> > On 08/05/2010 10:24 AM, Ada novice wrote:
> >>
> >> They are much more accurate and better results of course. I wonder
> >> why Matlab tends to be give very "accurate" answers. Normally 15
> >> digits of precision is also used there.
> >
> > You requested 15 decimal digits; your results are zero to 15
> > decimal places. If you output in non-scientific notation you'd get
> > zero; presumably that's what Matlab is doing.
>
> The attached update uses fixed notation, looks rather better.
>
> Note that the reason for the lack of precision in the Test16 results
> is likely because the inputs are only specified to 6 digits.

YC: For what it's worth, I think of this in model/view terms: The
subtype My_Float is a model of real numbers that is implemented as
polynomials with some finite number of terms having binary
coefficients. The package My_Float_IO provides a view of My_Float that
is rounded to some finite number of displayed decimal digits, the
default for which is My_Float'Digits-1.

[nice working update elided]

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
From: Jacob Sparre Andersen on
Ada novice <posts(a)gmx.us> wrote:

> Can we change the subtype to Long_Long_Float? This will be of 18
> precision digits [...]

That's not guaranteed. If you want 18 digits, you should declare the
type (My_Float?) as:

type My_Float is digits 18;

Jacob
--
Jacob Sparre Andersen Research & Innovation
Vesterbrogade 148K, 1. th.
1620 K�benhavn V
Danmark

Phone: +45 21 49 08 04
E-mail: jacob(a)jacob-sparre.dk
Web-sted: http://www.jacob-sparre.dk/
From: sjw on
On Aug 5, 6:24 pm, Ada novice <po...(a)gmx.us> wrote:

> On Aug 5, 3:57 pm, sjw <simon.j.wri...(a)mac.com> wrote:
>
> > Although LAPACK/BLAS (at 3.2.2 anyway) allow you to build with
> > extended precision (80-bit floats, GNAT Long_Long_Float if on x86
> > hardware) GNAT's implementation of Generic * Arrays assumes the worst
> > case, ie BLAS/LAPACK only available in single & double precision; and
> > if the type in use (My_Float in my test case) doesn't match Fortran
> > single or double precision it converts to double precision, makes the
> > call, then converts back.
>
> Can we change the subtype to Long_Long_Float? This will be of 18
> precision digits and "more" precise than Fortran's double precision.
> It would be like asking for more precision that can be offered. Did I
> understand you correctly?

You can change to Long_Long_Float, and on an Intel machine that will
use 80 bits (on a PowerPC it won't; Long_Long_Float is the same as
Long_Float, because the FPU on a PPC doesn't support extended
precision (AFAIK)).

*BUT* *BUT* *BUT* the internals of the matrix operations (the standard
ones and our extensions) only use 64 bits. So the apparent extra
precision is fool's gold.
From: Dmitry A. Kazakov on
On Fri, 06 Aug 2010 10:04:24 +0200, Jacob Sparre Andersen wrote:

> Ada novice <posts(a)gmx.us> wrote:
>
>> Can we change the subtype to Long_Long_Float? This will be of 18
>> precision digits [...]
>
> That's not guaranteed. If you want 18 digits, you should declare the
> type (My_Float?) as:
>
> type My_Float is digits 18;

Further, practically you should never use subtype in the form

subtype My_Float is Long_Float;

except for special cases like:

subtype Non_IEEE_Float is Long_Float range Long_Float'Range;

or

subtype Non_Negative_Float is Long_Float range 0.0..Long_Float'Last;

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
First  |  Prev  |  Next  |  Last
Pages: 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Prev: Dhrystone
Next: Learning Ada