#include #include #include #include "libnumarray.h" #ifdef MS_WIN32 #pragma warning(once : 4244) #endif #define logical_and(arg1, arg2) (arg1 != 0) & (arg2 != 0) #define logical_or(arg1, arg2) (arg1 != 0) | (arg2 != 0) #define logical_xor(arg1, arg2) ((arg1 != 0) ^ (arg2 != 0)) & 1 #define ufmaximum(arg1, arg2) (((temp1=arg1) > (temp2=arg2)) ? temp1 : temp2) #define ufminimum(arg1, arg2) (((temp1=arg1) < (temp2=arg2)) ? temp1 : temp2) #define distance3d(x,y,z) sqrt(x*x + y*y + z*z) /********************* _distance3d *********************/ /********************* minus *********************/ static int minus_ixi_vxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 *tin0 = (Int32 *) buffers[0]; Int32 *tout0 = (Int32 *) buffers[1]; BEGIN_THREADS for (i=0; i 2147483647) temp = (Float64) int_overflow_error(2147483647.); if (temp < (-2147483648.)) temp = (Float64) int_overflow_error(-2147483648.); *tout0 = (Int32) temp; ++tin0; ++tout0; } END_THREADS return 0; } static CfuncDescriptor multiply_iixi_vsxv_descr = { "multiply_iixi_vsxv", (void *) multiply_iixi_vsxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Int32) }, { 0, 1, 0, 0 } }; static int multiply_iixi_vvxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 *tin0 = (Int32 *) buffers[0]; Int32 *tin1 = (Int32 *) buffers[1]; Int32 *tout0 = (Int32 *) buffers[2]; Float64 temp; BEGIN_THREADS for (i=0; i 2147483647) temp = (Float64) int_overflow_error(2147483647.); if (temp < (-2147483648.)) temp = (Float64) int_overflow_error(-2147483648.); *tout0 = (Int32) temp; ++tin0; ++tin1; ++tout0; } END_THREADS return 0; } static CfuncDescriptor multiply_iixi_vvxv_descr = { "multiply_iixi_vvxv", (void *) multiply_iixi_vvxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Int32) }, { 0, 0, 0, 0 } }; static void _multiply_ixi_R(long dim, long dummy, maybelong *niters, void *input, long inboffset, maybelong *inbstrides, void *output, long outboffset, maybelong *outbstrides) { long i; Int32 *tin0 = (Int32 *) ((char *) input + inboffset); Int32 *tout0 = (Int32 *) ((char *) output + outboffset); Int32 net; Float64 temp; if (dim == 0) { net = *tout0; for (i=1; i 2147483647) temp = (Float64) int_overflow_error(2147483647.); if (temp < (-2147483648.)) temp = (Float64) int_overflow_error(-2147483648.); net = (Int32) temp; } *tout0 = net; } else { for (i=0; i 2147483647) temp = (Float64) int_overflow_error(2147483647.); if (temp < (-2147483648.)) temp = (Float64) int_overflow_error(-2147483648.); *tout0 = (Int32) temp; } } else { for (i=0; i 2147483647) temp = (Float64) int_overflow_error(2147483647.); if (temp < (-2147483648.)) temp = (Float64) int_overflow_error(-2147483648.); *tout0 = (Int32) temp; ++tin1; ++tout0; } END_THREADS return 0; } static CfuncDescriptor multiply_iixi_svxv_descr = { "multiply_iixi_svxv", (void *) multiply_iixi_svxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Int32) }, { 1, 0, 0, 0 } }; /********************* multiply *********************/ /********************* multiply *********************/ /********************* multiply *********************/ /********************* multiply *********************/ /********************* divide *********************/ static int divide_iixi_vsxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 *tin0 = (Int32 *) buffers[0]; Int32 tin1 = *(Int32 *) buffers[1]; Int32 *tout0 = (Int32 *) buffers[2]; BEGIN_THREADS for (i=0; i tin1; ++tin0; ++tout0; } END_THREADS return 0; } static CfuncDescriptor greater_iixB_vsxv_descr = { "greater_iixB_vsxv", (void *) greater_iixB_vsxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Bool) }, { 0, 1, 0, 0 } }; static int greater_iixB_vvxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 *tin0 = (Int32 *) buffers[0]; Int32 *tin1 = (Int32 *) buffers[1]; Bool *tout0 = (Bool *) buffers[2]; BEGIN_THREADS for (i=0; i *tin1; ++tin0; ++tin1; ++tout0; } END_THREADS return 0; } static CfuncDescriptor greater_iixB_vvxv_descr = { "greater_iixB_vvxv", (void *) greater_iixB_vvxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Bool) }, { 0, 0, 0, 0 } }; static int greater_iixB_svxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 tin0 = *(Int32 *) buffers[0]; Int32 *tin1 = (Int32 *) buffers[1]; Bool *tout0 = (Bool *) buffers[2]; BEGIN_THREADS for (i=0; i *tin1; ++tin1; ++tout0; } END_THREADS return 0; } static CfuncDescriptor greater_iixB_svxv_descr = { "greater_iixB_svxv", (void *) greater_iixB_svxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Bool) }, { 1, 0, 0, 0 } }; /********************* greater_equal *********************/ static int greater_equal_iixB_vsxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 *tin0 = (Int32 *) buffers[0]; Int32 tin1 = *(Int32 *) buffers[1]; Bool *tout0 = (Bool *) buffers[2]; BEGIN_THREADS for (i=0; i= tin1; ++tin0; ++tout0; } END_THREADS return 0; } static CfuncDescriptor greater_equal_iixB_vsxv_descr = { "greater_equal_iixB_vsxv", (void *) greater_equal_iixB_vsxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Bool) }, { 0, 1, 0, 0 } }; static int greater_equal_iixB_vvxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 *tin0 = (Int32 *) buffers[0]; Int32 *tin1 = (Int32 *) buffers[1]; Bool *tout0 = (Bool *) buffers[2]; BEGIN_THREADS for (i=0; i= *tin1; ++tin0; ++tin1; ++tout0; } END_THREADS return 0; } static CfuncDescriptor greater_equal_iixB_vvxv_descr = { "greater_equal_iixB_vvxv", (void *) greater_equal_iixB_vvxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Bool) }, { 0, 0, 0, 0 } }; static int greater_equal_iixB_svxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 tin0 = *(Int32 *) buffers[0]; Int32 *tin1 = (Int32 *) buffers[1]; Bool *tout0 = (Bool *) buffers[2]; BEGIN_THREADS for (i=0; i= *tin1; ++tin1; ++tout0; } END_THREADS return 0; } static CfuncDescriptor greater_equal_iixB_svxv_descr = { "greater_equal_iixB_svxv", (void *) greater_equal_iixB_svxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Bool) }, { 1, 0, 0, 0 } }; /********************* less *********************/ static int less_iixB_vsxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 *tin0 = (Int32 *) buffers[0]; Int32 tin1 = *(Int32 *) buffers[1]; Bool *tout0 = (Bool *) buffers[2]; BEGIN_THREADS for (i=0; i> tin1; ++tin0; ++tout0; } END_THREADS return 0; } static CfuncDescriptor rshift_iixi_vsxv_descr = { "rshift_iixi_vsxv", (void *) rshift_iixi_vsxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Int32) }, { 0, 1, 0, 0 } }; static int rshift_iixi_vvxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 *tin0 = (Int32 *) buffers[0]; Int32 *tin1 = (Int32 *) buffers[1]; Int32 *tout0 = (Int32 *) buffers[2]; BEGIN_THREADS for (i=0; i> *tin1; ++tin0; ++tin1; ++tout0; } END_THREADS return 0; } static CfuncDescriptor rshift_iixi_vvxv_descr = { "rshift_iixi_vvxv", (void *) rshift_iixi_vvxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Int32) }, { 0, 0, 0, 0 } }; static int rshift_iixi_svxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 tin0 = *(Int32 *) buffers[0]; Int32 *tin1 = (Int32 *) buffers[1]; Int32 *tout0 = (Int32 *) buffers[2]; BEGIN_THREADS for (i=0; i> *tin1; ++tin1; ++tout0; } END_THREADS return 0; } static CfuncDescriptor rshift_iixi_svxv_descr = { "rshift_iixi_svxv", (void *) rshift_iixi_svxv, CFUNC_UFUNC, 0, CHECK_ALIGN, 2, 1, { sizeof(Int32), sizeof(Int32), sizeof(Int32) }, { 1, 0, 0, 0 } }; /********************* lshift *********************/ static int lshift_iixi_vsxv(long niter, long ninargs, long noutargs, void **buffers, long *bsizes) { long i; Int32 *tin0 = (Int32 *) buffers[0]; Int32 tin1 = *(Int32 *) buffers[1]; Int32 *tout0 = (Int32 *) buffers[2]; BEGIN_THREADS for (i=0; i