[Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray <=> numpy.array typemap to share?

Christopher Barker Chris.Barker at noaa.gov
Mon Sep 17 16:24:27 EDT 2007


David Cournapeau wrote:
> Christopher Barker wrote:
>> My real question is what compiler and library writers are doing -- has 
>> anyone (OK, I guess MS and gcc are all I care about anyway) built 
>> anything optimized for them? Are they going to dump them? Who knows?
> What do you mean by optimization ? 

Well, I'm quite specifically not being precise about that. It appears 
the POINT of valarray was to provide a way to do computation that 
compiler(library) writers could optimize in various ways for the system 
at hand. The one example I have seen is someone that wrote a version 
that takes advantage of the PPC altivec instructions:

(http://www.pixelglow.com/stories/altivec-valarray-2/)

Anyway, at this point I'm far less concerned about optimization that 
just a more robust and convenient way to deal with data that raw pointers.

> I 
> remember having used blitz at some point, and I thought it was terrible. 

Darn -- it looks so promising.

> I think C++ is much more useful 
> for the automatic memory management through RAII, which is what 
> std::vector gives you.

and std::valarray not? I guess where I'm at now is deciding if there is 
any advantage or disadvantage to using std::valarray vs. std::vector. 
The other option is to go with something else: boost::multiarray, 
blitz++, etc. However, at least in term of how well they might p;lay 
with numpy arrays, I don't see a reason to do so.

> If your compiler supports restrict, use it 
> (http://www.cellperformance.com/mike_acton/2006/05/demystifying_the_restrict_keyw.html), 

Thanks for that link -- I'll keep that in mind. And now I finally think 
I understand what is meant by "aliased" pointer - which explains why, 
quite deliberately, you can't create a valarray from an existing pointer 
to a data block.

> The fact that, while C++ being a popular language, a standard class for 
> matrix algebra does not exist yet shows me that this is not that useful, 
> or too complicate to develop.

Could be. Personally, I'm not looking for matrix algebra, rather a 
generic nd-array class - but the argument is the same.

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list