boost.math

View: New views
11 Messages — Rating Filter:   Alert me  

boost.math

by rodrigue pons :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

i need to implement the computation of huges series. These series are
made of floats, and thus the error propagates.
The problem is that the main constrain is the execution time, thus i
must use the more "native" type possible.
Is boost.math offer a solution to minimize this error? Which type of
float (float, double, any structure?) must i use?

Thanks.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: boost.math

by Paul A. Bristow-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> -----Original Message-----
> From: boost-bounces@... [mailto:boost-bounces@...] On
Behalf Of
> rodrigue pons
> Sent: Tuesday, October 27, 2009 5:49 PM
> To: boost@...
> Subject: [boost] boost.math
 
> i need to implement the computation of huges series. These series are
> made of floats, and thus the error propagates.
> The problem is that the main constrain is the execution time, thus i
> must use the more "native" type possible.
> Is boost.math offer a solution to minimize this error? Which type of
> float (float, double, any structure?) must i use?

I feel sure that in raw compute speed, hardware built-in float and double will
be fastest, and probably double as fast as float.

More precise types like NTL RR and GMP are usually *very* much slower, but the
improved precision might make them worth it.

But I suspect that you will only find out which is best by trying it out on the
hardware you have available.

At least the Boost.Math makes changing float type quite easy :-)

HTH - FWIW

Paul
 
---
Paul A. Bristow
Prizet Farmhouse
Kendal, UK   LA8 8AB
+44 1539 561830, mobile +44 7714330204
pbristow@...





_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: boost.math

by John Maddock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> i need to implement the computation of huges series. These series are
> made of floats, and thus the error propagates.
> The problem is that the main constrain is the execution time, thus i
> must use the more "native" type possible.
> Is boost.math offer a solution to minimize this error? Which type of
> float (float, double, any structure?) must i use?

It depends why the error is creeping in:

* Computing with double is usually as fast as with float (the only exception
occurs where SSE optimizations can parrelellise the code).
* You could use either NTL::RR or MPFR to obtain high precision arithmetic -
Boost.Math contains wrappers for these that make them look "just like a
built in type" plus the glue and traits classes required to work well with
the rest of Boost.Math, but performance will be many many times slower than
a native type.  See
http://www.boost.org/doc/libs/1_40_0/libs/math/doc/sf_and_dist/html/math_toolkit/using_udt.html
* You could try computing the series using Kahan's summation algorithm
http://www.boost.org/doc/libs/1_40_0/libs/math/doc/sf_and_dist/html/math_toolkit/toolkit/internals1/series_evaluation.html 
but the advantage gained is usually minimal except possibly in some special
cases.

Ultimately before you do any of the above, what you need to decide, is why
is the error occurring?  Once you know what it is about the arithmetic
involved that generates the error then you can start to do something about
it.  One trick I sometimes use if I can't spot anything obvious right away
is to write some debugging code that computes the result at two different
precisions - set it to break when the results start to drift apart, and with
luck you can then spot what's causing the problem.

HTH, John.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: boost.math

by Michael Goldshteyn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

"John Maddock" <john@...> wrote in message
news:1B058C04D8C44540B01DE6EE0A5DE772@acerlaptop...
> * You could use either NTL::RR or MPFR to obtain high precision
> arithmetic - Boost.Math contains wrappers for these that make them look
> "just like a built in type" plus the glue and traits classes required to
> work well with the rest of Boost.Math, but performance will be many many
> times slower than a native type.  See
> http://www.boost.org/doc/libs/1_40_0/libs/math/doc/sf_and_dist/html/math_toolkit/using_udt.html
>
> HTH, John.

Correct me if I am wrong on this, but the use of NTL::RR or MPFR
automatically forces you to comply with the GPL, meaning that they are
practically worthless for commercial use.

Mike


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: boost.math

by Paul A. Bristow-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> -----Original Message-----
> From: boost-bounces@... [mailto:boost-bounces@...] On
Behalf Of
> gmane
> Sent: Wednesday, October 28, 2009 2:03 PM
> To: boost@...
> Subject: Re: [boost] boost.math
 
> Correct me if I am wrong on this, but the use of NTL::RR or MPFR
> automatically forces you to comply with the GPL, meaning that they are
> practically worthless for commercial use.

I believe you are right about using NTL RR (we have asked the author of NTL to
change the license but without success) but previous discussions seemed to
conclude that GMP http://gmplib.org/  might be used (because is it LGPL not GPL)
and discouraged anyone from writing  Boost's Own Version of big integer (and big
float) libraries.

http://en.wikipedia.org/wiki/LGPL says (apart from other matters):

"Whether a work that uses an LGPL program is a derivative work or not is a legal
issue."

IANAL and I fear that many lawyers would take the view that the situation causes
too much FUD to be acceptable.

This all seems a regrettable waste of the massive efforts of the GMP team - "the
fastest bignum library on the planet!".

Paul

---
Paul A. Bristow
Prizet Farmhouse
Kendal, UK   LA8 8AB
+44 1539 561830, mobile +44 7714330204
pbristow@...










