weave.inline keeps recompling my C++ code (fwd)
Hi, I'm using weave.inline to compare the performance of weave with several other methods of doing the same calculation. It is simply a matrix multiplication: Z = sin(X)*cos(Y). I have attached my program for you to peruse. I am in general very impressed with the usability and performance of weave. I have two questions, however: 1) Why does it tell me 'repairing catalog by removing key' every single time I run this program using 'python tryweave.py'? I thought the idea was for scipy-weave to only have to recompile the C++ portions if the C++ source code changes. 2) How can I use the sin and cos functions with weave.blitz? Up until now, I have had to comment out the weave_blitz version because I can't figure out how to add cmath support to my blitz++ expression. FYI, my system is Debian Linux (Sarge/Testing branch). The Python prompt says: Python 2.3.5 (#2, Feb 9 2005, 00:38:15) [GCC 3.3.5 (Debian 1:3.3.5-8)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
Cheers, Curtis
Curtis Cooper wrote:
Hi,
I'm using weave.inline to compare the performance of weave with several other methods of doing the same calculation. It is simply a matrix multiplication: Z = sin(X)*cos(Y). I have attached my program for you to peruse. I am in general very impressed with the usability and performance of weave. I have two questions, however:
1) Why does it tell me 'repairing catalog by removing key' every single time I run this program using 'python tryweave.py'? I thought the idea was for scipy-weave to only have to recompile the C++ portions if the C++ source code changes.
I think this is a bug in weave.inline. Incidentally, I ran into it just today, and also when trying to use some C code which called sin/cos. I may have a look at the weave code to fix it, but I can't make any promises as to when. weave is not quite trivial, and the last time I fixed something there, it took a bit of effort just to wrap my head around enough of the code to understand what to look for. If you can fix it quicker, by all means send a patch.
2) How can I use the sin and cos functions with weave.blitz? Up until now, I have had to comment out the weave_blitz version because I can't figure out how to add cmath support to my blitz++ expression.
You need to make sure that the math.h header is included, and that libm is linked in. Here's a trivial (scalar) example: def sinC(x): """sinC(x) -> sin(x). Implemented using the C sin() function. """ support = \ """ #include <math.h> """ code = \ """ return_val = sin(x); """ return inline(code,['x'], type_converters = converters.blitz, support_code = support, libraries = ['m'], ) Once you do those two things, your looping example with sin(X(i,j)) should work just fine. best, f
participants (2)
-
Curtis Cooper
-
Fernando Perez