numpy 2.0.0
src/multiarray/dtype_transfer.c File Reference
#include "Python.h"
#include "structmember.h"
#include <numpy/ndarrayobject.h>
#include <numpy/ufuncobject.h>
#include <numpy/npy_cpu.h>
#include "lowlevel_strided_loops.h"

Data Structures

struct  _strided_zero_pad_data
struct  _align_wrap_data
struct  _wrap_copy_swap_data
struct  _strided_cast_data
struct  _one_to_n_data
struct  _n_to_n_data
struct  _subarray_broadcast_offsetrun
struct  _subarray_broadcast_data
struct  _single_field_transfer
struct  _field_transfer_data
struct  _dst_memset_zero_data

Defines

#define PY_SSIZE_T_CLEAN
#define _MULTIARRAYMODULE
#define NPY_LOWLEVEL_BUFFER_BLOCKSIZE   128
#define NPY_DT_DBG_TRACING   0
#define NPY_DT_REF_DBG_TRACING   0
#define NPY_DT_DBG_REFTRACE(msg, ref)

Typedefs

typedef void(* free_strided_transfer_data )(void *)
typedef void *(* copy_strided_transfer_data )(void *)

Functions

static int get_decsrcref_transfer_function (int aligned, npy_intp src_stride, PyArray_Descr *src_dtype, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api)
static int get_setdstzero_transfer_function (int aligned, npy_intp dst_stride, PyArray_Descr *dst_dtype, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api)
NPY_NO_EXPORT int get_bool_setdstone_transfer_function (npy_intp dst_stride, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *NPY_UNUSED(out_needs_api))
static void _strided_to_strided_move_references (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp src_itemsize, void *data)
static void _strided_to_strided_copy_references (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp src_itemsize, void *data)
void * _strided_zero_pad_data_copy (void *data)
static void _strided_to_strided_zero_pad_copy (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp src_itemsize, void *data)
static void _strided_to_strided_truncate_copy (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp src_itemsize, void *data)
NPY_NO_EXPORT int PyArray_GetStridedZeroPadCopyFn (int aligned, npy_intp src_stride, npy_intp dst_stride, npy_intp src_itemsize, npy_intp dst_itemsize, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata)
void _align_wrap_data_free (void *data)
void * _align_wrap_data_copy (void *data)
static void _strided_to_strided_contig_align_wrap (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp src_itemsize, void *data)
static void _strided_to_strided_contig_align_wrap_init_dest (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp src_itemsize, void *data)
NPY_NO_EXPORT int wrap_aligned_contig_transfer_function (npy_intp src_itemsize, npy_intp dst_itemsize, PyArray_StridedTransferFn *tobuffer, void *todata, PyArray_StridedTransferFn *frombuffer, void *fromdata, PyArray_StridedTransferFn *wrapped, void *wrappeddata, int init_dest, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata)
void _wrap_copy_swap_data_free (void *data)
void * _wrap_copy_swap_data_copy (void *data)
static void _strided_to_strided_wrap_copy_swap (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp NPY_UNUSED(src_itemsize), void *data)
static int wrap_copy_swap_function (int aligned, npy_intp src_stride, npy_intp dst_stride, PyArray_Descr *dtype, int should_swap, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata)
void _strided_cast_data_free (void *data)
void * _strided_cast_data_copy (void *data)
static void _aligned_strided_to_strided_cast (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp src_itemsize, void *data)
static void _aligned_strided_to_strided_cast_decref_src (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp src_itemsize, void *data)
static void _aligned_contig_to_contig_cast (char *dst, npy_intp NPY_UNUSED(dst_stride), char *src, npy_intp NPY_UNUSED(src_stride), npy_intp N, npy_intp NPY_UNUSED(itemsize), void *data)
static int get_nbo_cast_numeric_transfer_function (int aligned, npy_intp src_stride, npy_intp dst_stride, int src_type_num, int dst_type_num, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata)
static int get_nbo_cast_transfer_function (int aligned, npy_intp src_stride, npy_intp dst_stride, PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype, int move_references, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api, int *out_needs_wrap)
static int get_cast_transfer_function (int aligned, npy_intp src_stride, npy_intp dst_stride, PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype, int move_references, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api)
void _one_to_n_data_free (void *data)
void * _one_to_n_data_copy (void *data)
static void _strided_to_strided_one_to_n (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp src_itemsize, void *data)
static void _strided_to_strided_one_to_n_with_finish (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp src_itemsize, void *data)
static int wrap_transfer_function_one_to_n (PyArray_StridedTransferFn *stransfer_inner, void *data_inner, PyArray_StridedTransferFn *stransfer_finish_src, void *data_finish_src, npy_intp dst_itemsize, npy_intp N, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata)
static int get_one_to_n_transfer_function (int aligned, npy_intp src_stride, npy_intp dst_stride, PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype, int move_references, npy_intp N, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api)
void _n_to_n_data_free (void *data)
void * _n_to_n_data_copy (void *data)
static void _strided_to_strided_n_to_n (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp src_itemsize, void *data)
static void _contig_to_contig_n_to_n (char *dst, npy_intp NPY_UNUSED(dst_stride), char *src, npy_intp NPY_UNUSED(src_stride), npy_intp N, npy_intp NPY_UNUSED(src_itemsize), void *data)
static int wrap_transfer_function_n_to_n (PyArray_StridedTransferFn *stransfer_inner, void *data_inner, npy_intp src_stride, npy_intp dst_stride, npy_intp src_itemsize, npy_intp dst_itemsize, npy_intp N, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata)
static int get_n_to_n_transfer_function (int aligned, npy_intp src_stride, npy_intp dst_stride, PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype, int move_references, npy_intp N, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api)
void _subarray_broadcast_data_free (void *data)
void * _subarray_broadcast_data_copy (void *data)
static void _strided_to_strided_subarray_broadcast (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp NPY_UNUSED(src_itemsize), void *data)
static void _strided_to_strided_subarray_broadcast_withrefs (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp NPY_UNUSED(src_itemsize), void *data)
static int get_subarray_broadcast_transfer_function (int aligned, npy_intp src_stride, npy_intp dst_stride, PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype, npy_intp src_size, npy_intp dst_size, PyArray_Dims src_shape, PyArray_Dims dst_shape, int move_references, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api)
static int get_subarray_transfer_function (int aligned, npy_intp src_stride, npy_intp dst_stride, PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype, int move_references, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api)
void _field_transfer_data_free (void *data)
void * _field_transfer_data_copy (void *data)
static void _strided_to_strided_field_transfer (char *dst, npy_intp dst_stride, char *src, npy_intp src_stride, npy_intp N, npy_intp NPY_UNUSED(src_itemsize), void *data)
static int get_fields_transfer_function (int aligned, npy_intp src_stride, npy_intp dst_stride, PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype, int move_references, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api)
static int get_decsrcref_fields_transfer_function (int aligned, npy_intp src_stride, PyArray_Descr *src_dtype, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api)
static int get_setdestzero_fields_transfer_function (int aligned, npy_intp dst_stride, PyArray_Descr *dst_dtype, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api)
static void _null_to_strided_set_bool_one (char *dst, npy_intp dst_stride, char *NPY_UNUSED(src), npy_intp NPY_UNUSED(src_stride), npy_intp N, npy_intp NPY_UNUSED(src_itemsize), void *NPY_UNUSED(data))
static void _null_to_contig_set_bool_one (char *dst, npy_intp NPY_UNUSED(dst_stride), char *NPY_UNUSED(src), npy_intp NPY_UNUSED(src_stride), npy_intp N, npy_intp NPY_UNUSED(src_itemsize), void *NPY_UNUSED(data))
void * _dst_memset_zero_data_copy (void *data)
static void _null_to_strided_memset_zero (char *dst, npy_intp dst_stride, char *NPY_UNUSED(src), npy_intp NPY_UNUSED(src_stride), npy_intp N, npy_intp NPY_UNUSED(src_itemsize), void *data)
static void _null_to_contig_memset_zero (char *dst, npy_intp dst_stride, char *NPY_UNUSED(src), npy_intp NPY_UNUSED(src_stride), npy_intp N, npy_intp NPY_UNUSED(src_itemsize), void *data)
static void _null_to_strided_reference_setzero (char *dst, npy_intp dst_stride, char *NPY_UNUSED(src), npy_intp NPY_UNUSED(src_stride), npy_intp N, npy_intp NPY_UNUSED(src_itemsize), void *NPY_UNUSED(data))
static void _dec_src_ref_nop (char *NPY_UNUSED(dst), npy_intp NPY_UNUSED(dst_stride), char *NPY_UNUSED(src), npy_intp NPY_UNUSED(src_stride), npy_intp NPY_UNUSED(N), npy_intp NPY_UNUSED(src_itemsize), void *NPY_UNUSED(data))
static void _strided_to_null_dec_src_ref_reference (char *NPY_UNUSED(dst), npy_intp NPY_UNUSED(dst_stride), char *src, npy_intp src_stride, npy_intp N, npy_intp NPY_UNUSED(src_itemsize), void *NPY_UNUSED(data))
NPY_NO_EXPORT int PyArray_GetDTypeTransferFunction (int aligned, npy_intp src_stride, npy_intp dst_stride, PyArray_Descr *src_dtype, PyArray_Descr *dst_dtype, int move_references, PyArray_StridedTransferFn **out_stransfer, void **out_transferdata, int *out_needs_api)

