Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with reading version 4.2 DumpSave files,...

3 views
Skip to first unread message

terry

unread,
May 4, 2007, 4:33:49 AM5/4/07
to
Dear Mathematica Guru's,

Because of a Mathematica bug (which still isn't fixed in the just
released version 6), my version 4.2 DumpSave files cannot be read by
my version 5.2. So as a result I'm trying to find a way to _exactly_
write out these numbers to a pure ascii text file from within 4.2,
then read them in as text and convert them back into number form
within 5.2 without losing any digits. Any idea's how I could
accomplish this simply?

Note that simply saving the approximate real numbers with Save[] and
retreiving them will not work in this case because Save[] 'distorts'
the numbers even if they are loaded back into the same version of
Mathematica (when it converts to base 10 and back).

Thanks in advance!

Regards,
Terry


Jens-Peer Kuska

unread,
May 5, 2007, 5:56:21 AM5/5/07
to
Hi,

and using the old binary package for binary import/export in 4.2
and usging BinaryImport[]/BinaryExport[] in the newer version
can't help ?

Regards
Jens

Jean-Marc Gulliet

unread,
May 5, 2007, 6:14:22 AM5/5/07
to
On 5/4/07, Terry Chung <terry...@yahoo.com> wrote:
> Hi Jean-Marc,
>
> Thanks for the reply! I'm going to take a closer look
> at what you suggest this weekend, although right now
> I'm not sure it will work for my case. The reason is
> because of lost digits in conversion to base 10 (for
> displaying on the screen in the Mathematica GUI).
> What your doing seems very similar to the Save[]
> function I used to use to save my numbers in between
> runs of my simulation. What I discovered was that
> Save[] converts the number to base 10 (from the
> internal binary representation within Mathematica and
> all computers) to write to the external file. When I
> read the number back in, it was sometimes slightly
> different when I compared it to the unsaved version
> of the same number.
>
> What I really need is a method for saving the exact
> binary representation of that number in an purely
> text format and a reciprocal method for reading that
> number back in.
>
> Does that make sense?
>
> Terry

Hi Terry,

In addition, you could use BaseForm to convert the numbers in binary
form. A quick and dirty example follows (just to give you an overall
idea).

In[1]:=
expr={{1.234567987654*^6,-34.3892839,898890.7348327,-8.748328494823489*^8},{\
124567.98764,-8934.3892839,89890.7348327,-8.78907284948235*^9}}

Out[1]=
6 8
9
{{1.23457 10 , -34.3893, 898891., -8.74833 10 }, {124568., -8934.39,
89890.7, -8.78907 10 }}

