Hallo!
> * A new ARGOUTVIEW suite of typemaps is provided that allows your
> wrapped function
>to provide a pointer to internal data and that returns a numpy
> array encapsulating
>it.
Thanks for integrating it !
> * New typemaps are provided that correctly handle FORTRAN ordered 2D
The numpy array is created using PyArray_SimpleNewFromData(). From
the Guide to NumPy, "[y]ou should ensure that the provided memory is
not freed while the returned array is in existence." That is, numpy
does not try to deallocate the memory when the ndarray object is
destroyed, but it al
On Nov 30, 2007 5:16 AM, Bill Spotz <[EMAIL PROTECTED]> wrote:
> I have just committed the latest version of numpy.i (a swig interface
> file for bridging between C arrays and numerical python) to the numpy
> svn repository. There are three relatively new features that are now
> supported:
>
> * I
I have just committed the latest version of numpy.i (a swig interface
file for bridging between C arrays and numerical python) to the numpy
svn repository. There are three relatively new features that are now
supported:
* It is now possible to wrap functions that expect integer arguments
Bill Spotz wrote:
> First, my plan is to add to numpy.i, typemaps for signatures like the
> following:
>
> %typemap(argout) (double** ARGOUT_ARRAY1, int* DIM1)
>
> It is important to note that even though the same argument *names*
> are used, this is a different typemap signature than
>
Hallo!
> First, my plan is to add to numpy.i, typemaps for signatures like the
> following:
>
> %typemap(argout) (double** ARGOUT_ARRAY1, int* DIM1)
>
> It is important to note that even though the same argument *names* are
> used, this is a different typemap signature than
>
> %typem
OK, I'm going to try to get to this soon, but I want to discuss the
interface some before committing to development.
First, my plan is to add to numpy.i, typemaps for signatures like the
following:
%typemap(argout) (double** ARGOUT_ARRAY1, int* DIM1)
It is important to note that even th
On Nov 21, 2007, at 10:07 AM, Georg Holzmann wrote:
> BTW: what is the difference between PyArray_SimpleNewFromData() and
> PyArray_FromDimsAndData() ?
> (I don't have this book ...)
PyArray_SimpleNewFromData() is the new version and
PyArray_FromDimsAndData() is the old version :-)
Travis ma
Georg Holzmann wrote:
> As chris said, I need to make an example:
> http://grh.mur.at/software/numpy2carray.tar.gz
Ah, I see now:
/// @return internal big data without copying
void getBigData(double **mtx, int *rows, int *cols)
{
*rows = drows; *cols = dcols;
*mtx = very_big_da
Hallo!
As chris said, I need to make an example:
http://grh.mur.at/software/numpy2carray.tar.gz
I added the following class-example:
class_example.h: the C++ code
class_example.i: the SWIG interface file
class_example_usage.py: example usage in python
And some comments:
Bill Spotz schrieb:
> H
David.Goldsmith wrote:
> Chris, just to be clear, this is addressed to the OP, correct?
yes, but if anyone else want to come up with one, that would work too.
-Chris
>> What would be great is a simple trimmed down example -- a
>> small-as-you-can-make-it class with a method that shows what you
Chris, just to be clear, this is addressed to the OP, correct?
DG
Christopher Barker wrote:
> I'm a bit confused too.
>
> What would be great is a simple trimmed down example -- a
> small-as-you-can-make-it class with a method that shows what you need,
> perhaps with a little C++ sample that us
Christopher Barker wrote:
> What would be great is a simple trimmed down example --
.. and then we'd have an example to put in the numpy.i docs and
examples, too.
By the way Bill, I haven't forgotten the examples I said I'd add to the
docs. I've been distracted away from my SWIG work lately,
I'm a bit confused too.
What would be great is a simple trimmed down example -- a
small-as-you-can-make-it class with a method that shows what you need,
perhaps with a little C++ sample that uses it. Then we can see how best
to wrap it for python.
-Chris
--
Christopher Barker, Ph.D.
Oceano
Here is what I am proposing you do: in your interface file, add
something like
PyObject * getMatrix()
{
npy_intp dims[2] = { /* Obtain the dimensions to your
internal matrix */ };
double * data = /* Obtain the pointer to you internal matrix
*/;
return PyA
Hallo!
> OK, so the key here is the *internal* matrix. I think you need to
> provide a way to extract that matrix from the C++ application as a numpy
> array. Then you can provide it to your function/method as an INPLACE
> array. No new memory will be allocated.
[...]
> The INPLACE typemaps
Bill Spotz wrote:
>> Again, see above for my use case.
>> But the fortran ordering should not be that hard (only setting the
>> flags
>> and strides right, as in FARRAY2_OUT in numpy2carray.i) - but of
>> course
>> someone has to do it ... ;)
>>
>
> Yes, it shouldn't be too hard. And I li
On Nov 20, 2007, at 7:24 AM, Georg Holzmann wrote:
> Yes but this means that you again allocate an array of the same size.
> E.g. in my algorithm I can have a very big internal matrix in C++
OK, so the key here is the *internal* matrix. I think you need to
provide a way to extract that matrix
>
> > Of course : http://matt.eifelle.com/item/5
> > It's a basic version of the wrapper I use in my lab (pay attention to
> > the constructor for instance), I hope you will be able to do something
>
> Thanks !
> But this assumes that the data in my C++ library is stored in a
> PyArrayObject ?
Y
Hallo!
> Is there any doc on numpy.i usage?
yes there is a pdf in /numpy/doc/swig !
LG
Georg
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
Hallo!
> Of course : http://matt.eifelle.com/item/5
> It's a basic version of the wrapper I use in my lab (pay attention to
> the constructor for instance), I hope you will be able to do something
Thanks !
But this assumes that the data in my C++ library is stored in a
PyArrayObject ?
This is
>
> > If what you want is to provide a view from your C++ matrix, this is
> > different. You must either :
> > - propose the array interface
> > - use a Python object inside your C++ matrix (this is to be done, I've a
> > basic example in my blog)
>
Of course : http://matt.eifelle.com/item/5
It's
Christopher Barker wrote:
>
>
> Georg Holzmann wrote:
>> Because I had some troubles in wrapping my C++ library in python/numpy,
>> I did (another) numpy2carray.i file for SWIG.
>
> How is this better/different than numpy.i in:
>
> numpy/doc/swig/numpy.i
>
>> With that interface file it is po
Hallo!
> E.g. in my algorithm I can have a very big internal matrix in C++ (say
> 700 MB - in fortran style). Now I want to have this matrix in numpy to
> plot some parts of it, get some data out of it ... whatever - if I again
> allocate an array of the same size, I am out of memo
2007/11/20, Georg Holzmann <[EMAIL PROTECTED]>:
>
> Hallo!
>
> > Really? I worked pretty hard to avoid copies when they were not
> > necessary. For the ARGOUT typemaps, I allocate an array of the
> > requested size and then pass its data buffer to your function. If
>
> Yes but this means that yo
Hallo!
> Really? I worked pretty hard to avoid copies when they were not
> necessary. For the ARGOUT typemaps, I allocate an array of the
> requested size and then pass its data buffer to your function. If
Yes but this means that you again allocate an array of the same size.
E.g. in my a
On Nov 20, 2007, at 1:12 AM, Georg Holzmann wrote:
> The problem I had with numpy.i:
>
> - it copies the arrays on output (Argout Arrays) which was not
> possible
> for my algorithms (I have some very big matrices)
Really? I worked pretty hard to avoid copies when they were not
necessary. F
Georg Holzmann wrote:
>>> (I also included an example for an interface to
>>> fortran style arrays).
>>>
>> That, it doesn't have.
>> It has ;) ... look in numpy2carray.i, FARRAY2_OUT (line 175).
>> But yes, sorry, I did no example in example.cpp ...
>>
I'm pretty sure Chris meant that
Hallo!
> How is this better/different than numpy.i in:
>
> numpy/doc/swig/numpy.i
The problem I had with numpy.i:
- it copies the arrays on output (Argout Arrays) which was not possible
for my algorithms (I have some very big matrices)
- it is not possible to 2D or 3D Argout Arrays (why?), in
Georg Holzmann wrote:
> Because I had some troubles in wrapping my C++ library in python/numpy,
> I did (another) numpy2carray.i file for SWIG.
How is this better/different than numpy.i in:
numpy/doc/swig/numpy.i
> With that interface file it is possible to input/output arrays with or
> with
Hallo!
Because I had some troubles in wrapping my C++ library in python/numpy,
I did (another) numpy2carray.i file for SWIG.
With that interface file it is possible to input/output arrays with or
without copying data (I also included an example for an interface to
fortran style arrays).
I am s
31 matches
Mail list logo