Created
October 25, 2018 05:38
-
-
Save chelseatroy/38c5b084cd4ffc6587d3bf2f2041fd0d to your computer and use it in GitHub Desktop.
Dot Products in Numpy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**begin repeat | |
* | |
* #name = BYTE, UBYTE, SHORT, USHORT, INT, UINT, | |
* LONG, ULONG, LONGLONG, ULONGLONG, | |
* FLOAT, DOUBLE, LONGDOUBLE, | |
* DATETIME, TIMEDELTA# | |
* #type = npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint, | |
* npy_long, npy_ulong, npy_longlong, npy_ulonglong, | |
* npy_float, npy_double, npy_longdouble, | |
* npy_datetime, npy_timedelta# | |
* #out = npy_long, npy_ulong, npy_long, npy_ulong, npy_long, npy_ulong, | |
* npy_long, npy_ulong, npy_longlong, npy_ulonglong, | |
* npy_float, npy_double, npy_longdouble, | |
* npy_datetime, npy_timedelta# | |
*/ | |
static void | |
@name@_dot(char *ip1, npy_intp is1, char *ip2, npy_intp is2, char *op, npy_intp n, | |
void *NPY_UNUSED(ignore)) | |
{ | |
@out@ tmp = (@out@)0; | |
npy_intp i; | |
for (i = 0; i < n; i++, ip1 += is1, ip2 += is2) { | |
tmp += (@out@)(*((@type@ *)ip1)) * | |
(@out@)(*((@type@ *)ip2)); | |
} | |
*((@type@ *)op) = (@type@) tmp; | |
} | |
/**end repeat**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment