[C++-SIG] Re: blitz++ vs. NumPy?

Paul F. Dubois dubois1 at llnl.gov
Mon Dec 21 21:26:38 CET 1998


-----Original Message-----
From: Phil Austin <phil at geog.ubc.ca>
Newsgroups: comp.lang.python

>
>2) Two things I wasn't able to figure out in 20 minutes are:
>
>  a) How to add my Blitz-based Py::Array constructor to Paul's code
>     using inheritence.  It looks like:
>
>    explicit Array (blitz::Array<int,1> dimens, PyArray_TYPES t =
PyArray_DOUBLE)
>        : Sequence(FromAPI(PyArray_FromDims(dimens.size(), dimens.data(),
t))) {
>        validate();
>    }
>
>  b) Is there a general way to convert between a Blitz TinyVector of
>     length N (where N isn't known at compile time)
>     and a blitz::Array<int,1>?  I'd like to avoid specifying the
>     dimensions to the Py::Array and the blitz::Array separately.
>
a. In C++ certain things are not inherited. These include the constructors
and copy constructors, and I think the assignment operator. In the CXX
documentation it gives you a list in the comments of the ones you have to
reimplement in a child. So the answer to your question is that you have to
copy my functions and change their names appropriately and put them in your
"child". You make a new child BlitzArray and give it appropriate
constructors, assignment, and destructors. You might want to just use Array
as a sample rather than a parent so that you can carefully manage the "tied"
memory without worrying about what I'm doing in Array. Note that since
~Object is virtual, the destructors are called up the inheritance line after
yours is executed. So you are ADDING actions rather than replacing them.

b. I don't know much about Blitz in detail and can't answer this question.
But you might be needing a member function template here to instantiate
something for each needed size. Unfortunately, that is the one area that has
the most portability problems at the moment.






More information about the Cplusplus-sig mailing list