Topic: Fortran Math functions faster
Author: lincmad@netcom.com (Linc Madison)
Date: Wed, 13 Apr 1994 07:14:06 GMT Raw View
TOWNSEND S (l1rc@unb.ca) wrote:
: I am presently doing some multigrid routines under C++. I have been
: resently told that using fortran will yield a faster solution as it
: is designed for math functions.
[Please use a carriage return to keep lines under 80 characters.]
: First, is this true?
Most math functions will have essentially the same efficiency in either
language -- for example, x = sin(y) will map out to whatever your
machine does with sine functions (math coprocessor or some sort of
optimized library call, one would hope).
One of the few areas in which Fortran does have an advantage is that
most Fortran compilers will take the expressions X**2, X**3, and X**4,
and replace them with optimized exact computations of the square, cube,
and fourth power, for integer or real bases. In garden-variety C++, you
only have the pow(double,double) function, which uses a general
algorithm that is less efficient if the power is a small integer.
: Second, is it possible to call fortran function (compiled/uncompiled)
: into C++. Perhaps more specfically Borland's C++ for OS/2?
Well, in theory you should be able to use an ``extern "Fortran"''
statement, but I don't know if your compiler supports that.
-- Linc Madison * Oakland, California * LincMad@Netcom.com
Author: l1rc@unb.ca (TOWNSEND S)
Date: 12 Apr 1994 13:46:31 GMT Raw View
I am presently doing some multigrid routines under C++. I have been resently told that using fortran will yield a faster solution as it is designed for math functions.
First, is this true?
Second, is it possible to call fortran function (compiled/uncompiled) into C++. Perhaps more specfically Borland's C++ for OS/2?
---
Stephen
Team OS/2
======================================
Stephen F Townsend...
"I know things about pigeons." -Clint Eastwood,
[In the Line of Fire]
"To solve a problem: fix it, not the blame." -Sean Connery,
[Rising Sun]
======================================