|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
interfacing function of a complex numberHello,
I created a function with complex numbers in python and now I'd like to compile it in swig to speed it all up by creating a function of the type double complex c2(x). But when I want to compile it with setup.py it is creating the following error: python setup.py build_ext --inplace running build_ext building '_test' extension gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c test_wrap.c -o build/temp.linux-i686-2.6/test_wrap.o test_wrap.c:2514: erreur: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c2’ test_wrap.c: In function ‘_wrap_c2’: test_wrap.c:2569: erreur: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘result’ test_wrap.c:2569: erreur: ‘result’ undeclared (first use in this function) test_wrap.c:2569: erreur: (Each undeclared identifier is reported only once test_wrap.c:2569: erreur: for each function it appears in.) test_wrap.c:2577: erreur: expected ‘)’ before ‘complex’ test_wrap.c:2577: attention : implicit declaration of function ‘c2’ test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ test_wrap.c:2578: erreur: valeur de pointeur utilisée là où une valeur à virgule flottante était attendue test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ test_wrap.c:2578: erreur: incompatible type for argument 1 of ‘memcpy’ test_wrap.c:2578: erreur: valeur de pointeur utilisée là où une valeur à virgule flottante était attendue test_wrap.c:2578: erreur: incompatible type for argument 1 of ‘SWIG_Python_NewPointerObj’ error: command 'gcc' failed with exit status 1 The strangest thing for me is that the first error is that he can't handle the complex argument, as line 2514 is : extern double complex c2(double x); So what am I doing wrong ? I already tested what happend if I skip the complex argument. Then everything is compiling fine but python is failing with an segmentation fault. I included complex and everything else is straight-forward. I attach the concerned files for test issues Would be great If someone could help me. Bye, Fred ***** test.i ******* /* test.i */ %module test %{ /* Put header files here or function declarations like below */ extern double complex c2(double x); %} extern double complex c2(double x); ********** test.c ********** #include <math.h> #include <complex.h> double complex c2(double x) { double complex ph = I*x; return cexp(x); } **** setup.py ***** #!/usr/bin/env python """ setup.py file for fast correlation library """ from distutils.core import setup, Extension from Cython.Distutils import build_ext test_module = Extension('_test', sources=['test_wrap.c', 'test.c'], ) setup (name = 'Test', version = '0.1', author = "Fred Jendrzejewski", description = """Propagating fields around""", ext_modules = [test_module], py_modules = ["test"], ) ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
|
|
Re: interfacing function of a complex numberAs far as I know, support for the "double complex" datatype isn't even
supported by Swig unless someone has patched it to support C99. That said, it may be the case that the C compiler itself doesn't support it unless certain compiler flags are enabled. You might want to check the options to gcc to see if there is some kind of compiler flag that needs to be turned on to support the double complex datatype. Cheers, Dave On Sep 23, 2009, at 12:36 PM, Fred Jendrzejewski wrote: > Hello, > > I created a function with complex numbers in python and now I'd like > to > compile it in swig to speed it all up by creating a function of the > type > double complex c2(x). > > But when I want to compile it with setup.py it is creating the > following > error: > > python setup.py build_ext --inplace > running build_ext > building '_test' extension > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall > -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c test_wrap.c -o > build/temp.linux-i686-2.6/test_wrap.o > test_wrap.c:2514: erreur: expected ‘=’, ‘,’, ‘;’, ‘asm’ or > ‘__attribute__’ before ‘c2’ > test_wrap.c: In function ‘_wrap_c2’: > test_wrap.c:2569: erreur: expected ‘=’, ‘,’, ‘;’, ‘asm’ or > ‘__attribute__’ before ‘result’ > test_wrap.c:2569: erreur: ‘result’ undeclared (first use in this > function) > test_wrap.c:2569: erreur: (Each undeclared identifier is reported > only once > test_wrap.c:2569: erreur: for each function it appears in.) > test_wrap.c:2577: erreur: expected ‘)’ before ‘complex’ > test_wrap.c:2577: attention : implicit declaration of function ‘c2’ > test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ > test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ > test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ > test_wrap.c:2578: erreur: valeur de pointeur utilisée là où une > valeur à > virgule flottante était attendue > test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ > test_wrap.c:2578: erreur: incompatible type for argument 1 of ‘memcpy’ > test_wrap.c:2578: erreur: valeur de pointeur utilisée là où une > valeur à > virgule flottante était attendue > test_wrap.c:2578: erreur: incompatible type for argument 1 of > ‘SWIG_Python_NewPointerObj’ > error: command 'gcc' failed with exit status 1 > > The strangest thing for me is that the first error is that he can't > handle the complex argument, as line 2514 is : > > extern double complex c2(double x); > > > So what am I doing wrong ? I already tested what happend if I skip the > complex argument. Then everything is compiling fine but python is > failing with an segmentation fault. I included complex and everything > else is straight-forward. I attach the concerned files for test issues > > > Would be great If someone could help me. > > Bye, > Fred > > ***** test.i ******* > > > /* test.i */ > %module test > %{ > /* Put header files here or function declarations like below */ > extern double complex c2(double x); > %} > extern double complex c2(double x); > > ********** test.c ********** > > #include <math.h> > #include <complex.h> > > double complex c2(double x) { > double complex ph = I*x; > return cexp(x); > } > > > > **** setup.py ***** > > #!/usr/bin/env python > > """ > setup.py file for fast correlation library > """ > > from distutils.core import setup, Extension > from Cython.Distutils import build_ext > > > test_module = Extension('_test', > sources=['test_wrap.c', 'test.c'], > ) > > setup (name = 'Test', > version = '0.1', > author = "Fred Jendrzejewski", > description = """Propagating fields around""", > ext_modules = [test_module], > py_modules = ["test"], > ) > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart > your > developing skills, take BlackBerry mobile applications to market and > stay > ahead of the curve. Join us from November 9-12, 2009. Register > now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Swig-user mailing list > Swig-user@... > https://lists.sourceforge.net/lists/listinfo/swig-user ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
|
|
Re: interfacing function of a complex numberFred
I have done some work on interfacing complex numbers to ruby using Swig. From memory I used the C++ header <complex> instead of <complex.h>. I am away from base at the moment until the end of next week and cannot access my files on this until I am home. John ________________________________________ From: Fred Jendrzejewski [fred.jen@...] Sent: 23 September 2009 18:36 To: swig-user@... Subject: [Swig-user] interfacing function of a complex number Hello, I created a function with complex numbers in python and now I'd like to compile it in swig to speed it all up by creating a function of the type double complex c2(x). But when I want to compile it with setup.py it is creating the following error: python setup.py build_ext --inplace running build_ext building '_test' extension gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c test_wrap.c -o build/temp.linux-i686-2.6/test_wrap.o test_wrap.c:2514: erreur: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c2’ test_wrap.c: In function ‘_wrap_c2’: test_wrap.c:2569: erreur: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘result’ test_wrap.c:2569: erreur: ‘result’ undeclared (first use in this function) test_wrap.c:2569: erreur: (Each undeclared identifier is reported only once test_wrap.c:2569: erreur: for each function it appears in.) test_wrap.c:2577: erreur: expected ‘)’ before ‘complex’ test_wrap.c:2577: attention : implicit declaration of function ‘c2’ test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ test_wrap.c:2578: erreur: valeur de pointeur utilisée là où une valeur à virgule flottante était attendue test_wrap.c:2578: erreur: expected ‘)’ before ‘complex’ test_wrap.c:2578: erreur: incompatible type for argument 1 of ‘memcpy’ test_wrap.c:2578: erreur: valeur de pointeur utilisée là où une valeur à virgule flottante était attendue test_wrap.c:2578: erreur: incompatible type for argument 1 of ‘SWIG_Python_NewPointerObj’ error: command 'gcc' failed with exit status 1 The strangest thing for me is that the first error is that he can't handle the complex argument, as line 2514 is : extern double complex c2(double x); So what am I doing wrong ? I already tested what happend if I skip the complex argument. Then everything is compiling fine but python is failing with an segmentation fault. I included complex and everything else is straight-forward. I attach the concerned files for test issues Would be great If someone could help me. Bye, Fred ***** test.i ******* /* test.i */ %module test %{ /* Put header files here or function declarations like below */ extern double complex c2(double x); %} extern double complex c2(double x); ********** test.c ********** #include <math.h> #include <complex.h> double complex c2(double x) { double complex ph = I*x; return cexp(x); } **** setup.py ***** #!/usr/bin/env python """ setup.py file for fast correlation library """ from distutils.core import setup, Extension from Cython.Distutils import build_ext test_module = Extension('_test', sources=['test_wrap.c', 'test.c'], ) setup (name = 'Test', version = '0.1', author = "Fred Jendrzejewski", description = """Propagating fields around""", ext_modules = [test_module], py_modules = ["test"], ) ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
| Free embeddable forum powered by Nabble | Forum Help |