internal static void NpyArray_InitArrFuncs(NpyArray_ArrFuncs f) { int i; f.cast = null; f.getitem = null; f.setitem = null; f.copyswapn = null; f.copyswap = null; f.compare = null; f.argmax = null; f.dotfunc = null; f.scanfunc = null; f.fromstr = null; f.nonzero = null; f.fill = null; f.fillwithscalar = null; for (i = 0; i < npy_defs.NPY_NSORTS; i++) { f.sort[i] = null; f.argsort[i] = null; } f.castfuncs = null; f.scalarkind = null; f.cancastscalarkindto = null; f.cancastto = null; }
internal static NpyArray_ArrFuncs GetArrFuncs(NPY_TYPES type_num) { NpyArray_ArrFuncs arrFuncs = new NpyArray_ArrFuncs() { /// // Functions to get and set items with standard Python types // -- not array scalars // getitem = null, setitem = null, // // Function to compare items // Can be null // compare = NpyArray_CompareFunc, /// // Function to select largest // Can be null // argmax = NpyArray_ArgMaxFunc, /// // Function to select largest // Can be null // argmin = NpyArray_ArgMinFunc, // // Function to scan an ASCII file and // place a single value plus possible separator // Can be null // scanfunc = NpyArray_ScanFunc, /// // Function to read a single value from a string // and adjust the pointer; Can be null // fromstr = NpyArray_FromStrFunc, /// // Function to determine if data is zero or not // If null a default version is // used at Registration time. // nonzero = null, // // Used for arange. // Can be null. // fill = NpyArray_FillFunc, /// // Function to fill arrays with scalar values // Can be null // fillwithscalar = NpyArray_FillWithScalarFunc, // // Array of PyArray_CastFuncsItem given cast functions to // user defined types. The array it terminated with PyArray_NOTYPE. // Can be null. // castfuncs = new List <NpyArray_CastFuncsItem>(), // // Functions useful for generalizing // the casting rules. // Can be null; // scalarkind = NpyArray_ScalarKindFunc, cancastscalarkindto = null, cancastto = null, }; switch (type_num) { case NPY_TYPES.NPY_BOOL: arrFuncs.getitem = BOOL_GetItemFunc; arrFuncs.setitem = BOOL_SetItemFunc; break; case NPY_TYPES.NPY_BYTE: arrFuncs.getitem = BYTE_GetItemFunc; arrFuncs.setitem = BYTE_SetItemFunc; break; case NPY_TYPES.NPY_UBYTE: arrFuncs.getitem = UBYTE_GetItemFunc; arrFuncs.setitem = UBYTE_SetItemFunc; break; case NPY_TYPES.NPY_INT16: arrFuncs.getitem = INT16_GetItemFunc; arrFuncs.setitem = INT16_SetItemFunc; break; case NPY_TYPES.NPY_UINT16: arrFuncs.getitem = UINT16_GetItemFunc; arrFuncs.setitem = UINT16_SetItemFunc; break; case NPY_TYPES.NPY_INT32: arrFuncs.getitem = INT32_GetItemFunc; arrFuncs.setitem = INT32_SetItemFunc; break; case NPY_TYPES.NPY_UINT32: arrFuncs.getitem = UINT32_GetItemFunc; arrFuncs.setitem = UINT32_SetItemFunc; arrFuncs.setitem = UINT32_SetItemFunc; break; case NPY_TYPES.NPY_INT64: arrFuncs.getitem = INT64_GetItemFunc; arrFuncs.setitem = INT64_SetItemFunc; break; case NPY_TYPES.NPY_UINT64: arrFuncs.getitem = UINT64_GetItemFunc; arrFuncs.setitem = UINT64_SetItemFunc; break; case NPY_TYPES.NPY_FLOAT: arrFuncs.getitem = FLOAT_GetItemFunc; arrFuncs.setitem = FLOAT_SetItemFunc; break; case NPY_TYPES.NPY_DOUBLE: case NPY_TYPES.NPY_COMPLEXREAL: case NPY_TYPES.NPY_COMPLEXIMAG: arrFuncs.getitem = DOUBLE_GetItemFunc; arrFuncs.setitem = DOUBLE_SetItemFunc; break; case NPY_TYPES.NPY_DECIMAL: arrFuncs.getitem = DECIMAL_GetItemFunc; arrFuncs.setitem = DECIMAL_SetItemFunc; break; case NPY_TYPES.NPY_COMPLEX: arrFuncs.getitem = COMPLEX_GetItemFunc; arrFuncs.setitem = COMPLEX_SetItemFunc; break; case NPY_TYPES.NPY_BIGINT: arrFuncs.getitem = BIGINT_GetItemFunc; arrFuncs.setitem = BIGINT_SetItemFunc; break; case NPY_TYPES.NPY_OBJECT: arrFuncs.getitem = OBJECT_GetItemFunc; arrFuncs.setitem = OBJECT_SetItemFunc; break; case NPY_TYPES.NPY_STRING: arrFuncs.getitem = STRING_GetItemFunc; arrFuncs.setitem = STRING_SetItemFunc; break; default: arrFuncs.getitem = NpyArray_GetItemFunc; arrFuncs.setitem = NpyArray_SetItemFunc; break; } for (int i = 0; i < arrFuncs.cast.Length; i++) { arrFuncs.cast[i] = CastFunctions.DefaultCastFunction; } for (int i = 0; i < arrFuncs.sort.Length; i++) { arrFuncs.sort[i] = NpyArray_SortFunc; } for (int i = 0; i < arrFuncs.argsort.Length; i++) { arrFuncs.argsort[i] = NpyArray_ArgSortFunc; } return(arrFuncs); }
internal static void NpyArray_InitArrFuncs(NpyArray_ArrFuncs f) { numpyinternal.NpyArray_InitArrFuncs(f); }