MCPcopy Create free account
hub / github.com/numpy/numpy / npy_to_cdouble

Function npy_to_cdouble

numpy/core/src/multiarray/textreading/conversions.c:255–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253
254
255NPY_NO_EXPORT int
256npy_to_cdouble(PyArray_Descr *descr,
257 const Py_UCS4 *str, const Py_UCS4 *end, char *dataptr,
258 parser_config *pconfig)
259{
260 double real;
261 double imag;
262
263 bool success = to_complex_int(
264 str, end, &real, &imag, pconfig->imaginary_unit, true);
265
266 if (!success) {
267 return -1;
268 }
269 npy_complex128 val = {real, imag};
270 memcpy(dataptr, &val, sizeof(npy_complex128));
271 if (!PyArray_ISNBO(descr->byteorder)) {
272 npy_bswap8_unaligned(dataptr);
273 npy_bswap8_unaligned(dataptr + 8);
274 }
275 return 0;
276}
277
278
279/*

Callers

nothing calls this directly

Calls 2

to_complex_intFunction · 0.85
npy_bswap8_unalignedFunction · 0.85

Tested by

no test coverage detected