c_ndarray(a,
dtype=None,
ndim=None,
shape=None,
requirements=None)
| source code
|
Returns a ctypes structure of the array 'a' containing the arrays info
(data, shape, strides, ndim). A check is made to ensure that the array
has the specified dtype and requirements.
Example:
>>> myArray = np.arange(10.0)
>>> myCstruct = c_ndarray(myArray, dtype=np.double, ndim = 3, shape = (4,3,2),
... requirements = ['c_contiguous'])
- Parameters:
a (ndarray) - the numpy array to be converted
dtype (numpy dtype) - the required dtype of the array, convert if it doesn't match
ndim (integer) - the required number of axes of the array, complain if it doesn't
match
shape (tuple) - required shape of the array, complain if it doesn't match
requirements (list) - "ensurearray", "aligned",
"fortran", "f_contiguous", or
"c_contiguous". Convert if it doesn't match.
- Returns: ctypes structure
- ctypes structure with the fields:
-
data: pointer to the data : the type is determined with the
dtype of the array, and with ctypesDict.
-
shape: pointer to long array : size of each of the dimensions
-
strides: pointer to long array : strides in elements (not
bytes)
|