Define Documentation

#define _MULTIARRAYMODULE
#define NPY_DT_DBG_REFTRACE (   msg,
  ref 
)

Referenced by wrap_copy_swap_function().

#define NPY_DT_DBG_TRACING   0
**** PRINTF DEBUG TRACING *********
#define NPY_DT_REF_DBG_TRACING   0
Tracing incref/decref can be very noisy
#define NPY_LOWLEVEL_BUFFER_BLOCKSIZE   128

Referenced by _align_wrap_data_copy().

#define PY_SSIZE_T_CLEAN

Typedef Documentation

typedef void*(* copy_strided_transfer_data)(void *)
typedef void(* free_strided_transfer_data)(void *)
******************** ZERO-PADDED COPY *************************

Function Documentation

void* _align_wrap_data_copy ( void *  data)
transfer data copy function

Round up the structure size to 16-byte boundary
Add space for two low level buffers
Allocate the data, and populate it

References NPY_LOWLEVEL_BUFFER_BLOCKSIZE.

static void _aligned_contig_to_contig_cast ( char *  dst,
npy_intp   NPY_UNUSEDdst_stride,
char *  src,
npy_intp   NPY_UNUSEDsrc_stride,
npy_intp  N,
npy_intp   NPY_UNUSEDitemsize,
void *  data 
) [static]
static void _aligned_strided_to_strided_cast ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp  src_itemsize,
void *  data 
) [static]
static void _aligned_strided_to_strided_cast_decref_src ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp  src_itemsize,
void *  data 
) [static]
This one requires src be of type NPY_OBJECT

