weave.md (1142B)
1 title: Weave stuff. (insanely obsolete) 2 3 4 # Accessing an array and its metadata through C/C++ in *scipy.weave.inline()* 5 6 * Accessing an array *foo* with *foo.ndim == 3*: 7 - The array itself will be accessable through the *FOO3(i, j, k)* function. 8 - Array assignments will be the same. *FOO3(i, j, k) = bar;* 9 - *foo.shape* will be accessable through the *Nfoo[]* array. 10 11 12 ## The inline code: 13 14 ~~~ { .cpp } 15 16 long dim1, dim2, dim3; 17 18 dim1 = Nfoo[0]; // dimension access. 19 dim2 = Nfoo[1]; 20 dim3 = Nfoo[2]; 21 22 FOO3(0,0,0) = 1; // array assignment 23 return_val = FOO3(0,0,0); // array access. 24 25 ~~~ 26 27 ## The Python code: 28 29 ~~~ { .python } 30 import scipy 31 import scipy.weave 32 inline_code = r""" 33 put C/C++ code in here 34 """ 35 foo = scipy.arange(3**3).reshape((3,3,3)) 36 scipy.weave.inline(inline_code, foo) 37 ~~~ 38 39 # Using Python functions in weave.inline 40 41 Call *foo.call(py:tuple arg)*. 42 43 # Links 44 45 * At Weave and Numpy array arguments: [Scipy's Weave page](http://www.scipy.org/Weave) 46 * [Calling Python functions from inline C with scipy.weave (stackoverflow)](http://stackoverflow.com/questions/5929600/calling-python-functions-from-inline-c-with-scipy-weave)