The scipy document gives examples of Blitz++ style operations when using weave.blitz()
and C style indexing when using weave.inline()
. Does weave.inline()
also support Blitz++ style indexing and reductions. That will be very convenient. If weave.inline()
does indeed allow Blitz++ style indexing, could you tell me how to get a Blitz array from a numpy array in the weave.inline()
code. Much appreciated.
Here is an example, set the type_converter = weave.converters.blitz when calling weave.inline()
# -*- coding: utf-8 -*-
import scipy.weave as weave
import numpy as np
import time
def my_sum(a):
n=int(len(a))
code="""
int i;
double counter;
counter =0;
for(i=0;i<n;i++){
counter=counter+a(i);
}
return_val=counter;
"""
err=weave.inline(
code,
['a','n'],
type_converters=weave.converters.blitz,
compiler="gcc"
)
return err
a = np.arange(0, 10000000, 1.0)
print my_sum(a)