After casting, decrement the source ref

static void _dec_src_ref_nop ( char *  NPY_UNUSEDdst,
npy_intp   NPY_UNUSEDdst_stride,
char *  NPY_UNUSEDsrc,
npy_intp   NPY_UNUSEDsrc_stride,
npy_intp   NPY_UNUSEDN,
npy_intp   NPY_UNUSEDsrc_itemsize,
void *  NPY_UNUSEDdata 
) [static]

NOP

Referenced by _null_to_strided_set_bool_one().

void* _dst_memset_zero_data_copy ( void *  data)
zero-padded data copy function

References get_cast_transfer_function(), and NPY_NTYPES.

void* _field_transfer_data_copy ( void *  data)
transfer data copy function

Allocate the data and populate it
Copy all the fields transfer data

References _field_transfer_data_free(), _PyArray_Descr::fields, _PyArray_Descr::names, NPY_FAIL, PyArray_free, PyArray_FreeStridedTransferData(), PyArray_malloc, and PyDataType_REFCHK.

void _field_transfer_data_free ( void *  data)
transfer data free function

Referenced by _field_transfer_data_copy().

void* _n_to_n_data_copy ( void *  data)
transfer data copy function

Allocate the data, and populate it

void _n_to_n_data_free ( void *  data)
transfer data free function

References _subarray_broadcast_data::data, PyArray_free, and PyArray_FreeStridedTransferData().

