fast math in c++

fast math in c++

Post by Christoph Gaitzsc » Wed, 22 Apr 1998 04:00:00



Hi,

I'm new to this group, so sorry if this question is off-topic.

How can I do fast mathmatics in C++? I have to improve a program for simulation
which is coded in C. That program needs a GUI, so I want to recode it in C++. At
the moment I have to include the original C calculation routines, because C++,
so I was told, is not fast enough.

Is this true. Is there no way, like optimized math libraries etc. to get C++ as
fast as C?

Greetings, Christoph

 
 
 

fast math in c++

Post by Erik de Castro Lop » Thu, 23 Apr 1998 04:00:00



> Hi,

> I'm new to this group, so sorry if this question is off-topic.

> How can I do fast mathmatics in C++? I have to improve a program for simulation
> which is coded in C. That program needs a GUI, so I want to recode it in C++. At
> the moment I have to include the original C calculation routines, because C++,
> so I was told, is not fast enough.

> Is this true. Is there no way, like optimized math libraries etc. to get C++ as
> fast as C?

C is generally quicker than C++. The creation and destruction of C++
objects is an overhead which is usually best avoided. There is however
a project named Blitz++ which is attempting to improve this situation.
It uses C++ template techniques to generate highly optimesed assembly
language.

Have a look at:

        http://monet.uwaterloo.ca/blitz/

Erik

--
+-------------------------------------------------+

|       Linux  /  GNU  /  X-Windows  / GTK        |
+-------------------------------------------------+
"The worst thing about productivity tools is that
there's always something in them that makes you
less productive" - Chris Alfred Dec 15, 1997

 
 
 

fast math in c++

Post by Martin Kuchlmay » Sat, 25 Apr 1998 04:00:00



>Hi,
>I'm new to this group, so sorry if this question is off-topic.
>How can I do fast mathmatics in C++? I have to improve a program for simulation
>which is coded in C. That program needs a GUI, so I want to recode it in C++. At
>the moment I have to include the original C calculation routines, because C++,
>so I was told, is not fast enough.
>Is this true. Is there no way, like optimized math libraries etc. to get C++ as
>fast as C?

  I find this hard to beleive. The original calculation routines
should compile under c++ with little or no modifaction. Unless they do
something very unusual (for math routines it would have to be
something extermely unusual), they should produce almost identical
machine code. As far as I know, for example, if a structure and all
its compenets and subcomponents etc do not have a constructor declared
then no constructer will be called for that structure.
  Or do you mean you want to do a major rewrite (redesign) of the
calculation routines in a more object oriented manner? Even then I
would make a (very) uneducated guess that as long as you avoid doing
things in an object oriented way it critical places, they won't run
much slower.

  Also it is not essential to use c++ for a GUI although it may be a
good idea. (I am not very knowledgable about this area. Are motif or
qt c++ oriented?)

  You may want to ask about this on comp.lang.c++.moderated.

Quote:>Greetings, Christoph

Hope this helps, Martin
 
 
 

fast math in c++

Post by Tristan Wibberle » Sat, 02 May 1998 04:00:00



> >Hi,

> >I'm new to this group, so sorry if this question is off-topic.

> >How can I do fast mathmatics in C++? I have to improve a program for
simulation
> >which is coded in C. That program needs a GUI, so I want to recode it in
C++. At
> >the moment I have to include the original C calculation routines,
because C++,
> >so I was told, is not fast enough.

> >Is this true. Is there no way, like optimized math libraries etc. to get
C++ as
> >fast as C?

Can't you use the original C code and use external linkage: extern "C".
This will provide identical code for the math functions, but allow you to
use C++ for the GUI.

--
Vote Linus Torvalds, father of Linux a man of the century as a
builder and titan! Spread the word, spread it far. Let's contact
every Linux user out there to let them know to participate!
http://www.pathfinder.com/time/time100/time100poll.html

 
 
 

fast math in c++

Post by Dave Steffe » Sat, 02 May 1998 04:00:00




> > >Hi,

> > >I'm new to this group, so sorry if this question is off-topic.

> > >How can I do fast mathmatics in C++? I have to improve a program
> > >for simulation which is coded in C. That program needs a GUI, so
> > >I want to recode it in C++. At the moment I have to include the
> > >original C calculation routines, because C++, so I was told, is
> > >not fast enough.

> > >Is this true. Is there no way, like optimized math libraries
> > >etc. to get C++ as fast as C?

> Can't you use the original C code and use external linkage: extern "C".
> This will provide identical code for the math functions, but allow you to
> use C++ for the GUI.

        Indeed, C is (mostly) a subset of C++. So write the
mathematical stuff using the C subset of C++, and you're
set. Depending on the compiler, there may be some (small) run-time
penalites if you're using exceptions or rtti, but most compilers allow
you to turn those features off.

        Numerical work in C++ is actually a big topic;
<http://monet.uwaterloo.ca/oon/oonstd/> is a good place to start
looking.

--------------------------------------------------------------------------
Dave Steffen                      Wave after wave will flow with the tide
Dept. of Physics                    And bury the world as it does
Colorado State University         Tide after tide will flow and recede

                                                        - Peart / RUSH
"The reason that our people suffer in this way....
is that our ancestors failed to rule wisely".   -General Choi, Hong Hi

 
 
 

fast math in c++

Post by Geoffrey L. Brimhal » Tue, 05 May 1998 04:00:00


Another very good place to look is:

http://seurat.uwaterloo.ca/blitz/

Which has some of the fastest numerical codings for C++ available (they meet
or beat some fortran computational objects !).

 
 
 

1. Plug-Ins using C++

Hi folks,
        I hope I got the right forum for this: im a developer of a new
open-source project (http://threedsia.sourceforge.net) and have a problem
writing plug-ins:
Because we want to use mainly C++ as language I'd like to have C++ plug-ins, or
at least user C++ classes. While we already wrote some plug-ins with C and they
worked fine, I renamed a working plug-in from textonlyFrontEnd.c to *.cpp,
forcing make to use g++ as compiler. Compiles fine, but the resulting library
can't be accessed with dlsym... I already consulted what-ever-doc-I-could-find,
but I've not a suitable solution.
Thnx for any information,
        Marc Haisenko

2. Need help with KDE 3 and TightVNC

3. Suggestions for basic but very fast MP math machine...

4. ICQ

5. fast math library for Pentium?

6. opening a port

7. Version 0.21 of free fast math routines (libffm, preliminary version) now released !

8. Login Messages - HOWTO??

9. fast math libraries

10. Free fast math routines (libffm, preliminary version) being released !

11. A problem with using math.h in c++ under GCC

12. C / C++ math libraries

13. <math.h> and C++