[Trilinos-Users] Idempotent floating-point I/O?

Bartlett, Roscoe A rabartl at sandia.gov
Thu Apr 7 15:38:24 MDT 2011


Mark,

I believe that this is controllable by the setup of the ostream object you are outputting to.  Just crank up the precision and you can get as many digits as you would like.  If you expect 16 significant digits, just print out something like 20 or whatever is needed to reproduce the same binary representation.

However, it seems like the ParameterList class should just automatically print out floating point numbers in full precision does it not?

-Ross


> -----Original Message-----
> From: trilinos-users-bounces at software.sandia.gov [mailto:trilinos-
> users-bounces at software.sandia.gov] On Behalf Of Mark Hoemmen
> Sent: Thursday, April 07, 2011 3:29 PM
> To: trilinos-users at software.sandia.gov
> Subject: [Trilinos-Users] Idempotent floating-point I/O?
> 
> On Apr 7, 2011, at 12:00 PM, <trilinos-users-
> request at software.sandia.gov> wrote:
> > Here's my code snippet based on cxx_main.cpp
> >
> >    ParameterList Sample("Sample Parameter List");
> >
> >    Sample.set("Parameter 1",1);
> >    Sample.set("Parameter 2", "some kind of string");
> >    Sample.set("Parameter 3", 1.23456789E-10);
> >    ParameterList& SB_1 = Sample.sublist("Sublist 1");
> >
> >    SB_1.set("Num of iterations", 100);
> >    SB_1.set("Tolerance", 1.000E-6);
> >    writeParameterListToXmlFile(Sample,"Sample.xml");
> >
> > and this is what I see in the XML file Sample.xml
> >
> > <ParameterList>
> >  <Parameter name="Parameter 1" type="int" value="1"/>
> >  <Parameter name="Parameter 2" type="string" value="some kind of
> string"/>
> >  <Parameter name="Parameter 3" type="double" value="1.23457e-10"/>
> 
> This comment is tangential to the example, but it's been troubling me
> lately: How important is it that floating-point numbers don't print out
> idempotently by default?  (Input had 8 digits after the point, output
> had 5.)  There is an algorithm (Guy Steele et al.) for efficient
> reproducible printing of fixed-precision floating-point numbers and
> I've been wanting to take the time to implement it, since it matters
> for matrix I/O.
> 
> mfh
> 
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> http://software.sandia.gov/mailman/listinfo/trilinos-users



More information about the Trilinos-Users mailing list