static void _null_to_contig_memset_zero ( char *  dst,
npy_intp  dst_stride,
char *  NPY_UNUSEDsrc,
npy_intp   NPY_UNUSEDsrc_stride,
npy_intp  N,
npy_intp   NPY_UNUSEDsrc_itemsize,
void *  data 
) [static]
static void _null_to_contig_set_bool_one ( char *  dst,
npy_intp   NPY_UNUSEDdst_stride,
char *  NPY_UNUSEDsrc,
npy_intp   NPY_UNUSEDsrc_stride,
npy_intp  N,
npy_intp   NPY_UNUSEDsrc_itemsize,
void *  NPY_UNUSEDdata 
) [static]

bool type is one byte, so can just use the char

static void _null_to_strided_memset_zero ( char *  dst,
npy_intp  dst_stride,
char *  NPY_UNUSEDsrc,
npy_intp   NPY_UNUSEDsrc_stride,
npy_intp  N,
npy_intp   NPY_UNUSEDsrc_itemsize,
void *  data 
) [static]
static void _null_to_strided_reference_setzero ( char *  dst,
npy_intp  dst_stride,
char *  NPY_UNUSEDsrc,
npy_intp   NPY_UNUSEDsrc_stride,
npy_intp  N,
npy_intp   NPY_UNUSEDsrc_itemsize,
void *  NPY_UNUSEDdata 
) [static]

Release the reference in dst
Set it to zero

static void _null_to_strided_set_bool_one ( char *  dst,
npy_intp  dst_stride,
char *  NPY_UNUSEDsrc,
npy_intp   NPY_UNUSEDsrc_stride,
npy_intp  N,
npy_intp   NPY_UNUSEDsrc_itemsize,
void *  NPY_UNUSEDdata 
) [static]
******************* DEST BOOL SETONE **************************

bool type is one byte, so can just use the char

References _dec_src_ref_nop(), _PyArray_Descr::elsize, get_decsrcref_transfer_function(), and NPY_SUCCEED.

void* _one_to_n_data_copy ( void *  data)
transfer data copy function

Allocate the data, and populate it

void _one_to_n_data_free ( void *  data)
transfer data free function
void* _strided_cast_data_copy ( void *  data)
strided cast data copy function

References _PyArray_Descr::elsize, PyTypeNum_ISNUMBER, and _PyArray_Descr::type_num.

void _strided_cast_data_free ( void *  data)
strided cast data free function

References NPY_FAIL.

static void _strided_to_null_dec_src_ref_reference ( char *  NPY_UNUSEDdst,
npy_intp   NPY_UNUSEDdst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp   NPY_UNUSEDsrc_itemsize,
void *  NPY_UNUSEDdata 
) [static]

Release the reference in src

static void _strided_to_strided_contig_align_wrap ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp  src_itemsize,
void *  data 
) [static]
static void _strided_to_strided_contig_align_wrap_init_dest ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp  src_itemsize,
void *  data 
) [static]

References NPY_FAIL.

static void _strided_to_strided_copy_references ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp  src_itemsize,
void *  data 
) [static]
Copies references from src to dst

Release the reference in dst
Copy the reference
Claim the reference

static void _strided_to_strided_field_transfer ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp   NPY_UNUSEDsrc_itemsize,
void *  data 
) [static]

Do the transfer a block at a time

static void _strided_to_strided_move_references ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp  src_itemsize,
void *  data 
) [static]
********************* COPY REFERENCES **************************
Moves references from src to dst

Release the reference in dst
Move the reference
Set the source reference to NULL

static void _strided_to_strided_n_to_n ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp  src_itemsize,
void *  data 
) [static]
static void _strided_to_strided_one_to_n ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp  src_itemsize,
void *  data 
) [static]
static void _strided_to_strided_one_to_n_with_finish ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp  src_itemsize,
void *  data 
) [static]
static void _strided_to_strided_subarray_broadcast ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp   NPY_UNUSEDsrc_itemsize,
void *  data 
) [static]
static void _strided_to_strided_subarray_broadcast_withrefs ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp   NPY_UNUSEDsrc_itemsize,
void *  data 
) [static]
static void _strided_to_strided_truncate_copy ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp  src_itemsize,
void *  data 
) [static]
Does a strided to strided zero-padded copy for the case where dst_itemsize < src_itemsize

Referenced by _strided_to_strided_zero_pad_copy().

