Boost logo

Boost :

From: Helmut Zeisel (helmut.zeisel_at_[hidden])
Date: 2001-07-04 13:54:04


Mit, 04 Jul 2001 you wrote:
> on 7/2/01 4:12 PM, Helmut at helmut.zeisel_at_[hidden] wrote:
>
> > --- In boost_at_y..., <boost_at_y...> wrote:
> >> You can access this file at the URL
> >> http://groups.yahoo.com/group/boost/files/big_int/big_int_20010702.zip
>
> > This is a first release of my unlimited integer class. It has been tested
> > under NT (VC++ 6.0) and Linux (GCC 2.95). Observe that the heavy use of
> > templates requires option /Zm210 under VCC and -ftemplate-depth-32 under GCC.
> > With the exception of rational arithmetics, the tests and examples run on both
> > platforms.
>
> I guess you use some sort of extreme constructs, because my compiler
> _crashed_ when I tried to make your examples/tests. I had to use my
> operating system's kill-program keystroke to take back control.

This is pretty bad :-(
I only can guess from the experiences with VC++ and GCC
that you possibly need to add some compiler option
to increase compiler stack
size or template instantiation depth or something similar.
Let me know if you find a solution.

>
> For these tests and examples, you don't need to maintain separate *.hpp
> files. If there is only one file's worth of source, it's better to keep it
> in one file, so it's self-contained.

Originally I had it in one file only.
I decided, however, to use a template parameter for the integer class
so that just be including the *.hpp file in a simple main,
it might be possible to use the same .hpp file
for testing several implementations for the integer interface.

>
> > .) What should be syntax and semantics of a "div" function that returns
> > quotient and remainder at the same time? I implemented a member function
> > div(d,q) which returns *this /= d and sets q to the remainder. There are,
> > however, many other possibilities.
>
> I had a class-static "div" member function that took in the dividend and
> divisor and returned a std::pair representing the quotient and remainder.
>

I will add a similar function (but still offer my div member fct as a possible
optimization)

I vote for a "free" (i.e. not class-static) version, because it is more similar
to the built-in ints. What do other people think?

Anyway, it will be easy to change it in one or the other direction
(free vs. class-static)

>
> > .) I am still looking for a good name for a floating point division of two
> > unlimited integers. Observe that it might happen that two integers are too
> > large to be representable as double, but there quotient can be represented.
> >
> > Do you like double fdiv(const integer& p, const integer& q)?
>
> Would this be a class-static member function?
>

Free, not class-static ;-)
But again, I will not insist on that.

> > What should be the name of a float or a long double version?
>
> Maybe you could have just a long double version.
>

Sounds good. I will do this for the beginnint.

> > In file big_int.hpp there is a section of structs which, IMHO, should be part
> > of operators.hpp. I would appreciate if David Abrahams and/or Jeremy Siek
> > could check this section and offer similar functionality in operators.hpp.
>
> I think I added a bunch of similar structs already. I think there are a few
> differences, though.

I will check it.
If the differences are only in names, not in functionality,
it should not be too difficult to find a common proposal for David Abrahams and
Jeremy Siek.

> >
> > AFAIK, Hubert Holin is working on an FFT implementation for boost. Maybe I
> > will implement fast O(n log n) multiplication/division when boost-FFT is
> > available.
>
> Speed is nice, but we shouldn't have to compete with the specialty C++ math
> packages. None of the other Boost math packages do.

I agree.
But the difference between an O(n**2) and an O(n log n) algorithm
can be quite large ;-)

Helmut


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk