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

Mark Hoemmen mhoemme at sandia.gov
Thu Apr 7 15:29:25 MDT 2011


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



More information about the Trilinos-Users mailing list