static void _strided_to_strided_wrap_copy_swap ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp   NPY_UNUSEDsrc_itemsize,
void *  data 
) [static]
static void _strided_to_strided_zero_pad_copy ( char *  dst,
npy_intp  dst_stride,
char *  src,
npy_intp  src_stride,
npy_intp  N,
npy_intp  src_itemsize,
void *  data 
) [static]
void* _strided_zero_pad_data_copy ( void *  data)
zero-padded data copy function

Referenced by _strided_to_strided_zero_pad_copy().

void* _subarray_broadcast_data_copy ( void *  data)
transfer data copy function

Allocate the data and populate it

References PyArray_Dims::len, and PyArray_Dims::ptr.

Referenced by get_n_to_n_transfer_function().

void _subarray_broadcast_data_free ( void *  data)
transfer data free function

Referenced by get_n_to_n_transfer_function().

void* _wrap_copy_swap_data_copy ( void *  data)
wrap copy swap data copy function
void _wrap_copy_swap_data_free ( void *  data)
wrap copy swap data free function
NPY_NO_EXPORT int get_bool_setdstone_transfer_function ( npy_intp  dst_stride,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  NPY_UNUSEDout_needs_api 
)
Returns a transfer function which sets a boolean type to ones.
Returns NPY_SUCCEED or NPY_FAIL.
Only for the bool type, sets the destination to 1
static int get_cast_transfer_function ( int  aligned,
npy_intp  src_stride,
npy_intp  dst_stride,
PyArray_Descr src_dtype,
PyArray_Descr dst_dtype,
int  move_references,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api 
) [static]

If all native byte order and doesn't need alignment wrapping, return the function
Otherwise, we have to copy and/or swap to aligned temporaries
Get the copy/swap operation from src
If it's a custom data type, wrap its copy swap function
A straight copy
If it's not complex, one swap
If complex, a paired swap
Get the copy/swap operation to dst
If it's a custom data type, wrap its copy swap function
A straight copy
If it's not complex, one swap
If complex, a paired swap
Wrap it all up in a new transfer function + data

Referenced by _dst_memset_zero_data_copy().

static int get_decsrcref_fields_transfer_function ( int  aligned,
npy_intp  src_stride,
PyArray_Descr src_dtype,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api 
) [static]

Allocate the data and populate it

NPY_NO_EXPORT int get_decsrcref_transfer_function ( int  aligned,
npy_intp  src_stride,
PyArray_Descr src_dtype,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api 
) [static]
System Message: ERROR/3 (<string>, line 1) Document or section may not begin with a transition.

System Message: ERROR/3 (<string>, line 1) Document may not end with a transition.
Returns a transfer function which DECREFs any references in src_type.
Returns NPY_SUCCEED or NPY_FAIL.

If there are no references, it's a nop
If it's a single reference, it's one decref
If there are subarrays, need to wrap it
Get a function for contiguous src of the subarray type
If there are fields, need to do each field

Referenced by _null_to_strided_set_bool_one().

static int get_fields_transfer_function ( int  aligned,
npy_intp  src_stride,
npy_intp  dst_stride,
PyArray_Descr src_dtype,
PyArray_Descr dst_dtype,
int  move_references,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api 
) [static]
Handles fields transfer. To call this, at least one of the dtypes must have fields

Copy the src value to all the fields of dst
Allocate the data and populate it
If the references should be removed from src, add another transfer function to do that.
Copy the value of the first field to dst
If DECREF is needed on source fields, may need to process all the fields
Allocate the data and populate it
Special case bool type, the existence of fields implies True

TODO: Perhaps a better behavior would be to combine all the
input fields with an OR? The same would apply to subarrays.
If the src field has references, may need to clear them
Transfer the first field to the output
If the references should be removed from src, add more transfer functions to decrement the references for all the other fields.
Match up the fields to copy
Keeps track of the names we already used
If DECREF is needed on source fields, will need to also go through its fields.
Allocate the data and populate it
Use field_count to track additional functions added

static int get_n_to_n_transfer_function ( int  aligned,
npy_intp  src_stride,
npy_intp  dst_stride,
PyArray_Descr src_dtype,
PyArray_Descr dst_dtype,
int  move_references,
npy_intp  N,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api 
) [static]
static int get_nbo_cast_numeric_transfer_function ( int  aligned,
npy_intp  src_stride,
npy_intp  dst_stride,
int  src_type_num,
int  dst_type_num,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata 
) [static]

