Exemplo n.º 1
0
        internal static int SetIndex(VoidPtr data, npy_intp index, object invalue)
        {
            if (index < 0)
            {
                dynamic dyndatap = data.datap;
                index = dyndatap.Length - -index;
            }

            try
            {
                DefaultArrayHandlers.GetArrayHandler(data.type_num).SetIndex(data, index, invalue);
            }
            catch (System.OverflowException oe)
            {
                NpyErr_SetString(npyexc_type.NpyExc_OverflowError, oe.Message);
            }
            catch (Exception ex)
            {
                NpyErr_SetString(npyexc_type.NpyExc_ValueError, ex.Message);
            }

            return(1);
        }
Exemplo n.º 2
0
 internal static npy_intp NpyArray_ArgMaxFunc(VoidPtr ip, npy_intp startIndex, npy_intp endIndex)
 {
     return(DefaultArrayHandlers.GetArrayHandler(ip.type_num).ArgMax(ip.datap, startIndex, endIndex));
 }
Exemplo n.º 3
0
 private static int NpyArray_SortFuncTypeNum(VoidPtr data, int offset, int length)
 {
     DefaultArrayHandlers.GetArrayHandler(data.type_num).SortArray(data, offset, length);
     return(0);
 }
Exemplo n.º 4
0
 internal static IArrayHandlers GetArrayHandler(NPY_TYPES ItemType)
 {
     return(DefaultArrayHandlers.GetArrayHandler(ItemType));
 }
Exemplo n.º 5
0
        private static int GetTypeSize(NPY_TYPES type_num)
        {
            int ItemSize = 0;

            switch (type_num)
            {
            case NPY_TYPES.NPY_BOOL:
            {
                ItemSize = sizeof(bool);
                break;
            }

            case NPY_TYPES.NPY_BYTE:
            {
                ItemSize = sizeof(sbyte);
                break;
            }

            case NPY_TYPES.NPY_UBYTE:
            {
                ItemSize = sizeof(byte);
                break;
            }

            case NPY_TYPES.NPY_INT16:
            {
                ItemSize = sizeof(Int16);
                break;
            }

            case NPY_TYPES.NPY_UINT16:
            {
                ItemSize = sizeof(UInt16);
                break;
            }

            case NPY_TYPES.NPY_INT32:
            {
                ItemSize = sizeof(Int32);
                break;
            }

            case NPY_TYPES.NPY_UINT32:
            {
                ItemSize = sizeof(UInt32);
                break;
            }

            case NPY_TYPES.NPY_INT64:
            {
                ItemSize = sizeof(Int64);
                break;
            }

            case NPY_TYPES.NPY_UINT64:
            {
                ItemSize = sizeof(UInt64);
                break;
            }

            case NPY_TYPES.NPY_FLOAT:
            {
                ItemSize = sizeof(float);
                break;
            }

            case NPY_TYPES.NPY_DOUBLE:
            case NPY_TYPES.NPY_COMPLEXREAL:
            case NPY_TYPES.NPY_COMPLEXIMAG:
            {
                ItemSize = sizeof(double);
                break;
            }

            case NPY_TYPES.NPY_DECIMAL:
            {
                ItemSize = sizeof(decimal);
                break;
            }

            case NPY_TYPES.NPY_COMPLEX:
            {
                if (__ComplexSize < 0)
                {
                    __ComplexSize = DefaultArrayHandlers.GetArrayHandler(NPY_TYPES.NPY_COMPLEX).ItemSize;
                }
                ItemSize = __ComplexSize;
                break;
            }

            case NPY_TYPES.NPY_BIGINT:
            {
                if (__BigIntSize < 0)
                {
                    __BigIntSize = DefaultArrayHandlers.GetArrayHandler(NPY_TYPES.NPY_BIGINT).ItemSize;
                }
                ItemSize = __BigIntSize;
                break;
            }

            case NPY_TYPES.NPY_OBJECT:
            {
                if (__ObjectSize < 0)
                {
                    __ObjectSize = DefaultArrayHandlers.GetArrayHandler(NPY_TYPES.NPY_OBJECT).ItemSize;
                }
                ItemSize = __ObjectSize;
                break;
            }

            case NPY_TYPES.NPY_STRING:
            {
                if (__StringSize < 0)
                {
                    __StringSize = DefaultArrayHandlers.GetArrayHandler(NPY_TYPES.NPY_STRING).ItemSize;
                }
                ItemSize = __StringSize;
                break;
            }
            }

            return(ItemSize);
        }