[Numpy-discussion] Scalar math module is ready for testing

Albert Strasheim fullung at gmail.com
Fri Apr 28 15:32:13 EDT 2006


Hello Travis

I'm having some problems compiling the scalarmath code with the Visual
Studio .NET 2003 compiler.

Specifically, the compiler is failing to link in the llabs, fabsf and sqrtf
functions. The reason it is not finding these symbols could be explained by
the following errors I get when building the object file by hand using the
parameters distutils passes to the compiler (for some reason distutils is
suppressing compiler output -- this is pretty, but it makes debugging build
failures hard):

build\src.win32-2.4\numpy\core\src\scalarmathmodule.c(1737) : warning C4013:
'llabs' undefined; assuming extern returning int
build\src.win32-2.4\numpy\core\src\scalarmathmodule.c(1751) : warning C4013:
'fabsf' undefined; assuming extern returning int
build\src.win32-2.4\numpy\core\src\scalarmathmodule.c(1773) : warning C4013:
'sqrtf' undefined; assuming extern returning int

In c:\Program Files\Microsoft Visual Studio .NET 2003\vc7\crt\src\math.h I
have the following (extra code stripped):

...
#ifndef __cplusplus
#define acosl(x)    ((long double)acos((double)(x)))
#define asinl(x)    ((long double)asin((double)(x)))
#define atanl(x)    ((long double)atan((double)(x)))
...
/* NOTE! no sqrtf or fabsf is defined in this block */
#else  /* __cplusplus */
...
#if !defined (_M_MRX000) && !defined (_M_ALPHA) && !defined (_M_IA64)
/* NOTE! none of the above are defined on x86 */
...
inline float fabsf(float _X)
        {return ((float)fabs((double)_X)); }
...
inline float sqrtf(float _X)
        {return ((float)sqrt((double)_X)); }
...
#endif  /* !defined (_M_MRX000) && !defined (_M_ALPHA) && !defined (_M_IA64)
*/
#endif  /* __cplusplus */

>From this it would seem that Microsoft doesn't consider sqrtf and fabsf to
be part of the C language? However, the C++ code provides a clue for how
they implemented it.

Also, llabs isn't defined anywhere. From reading the MSDN docs, I suspect it
is called _abs64 on Windows.

Regards,

Albert

> -----Original Message-----
> From: numpy-discussion-admin at lists.sourceforge.net [mailto:numpy-
> discussion-admin at lists.sourceforge.net] On Behalf Of Travis Oliphant
> Sent: 28 April 2006 09:13
> To: numpy-discussion
> Subject: [Numpy-discussion] Scalar math module is ready for testing
> 
> 
> The scalar math module is complete and ready to be tested.  It should
> speed up code that relies heavily on scalar arithmetic by by-passing the
> ufunc machinery.
> 
> It needs lots of testing to be sure that it is doing the "right"
> thing.   To enable scalarmath you need to
> 
> import numpy.core.scalarmath
> 
> You cannot disable it once it's enabled except by restarting Python.  If
> we need that feature we can add it. The array scalars respond to the
> error modes of ufuncs.
> 
> There is an experimental function called alter_scalars that replaces the
> Python int, float, and complex number tables with the array scalar
> equivalents.  Thus, to amaze (or seriously annoy) your Python friends
> you can do
> 
> import numpy.core.scalarmath as ncs
> 
> ncs.alter_scalars(int)
> 
> 1 / 0
> 
> This will return 0 unless you change the error modes...
> 
> ncs.retore_scalars(int)
> 
> Will put things back the way Guido intended....
> 
> 
> Please try it out and send us error reports.   Many thanks to Sasha for
> his help in getting all the code so it at least compiles and loads.  All
> bugs should be blamed on me, though...
> 
> 
> Best,
> 
> -Travis





More information about the NumPy-Discussion mailing list