Emit a warning if complex imaginary is being cast away

static int get_nbo_cast_transfer_function ( int  aligned,
npy_intp  src_stride,
npy_intp  dst_stride,
PyArray_Descr src_dtype,
PyArray_Descr dst_dtype,
int  move_references,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api,
int *  out_needs_wrap 
) [static]

Check the data types whose casting functions use API calls
Get the cast function
Allocate the data for the casting
TODO: This is a hack so the cast functions have an array.
The cast functions shouldn't need that. Also, since we always handle byte order conversions, this array should have native byte order.
TODO: This is a hack so the cast functions have an array.
The cast functions shouldn't need that. Also, since we always handle byte order conversions, this array should have native byte order.
If it's aligned and all native byte order, we're all done
Use the contig version if the strides are contiguous or we're telling the caller to wrap the return, because the wrapping uses a contiguous buffer.

References _aligned_contig_to_contig_cast().

static int get_one_to_n_transfer_function ( int  aligned,
npy_intp  src_stride,
npy_intp  dst_stride,
PyArray_Descr src_dtype,
PyArray_Descr dst_dtype,
int  move_references,
npy_intp  N,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api 
) [static]

move_references is set to 0, handled in the wrapping transfer fn, src_stride is set to zero, because its 1 to N copying, and dst_stride is set to contiguous, because subarrays are always contiguous.
If the src object will need a DECREF, set src_dtype

References NPY_FAIL.

static int get_setdestzero_fields_transfer_function ( int  aligned,
npy_intp  dst_stride,
PyArray_Descr dst_dtype,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api 
) [static]

Allocate the data and populate it

NPY_NO_EXPORT int get_setdstzero_transfer_function ( int  aligned,
npy_intp  dst_stride,
PyArray_Descr dst_dtype,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api 
) [static]
Returns a transfer function which zeros out the dest values.
Returns NPY_SUCCEED or NPY_FAIL.

If there are no references, just set the whole thing to zero
If it's exactly one reference, use the decref function
If there are subarrays, need to wrap it
Get a function for contiguous dst of the subarray type
If there are fields, need to do each field

static int get_subarray_broadcast_transfer_function ( int  aligned,
npy_intp  src_stride,
npy_intp  dst_stride,
PyArray_Descr src_dtype,
PyArray_Descr dst_dtype,
npy_intp  src_size,
npy_intp  dst_size,
PyArray_Dims  src_shape,
PyArray_Dims  dst_shape,
int  move_references,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api 
) [static]

Allocate the data and populate it
move_references is set to 0, handled in the wrapping transfer fn, src_stride and dst_stride are set to contiguous, as N will always be 1 when it's called.
If the src object will need a DECREF
If the dst object needs a DECREF to set it to NULL
Calculate the broadcasting and set the offsets
Get the dst coord of this index for dimension i
Translate it into a src coord and update src_index
Out of bounds, flag with -1
Set the offset
Run-length encode the result
Stop the run when there's a valid index again
Stop the run when there's a valid index again
Multiply all the offsets by the src item size

static int get_subarray_transfer_function ( int  aligned,
npy_intp  src_stride,
npy_intp  dst_stride,
PyArray_Descr src_dtype,
PyArray_Descr dst_dtype,
int  move_references,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api 
) [static]
Handles subarray transfer. To call this, at least one of the dtype's subarrays must be non-NULL

Get the subarray shapes and sizes
Just a straight one-element copy.
Copy the src value to all the dst values
If the shapes match exactly, do an n to n copy
Copy the subarray with broadcasting, truncating, and zero-padding as necessary.

References PyArray_FreeStridedTransferData().

NPY_NO_EXPORT int PyArray_GetDTypeTransferFunction ( int  aligned,
npy_intp  src_stride,
npy_intp  dst_stride,
PyArray_Descr src_dtype,
PyArray_Descr dst_dtype,
int  move_references,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata,
int *  out_needs_api 
)
*************** MAIN DTYPE TRANSFER FUNCTION ******************