In[2]:=
data = (StringReplace[#1, Characters["{ 2}"] -> ""] & ) /@
(ToString[BaseForm[NumberForm[#1, {20, 20}, NumberPadding -> {"0",
"0"}, SignPadding -> True,
ExponentFunction -> (Null & )], 2]] & ) /@ expr

Out[2]=
{0100101101011010000111.1111110011010110111001000111111,-100010.\
01100011101010000001110000010011010110111111111,011011011011101001010.\
101111000001110111111110111011101,-110100001001001110001111010001.\
011110110111101100111
,011110011010010111.1111110011010101111110011001110001,-10001011100110.\
01100011101010000001110000010011010111,010101111100100010.\
101111000001110111111110111011101001,-1000001011110111101001101111010001.\
01111011011110110100
}

HTH,
Jean-Marc

>
> --- Jean-Marc Gulliet <jeanmarc...@gmail.com>

> > ToString and NumberForm should be what you need
> > before Export. Knowing
> > nothing about the kind of numbers you are dealing
> > with and the data
> > structure, it is hard to tell more. You can check
> > the following thread
> > to see some examples of the above mentioned
> > functions in action.
> >
> >
> http://forums.wolfram.com/mathgroup/archive/2007/Apr/msg00523.html
> >
> > Regards,
> > Jean-Marc
> >
>
>
>
>
> ____________________________________________________________________________________
> Get your own web address.
> Have a HUGE year through Yahoo! Small Business.
> http://smallbusiness.yahoo.com/domains/?p=BESTDEAL
>

Jean-Marc Gulliet

unread,
May 5, 2007, 6:36:40 AM5/5/07
to

ToString and NumberForm should be what you need before Export. Knowing

terry

unread,
May 6, 2007, 1:49:53 AM5/6/07
to
On May 5, 2:56 am, Jens-Peer Kuska <k...@informatik.uni-leipzig.de>
wrote:

> Hi,
>
> and using the old binary package for binary import/export in 4.2
> and usging BinaryImport[]/BinaryExport[] in the newer version
> can't help ?
>
> Regards
> Jens

Unfortuneately not:

From my 4.2 instance:
==============================================

In[13]:= a = targetFunction[[1]]

Out[13]= \!\(7.540873625469604946490279853`12.6348*^-897\)

In[14]:= Export["new_test", a, "Dump"]

Out[14]= new_test


From my 5.2 instance:
==============================================

In[14]:= a = Import["a:/new_test","Dump"];

In[15]:= a

Out[15]= \!
\(2.618456009313894180400204624`12.634760176636481*^-887\)


ragfield

unread,
May 6, 2007, 1:58:05 AM5/6/07
to

If you have both the old version and new version of Mathematica
installed on your system you can probably use MathLink to transfer the
exact expression from the old version of Mathematica to the new
version, then re-DumpSave it in the new version. Try something like
this in the *old* version, adjusting the LinkLaunch path to point to
the new version on your system.

data=Get["oldfile.mx"]

l=LinkLaunch["/Applications/Mathematica.app/Contents/MacOS/MathKernel -
mathlink"]

LinkRead[l]

LinkWrite[l,Unevaluated[
EvaluatePacket[DumpSave["newfile.mx", Evaluate[data]]]]]

LinkRead[l]

LinkClose[l]

-Rob


Chris Chiasson

unread,
May 6, 2007, 2:11:22 AM5/6/07
to
Did you try the Save command?

On 5/4/07, terry <terry...@yahoo.com> wrote:
> Dear Mathematica Guru's,
>

> Because of a Mathematica bug (which still isn't fixed in the just
> released version 6), my version 4.2 DumpSave files cannot be read by
> my version 5.2. So as a result I'm trying to find a way to _exactly_
> write out these numbers to a pure ascii text file from within 4.2,
> then read them in as text and convert them back into number form
> within 5.2 without losing any digits. Any idea's how I could
> accomplish this simply?
>
> Note that simply saving the approximate real numbers with Save[] and
> retreiving them will not work in this case because Save[] 'distorts'
> the numbers even if they are loaded back into the same version of
> Mathematica (when it converts to base 10 and back).
>

> Thanks in advance!
>
> Regards,
> Terry
>
>
>


--
http://chris.chiasson.name/

Jens-Peer Kuska

unread,
May 7, 2007, 5:30:57 AM5/7/07
to
Hi,

Export[] is not the package I'd mean I mean the FadtBinary
package from MathSource

http://library.wolfram.com/infocenter/MathSource/354/

to write the data with 4.2 and than you can try to read the data
with Import[] in 5.2

Regards
Jens

terry

unread,
May 14, 2007, 4:18:15 AM5/14/07
to
Ok I've completed my testing finally. It turns out that the solution
to my problems is simpler than I ever would have thought. It appears
that the problems I've had with the Save[] command not faithfully
saving real numbers only affects version 3.0. When I run the following
code in version 3.0, it never takes long before the loop exits
indicating that what was saved by Save[] does not match what was read
back in. However in version 4.2, try as I may I could not get the loop
to terminate. So that's it, I can just re-save all my real numbers in
4.2 using the Save[] function then read them in from my 5.2 instance.
Thanks again for everyone's input (and especially Chris for giving me
the idea to re-test the Save[] function)!

Terry

P.S. Here's the code I used for testing:


x = True;
While[x,
targetFunction = 537932*Random[Real,{1,27}]^3;
targetFunction2 = targetFunction;

Save["temp",targetFunction2];
Clear[targetFunction2];
Get["temp"];
DeleteFile["temp"];

x = RealDigits[targetFunction2,2] == RealDigits[targetFunction, 2];
If[x == False,
Print[RealDigits[targetFunction,2]];
Print[RealDigits[targetFunction2,2]];
];
];


0 new messages