Esempio n. 1
0
        public static NumericOperations GetOperations(UFuncOperation operationType, NumericOperation operation, NpyArray srcArray, NpyArray destArray, NpyArray operandArray)
        {
            NumericOperations operations = new NumericOperations();

            operations.operationType = operationType;
            operations.operation     = operation;

            if (srcArray != null)
            {
                operations.srcHelper       = GetNumericOperationsHelper(srcArray);
                operations._ConvertOperand = DefaultArrayHandlers.GetArrayHandler(srcArray.ItemType).MathOpConvertOperand;
            }

            if (destArray != null)
            {
                operations.destHelper      = GetNumericOperationsHelper(destArray);
                operations.destItemType    = destArray.ItemType;
                operations.destTypeIsFloat = numpyinternal.NpyTypeNum_ISFLOAT(destArray.ItemType);
            }

            if (operandArray != null)
            {
                operations.operHelper = GetNumericOperationsHelper(operandArray);
                operations.IsSrcAndOperandSameType = srcArray.ItemType == operandArray.ItemType;
            }


            return(operations);
        }
Esempio n. 2
0
            public static ndarray outer(UFuncOperation ops, dtype dtype, object a, object b, ndarray @out = null, int?axis = null)
            {
                var a1 = np.asanyarray(a);
                var b1 = np.asanyarray(b);


                List <npy_intp> destdims = new List <npy_intp>();

                foreach (var dim in a1.shape.iDims)
                {
                    destdims.Add(dim);
                }
                foreach (var dim in b1.shape.iDims)
                {
                    destdims.Add(dim);
                }



                ndarray dest = @out;

                if (dest == null)
                {
                    dest = np.empty(new shape(destdims), dtype: dtype != null ? dtype : a1.Dtype);
                }

                return(NpyCoreApi.PerformOuterOp(a1, b1, dest, ops));
            }
Esempio n. 3
0
            internal static ndarray reduce(UFuncOperation ops, object a, int axis = 0, dtype dtype = null, ndarray @out = null, bool keepdims = false)
            {
                ndarray arr = asanyarray(a);

                if (arr == null)
                {
                    throw new ValueError("unable to convert a to ndarray");
                }

                NPY_TYPES rtype = dtype != null ? dtype.TypeNum : arr.TypeNum;

                return(NpyCoreApi.PerformReduceOp(arr, axis, ops, rtype, @out, keepdims));
            }
Esempio n. 4
0
            internal static ndarray reduceat(UFuncOperation ops, object a, object indices, int axis = 0, dtype dtype = null, ndarray @out = null)
            {
                ndarray arr = asanyarray(a);

                if (arr == null)
                {
                    throw new ValueError("unable to convert a to ndarray");
                }

                ndarray indicesarr = asanyarray(indices);

                if (indicesarr == null)
                {
                    throw new ValueError("unable to convert indices to ndarray");
                }

                NPY_TYPES rtype = dtype != null ? dtype.TypeNum : arr.TypeNum;

                return(NpyCoreApi.PerformReduceAtOp(arr, indicesarr, axis, ops, rtype, @out));
            }
Esempio n. 5
0
 internal static NpyArray NpyArray_PerformNumericOperation(UFuncOperation operationType, NpyArray x1Array, NpyArray x2Array, NpyArray outArray, NpyArray whereFilter)
 {
     return(numpyinternal.NpyArray_PerformNumericOperation(operationType, x1Array, x2Array, outArray, whereFilter));
 }
Esempio n. 6
0
 internal static NpyUFuncObject NpyArray_SetNumericOp(UFuncOperation op, NpyUFuncObject func)
 {
     return(numpyinternal.NpyArray_SetNumericOp(op, func));
 }
Esempio n. 7
0
 internal static NpyUFuncObject NpyArray_GetNumericOp(UFuncOperation op)
 {
     return(numpyinternal.NpyArray_GetNumericOp(op));
 }
Esempio n. 8
0
 public static ndarray outer(UFuncOperation operation, dtype dtype, object a, object b, ndarray @out = null, int?axis = null)
 {
     return(ufuncbase.outer(operation, dtype, a, b, @out, axis));
 }
Esempio n. 9
0
 public static ndarray reduceat(UFuncOperation operation, object a, object indices, int axis = 0, ndarray @out = null)
 {
     return(ufuncbase.reduceat(operation, a, indices, axis, null, @out));
 }
Esempio n. 10
0
 public static ndarray reduce(UFuncOperation operation, object a, int axis = 0, ndarray @out = null, bool keepdims = false)
 {
     return(ufuncbase.reduce(operation, a, axis, null, @out, keepdims));
 }
Esempio n. 11
0
 public static ndarray accumulate(UFuncOperation operation, object a, int axis = 0, ndarray @out = null)
 {
     return(ufuncbase.accumulate(operation, a, axis, null, @out));
 }