If one of the dtypes is NULL, we give back either a src decref function or a dst setzero function
Common special case - number -> number NBO cast
If there are no references and the data types are equivalent, return a simple copy
We can't pass through the aligned flag because it's not appropriate. Consider a size-8 string, it will say it's aligned because strings only need alignment 1, but the copy function wants to know if it's alignment 8.

TODO: Change align from a flag to a "best power of 2 alignment"
which holds the strongest alignment value for all the data which will be used.
First look at the possibilities of just a copy or swap
A custom data type requires that we use its copy/swap
If the sizes and kinds are identical, but they're different custom types, then get a cast function
The special types, which have no byte-order
This is a straight copy
This is a straight copy + byte swap
This is a straight copy + element pair byte swap
Handle subarrays
Handle fields
Check for different-sized strings, unicodes, or voids
Otherwise a cast is necessary

Referenced by _strided_to_strided_subarray_broadcast_withrefs(), and get_n_to_n_transfer_function().

NPY_NO_EXPORT int PyArray_GetStridedZeroPadCopyFn ( int  aligned,
npy_intp  src_stride,
npy_intp  dst_stride,
npy_intp  src_itemsize,
npy_intp  dst_itemsize,
PyArray_StridedTransferFn **  outstransfer,
void **  outtransferdata 
)
Gives back a transfer function and transfer data pair which copies the data from source to dest, truncating it if the data doesn't fit, and padding with zero bytes if there's too much space.
For information on the 'aligned', 'src_stride' and 'dst_stride' parameters see above.
Returns NPY_SUCCEED or NPY_FAIL
NPY_NO_EXPORT int wrap_aligned_contig_transfer_function ( npy_intp  src_itemsize,
npy_intp  dst_itemsize,
PyArray_StridedTransferFn tobuffer,
void *  todata,
PyArray_StridedTransferFn frombuffer,
void *  fromdata,
PyArray_StridedTransferFn wrapped,
void *  wrappeddata,
int  init_dest,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata 
)
Wraps an aligned contig to contig transfer function between either copies or byte swaps to temporary buffers.
src_itemsize/dst_itemsize - The sizes of the src and dst datatypes. tobuffer - copy/swap function from src to an aligned contiguous buffer. todata - data for tobuffer frombuffer - copy/swap function from an aligned contiguous buffer to dst. fromdata - data for frombuffer wrapped - contig to contig transfer function being wrapped wrappeddata - data for wrapped init_dest - 1 means to memset the dest buffer to 0 before calling wrapped.
Returns NPY_SUCCEED or NPY_FAIL.

Round up the structure size to 16-byte boundary
Add space for two low level buffers
Allocate the data, and populate it
Set the function and data

static int wrap_copy_swap_function ( int  aligned,
npy_intp  src_stride,
npy_intp  dst_stride,
PyArray_Descr dtype,
int  should_swap,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata 
) [static]
This only gets used for custom data types

Allocate the data for the copy swap
TODO: This is a hack so the copyswap functions have an array.
The copyswap functions shouldn't need that.

References _strided_cast_data::aip, _strided_cast_data::aop, _strided_cast_data::castfunc, and NPY_DT_DBG_REFTRACE.

static int wrap_transfer_function_n_to_n ( PyArray_StridedTransferFn stransfer_inner,
void *  data_inner,
npy_intp  src_stride,
npy_intp  dst_stride,
npy_intp  src_itemsize,
npy_intp  dst_itemsize,
npy_intp  N,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata 
) [static]
Wraps a transfer function to produce one that copies N contiguous elements of src to N contiguous elements of dst.

If the N subarray elements exactly fit in the strides, then can do a faster contiguous transfer.

References _subarray_broadcast_offsetrun::count, and _subarray_broadcast_offsetrun::offset.

static int wrap_transfer_function_one_to_n ( PyArray_StridedTransferFn stransfer_inner,
void *  data_inner,
PyArray_StridedTransferFn stransfer_finish_src,
void *  data_finish_src,
npy_intp  dst_itemsize,
npy_intp  N,
PyArray_StridedTransferFn **  out_stransfer,
void **  out_transferdata 
) [static]
Wraps a transfer function to produce one that copies one element of src to N contiguous elements of dst. If stransfer_finish_src is not NULL, it should be a transfer function which just affects src, for example to do a final DECREF operation for references.

References _contig_to_contig_n_to_n().