Fastest math library for C++

  • Thread starter Thread starter Anna Smidt
  • Start date Start date
A

Anna Smidt

I am using the gsl math library for C++.
But I need more speed. Can anybody suggest a faster one?
Thanks.
Anna
 
Anna said:
I am using the gsl math library for C++.
But I need more speed. Can anybody suggest a faster one?
Thanks.
Anna

Sorry Anna, but this is a typical VB speak...
Afraid you'll never become a c++ ace :)

--PA
 
Anna Smidt said:
I am using the gsl math library for C++.
But I need more speed. Can anybody suggest a faster one?

I don't know what math features you need from a math library (array and
matrices? Special functions? etc.).

However, you may consider Blitz++ - it uses template metaprogramming
techniques to speed up matrix computations:

http://www.oonumerics.org/blitz/

If you need top speed, you may also consider optimizing and crafting the
code manually, e.g. inlining vector computations, avoiding things like
struct vec { double x, y, z } and using double v[3] instead, avoid virtual
functions in time-critical code, etc.

Giovanni
 
I will take a look into Blitz++, thanks.
I think inlining skills will have to wait for me some time still :-)

Anna
Anna Smidt said:
I am using the gsl math library for C++.
But I need more speed. Can anybody suggest a faster one?

I don't know what math features you need from a math library (array and
matrices? Special functions? etc.).

However, you may consider Blitz++ - it uses template metaprogramming
techniques to speed up matrix computations:

http://www.oonumerics.org/blitz/

If you need top speed, you may also consider optimizing and crafting the
code manually, e.g. inlining vector computations, avoiding things like
struct vec { double x, y, z } and using double v[3] instead, avoid virtual
functions in time-critical code, etc.

Giovanni
 
Sorry Anna, but this is a typical VB speak...
Afraid you'll never become a c++ ace :)

--PA

You estimate me wrong. I even tweaked VB6 with assembler code when I
needed it.
There are bad programmers in VB6 and good ones. The bad thing with VB6
is that it allows you really bad programming which some people abuse.
For example in a VB6 newsgroup somebody once said that he sells his
application for 5 years now and suddenly has a problem with it. And from
the code he posted I could see that (believe it or not) he stored
variables in Labels (these are standard controls in VB6) (which got
mixed up when VB6 converted Unicode to ANSI which caused his trouble, btw).

I wanted to say: When I wouldn't have wanted to become good at C++, I
would not have come here, would I?

Anna
 
Anna Smidt said:
You estimate me wrong. I even tweaked VB6 with assembler code when I
needed it.

You might be a good VB6 programmer, but I think Pavel is saying that you are
(for the moment) a bad question asker. Giovanni tried to answer your
question, but had to ask for additional details (which math functions are
you using) which you still haven't provided. We aren't telepathic, can't
read your mind. That's all.
 
Matrix and vector.
The GSL lib I'm using is already inline, but I'm feeling (it's a feeling
only, I cannot describe why I feel it... oh wait... I'm a woman, that
tells it all) that it's still slow/ too slow.
 
The GSL lib I'm using is already inline, but I'm feeling (it's a feeling
only, I cannot describe why I feel it... oh wait... I'm a woman, that
tells it all) that it's still slow/ too slow.

I think that in programming you don't use "feelings" to analyze performance
(?!).
You should *measure* performance, you could use benchmarks, etc.

Giovanni
 
Giovanni Dicanio said:
I think that in programming you don't use "feelings" to analyze
performance (?!).
You should *measure* performance, you could use benchmarks, etc.

After measuring performance, you know it takes 12.34 seconds. Is this good
or bad? Without a feeling that tells you if it's slow or fast, the number
doesn't have a meaning. That's why I think that the feeling can also be
important.

:-)


Armin
 
Armin Zingler said:
After measuring performance, you know it takes 12.34 seconds. Is this good
or bad? Without a feeling that tells you if it's slow or fast, the number
doesn't have a meaning. That's why I think that the feeling can also be
important.

:-)

This kind of feeling is OK, and it makes sense after you measured
performance.

But I can't have a feeling that a library is fast or slow without concrete
data.

I meant just that :)

Giovanni
 
Giovanni Dicanio said:
This kind of feeling is OK, and it makes sense after you measured
performance.

But I can't have a feeling that a library is fast or slow without
concrete data.

I meant just that :)

Like a "felt temperature", there is also a "felt duration". It sometimes
matters, too. ;-)


Armin
 
good or bad are relative terms. What you are comparing to?
Find alternatives to your approach and benchmark them.
 
Sheng Jiang said:
good or bad are relative terms. What you are comparing to?

Compare to what you expect. I think, Anna's expectation has been
disapointed, therefore she considered the current solution not good enough.
Find alternatives to your approach and benchmark them.

If you find a faster approach, it is better but you can still feel it is too
slow. That was my point. It was only about the feeling. Maybe you took it
too serious (watch the ":-)")


Armin
 
Back
Top