bug-gmp
[Top][All Lists]
Advanced

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

fprintf for GMP objects?


From: Ronald Bruck
Subject: fprintf for GMP objects?
Date: Thu, 5 Apr 2001 15:13:45 -0700

I've just started using GMP, and am delighted at finally being able to get good multi-precision results. But I have a couple of questions:

1. Is there a C++ wrapper for it yet? I'm mostly interested in the floating-point stuff.

2. Failing that, has anyone written a relacement for fscanf and fprintf which will read/write GMP reals instead of doubles?

I have ported Brian Borchers' csdp (a semidefinite-programming optimizer) using GMP rationals and floats instead of doubles, and life would have been SO much easier with (1). I wrote my own kludgy version of fprintf, just to print single floats (with preceding and following text) using %w.de notation, but I hate reinventing the wheel. Surely someone has written a full fprintf?! If nothing else, using K&R's example of how to use a variable argument list, intercepting the "%e" call.

I also wrote a routine to read an object from a file, deciding on-the-fly whether it's an integer, a rational, or a float; and storing the value in a GMP integer, rational, and float, as they make sense. (For example, if it reads an object it decides is an integer, it stores it in the GMP integer, GMP rational, and GMP float.) Again, this is surely reinventing the wheel.

And there are implementation questions I've sloughed off, because I have no one to ask. For example, if my fprintf finds a format specification of %e, it diverges from the standard fprintf in that it will use an mpf_out_str with a precision of 0, i.e. it will print FULL PRECISION. That means it won't be compatible with the standard fscanf. For my purposes that's not important, but if it were to be public code, this would have to be thought about.

So what sort of i/o is available?  What sort of wrapper?

I'll make csdp publicly available when I've tested it more thoroughly. Right now it's kind of rough. But if you want to peek at it, you can get it by anonmyous ftp from: imperator.usc.edu.



--Ron Bruck



reply via email to

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