LibraryLink`
LibraryLink`

MTensor_getComplexData (C Function)

gets an array of the data elements of an MTensor of complex type.

Details

  • Used in C/C++ code in a library function called from the Wolfram Language.
  • The array has a length equal to the flattened length.
  • An error will occur if the tensor is not a complex MTensor.

Examples

Basic Examples  (1)

This iterates over the data elements of an MTensor to do an in-place conjugation:

MTensor T0;
mcomplex* z;
mint i, len;
...
len = libData->MTensor_getFlattenedLength( T0);
data = libData->MTensor_getRealData( T0);
for (i = 0; i < len; i++) {
mcimag(z[i]) = -mcimag(z[i]);
}