_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: boost.math

by rodrigue pons :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you very much for ours replies.
I had a look on these libs, but they don't fit to my context because i
need the logarithm(s) function(s), and these libs don't implement
it/them. And i don't have time nor skill to do it myself.
I tried also MAPM, that implement logaritmic functions, but there is
others problems with this lib. But i'm going to resolve them.

Thank you all.

r0d.

2009/10/28 Paul A. Bristow <pbristow@...>:

>> -----Original Message-----
>> From: boost-bounces@... [mailto:boost-bounces@...] On
> Behalf Of
>> gmane
>> Sent: Wednesday, October 28, 2009 2:03 PM
>> To: boost@...
>> Subject: Re: [boost] boost.math
>
>> Correct me if I am wrong on this, but the use of NTL::RR or MPFR
>> automatically forces you to comply with the GPL, meaning that they are
>> practically worthless for commercial use.
>
> I believe you are right about using NTL RR (we have asked the author of NTL to
> change the license but without success) but previous discussions seemed to
> conclude that GMP http://gmplib.org/  might be used (because is it LGPL not GPL)
> and discouraged anyone from writing  Boost's Own Version of big integer (and big
> float) libraries.
>
> http://en.wikipedia.org/wiki/LGPL says (apart from other matters):
>
> "Whether a work that uses an LGPL program is a derivative work or not is a legal
> issue."
>
> IANAL and I fear that many lawyers would take the view that the situation causes
> too much FUD to be acceptable.
>
> This all seems a regrettable waste of the massive efforts of the GMP team - "the
> fastest bignum library on the planet!".
>
> Paul
>
> ---
> Paul A. Bristow
> Prizet Farmhouse
> Kendal, UK   LA8 8AB
> +44 1539 561830, mobile +44 7714330204
> pbristow@...
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>



--
PONS Rodrigue
Analista Autónomo

tel: 627.89.46.92
página web: r0d.developpez.com/index-es.php
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: boost.math

by John Maddock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>Thank you very much for ours replies.
>I had a look on these libs, but they don't fit to my context because i
>need the logarithm(s) function(s), and these libs don't implement
>it/them. And i don't have time nor skill to do it myself.
>I tried also MAPM, that implement logaritmic functions, but there is
>others problems with this lib. But i'm going to resolve them.

If you use the wrappers that Boost.Math supplies then both NTL::RR and mpfr
supply all the std lib functions including log etc.

But analyse your code to find out where the error is coming from before you
just reach for more digits.

John.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: boost.math

by rodrigue pons :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I can't use NTL because i'm working on a commercial software.

About the "error": my english is quite bad, maybe "imprecision" should
be the real word. I have a serie of computacions, and at each step, i
lose a bit o precision. I just want to minimise this imprecision.

2009/10/29 John Maddock <john@...>:

>> Thank you very much for ours replies.
>> I had a look on these libs, but they don't fit to my context because i
>> need the logarithm(s) function(s), and these libs don't implement
>> it/them. And i don't have time nor skill to do it myself.
>> I tried also MAPM, that implement logaritmic functions, but there is
>> others problems with this lib. But i'm going to resolve them.
>
> If you use the wrappers that Boost.Math supplies then both NTL::RR and mpfr
> supply all the std lib functions including log etc.
>
> But analyse your code to find out where the error is coming from before you
> just reach for more digits.
>
> John.
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>



--
PONS Rodrigue
Analista Autónomo

tel: 627.89.46.92
página web: r0d.developpez.com/index-es.php
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: boost.math

by Stewart, Robert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

rodrigue pons wrote:
>
> I can't use NTL because i'm working on a commercial software.

John suggested previously using something like NTL in order to identify where the drift or error occurs so that you can correct your algorithm.  That doesn't mean you need to ship with NTL in your application.

_____
Rob Stewart                           robert.stewart@...
Software Engineer, Core Software      using std::disclaimer;
Susquehanna International Group, LLP  http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: boost.math

by John Maddock :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>I can't use NTL because i'm working on a commercial software.

Nod, understood.

>About the "error": my english is quite bad, maybe "imprecision" should
>be the real word. I have a serie of computacions, and at each step, i
>lose a bit o precision. I just want to minimise this imprecision.

Right, and as I said, you really need to work out *why* you're loosing
precision at each step, once you have that information then you can do
something about it - usually!

John.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Re: boost.math

by rodrigue pons :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok i see, thank you.

2009/10/29 John Maddock <john@...>:

>> I can't use NTL because i'm working on a commercial software.
>
> Nod, understood.
>
>> About the "error": my english is quite bad, maybe "imprecision" should
>> be the real word. I have a serie of computacions, and at each step, i
>> lose a bit o precision. I just want to minimise this imprecision.
>
> Right, and as I said, you really need to work out *why* you're loosing
> precision at each step, once you have that information then you can do
> something about it - usually!
>
> John.
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>



--
PONS Rodrigue
Analista Autónomo

tel: 627.89.46.92
página web: r0d.developpez.com/index-es.php
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost