[C++-sig] numeric.hpp: copying raw data

Philip Austin paustin at eos.ubc.ca
Sat Oct 5 03:24:13 CEST 2002


Hi, we've been playing around with numeric.hpp and it's working well.
I'm uncertain, however, about the best way to move data from C to
python using numeric::array -- it looks like users with large arrays coming
from C need to bite the bullet and call import_libnumarray()?  I
wanted to check to make sure we aren't missing something before we
start implementing our own functions, like:

numeric::array ptrToNum(int* data, int n=0){
  NDInfo info;
  object obj(detail::new_reference(NA_Empty(1, &n, tInt32)));
  get_info(&obj, &info);
  memcpy(info.data, data, 4*n);
  return numeric::array(obj, "Int", n, false);
}

Regards, Phil Austin





More information about the Cplusplus-sig mailing list