SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] irregularly spaced grids and imshowm: PATCH for bilinear interp

From: Michael D. <md...@st...> - 2008年08月29日 11:43:53
It's funny you should mention this.
One of the things I realized after SciPy this year is that there is a 
lot of interfacing of Numpy with C++ (as opposed to C) that could really 
benefit from a standard C++ wrapper around Numpy. A bunch of different 
projects all had home-grown, semi-complete solutions. 
A standard wrapper would be good for all of the reasons you mention 
(basically resource management), but also to have a cleaner syntax for 
accessing the elements that would abstract away striding, ordering etc. 
It may actually be possible to build it around boost::multiarray (the 
closest thing the upcoming C++-0x standard has to a n-dimensional array).
Can't imagine I'll find time for it anytime soon, but it would be fun to 
work on...
Cheers,
Mike
Christopher Barker wrote:
> Michael Droettboom wrote:
> 
>> I think we want to use std::vector where possible for new code, and 
>> convert as we go through old code. Manual malloc/free is just too error 
>> prone. (We're forced to do some by interfacing with Python, but it 
>> should be kept to a minimum).
>> 
>
> My understanding is that this is exactly the issue -- with std::vector 
> and friends you can't both get the data pointer and create a vector with 
> a data pointer, which would be what you'd want to do to interface 
> efficiently with numpy arrays.
>
> I've been looking for a way to address this problem, but my C++ is 
> pretty week. maybe smart pointers and/or other boost classes could help.
>
>
> I do have an idea, though. The goal is a set of classes for working with 
> data that are convenient to use with pure C++, but also play with numpy 
> arrays.
>
> I imagine a simple vector/array set of classes build on top of a simple 
> object: a reference counted data block. This data block object would 
> simply hold a pointer to a block of data, maybe know how large it is, 
> maybe know what type the data is, and hold a reference count. when that 
> count drops to zero it deletes itself.
>
> The vector/array classes built on top of it would use the data block to 
> store their data, and increment/decrement the reference count as need 
> be. This would allow them to share data, have one array that is a subset 
> of another, using the same data block, etc.
>
> It should be easy to build numpy arrays from a system like this.
>
> Ideally (but I'm not sure how), the data blocks reference counting 
> system could be integrated with Python's, so that when a numpy array was 
> constructed from one, its reference count would be managed by python as 
> well as your C++ code.
>
> But maybe that's all just too much work...
>
>
> -Chris
>
>
>
> 

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /