[Numpy-discussion] Unexpected reorganization of internal data

Malcolm Reynolds malcolm.reynolds@gmail....
Tue Jan 31 08:14:14 CST 2012


Not exactly an answer to your question, but I can highly recommend
using Boost.python, PyUblas and Ublas for your C++ vectors and
matrices. It gives you a really good interface on the C++ side to
numpy arrays and matrices, which can be passed in both directions over
the language threshold with no copying.

If I had to guess I'd say sometimes when transposing numpy simply sets
a flag internally to avoid copying the data, but in some cases (such
as perhaps when multiplication needs to take place) the data has to be
placed in a new object. Accessing the data via raw pointers in C++ may
not be checking for the 'transpose' flag and therefore you see an
unexpected result.

Disclaimer: this is just a guess, someone more familiar with Numpy
internals will no doubt be able to correct me.

Malcolm


More information about the NumPy-Discussion mailing list