[Numpy-discussion] Dot in C extension
Charles R Harris
Sun May 25 01:12:55 CDT 2008
On Sat, May 24, 2008 at 11:29 PM, <email@example.com> wrote:
> Hi all,
> I'm trying to write a Gauss-Seidel function in C++. The function works
> however it is too slow because I'm not using any acceleration for the
> vector multiplication. I'm not really sure how to access the dot function
> in my extension, nor what all the arguments are for.
> Is this the right function to use (found in ndarrayobject.h):
> typedef void (PyArray_DotFunc)(void *, npy_intp, void *, npy_intp, void *,
> npy_intp, void *);
> I guess the voids are array objects, the two to be dotted and the output.
> What's the fourth?
It's ignored, so 0 (C++) should do.
@name@_dot(char *ip1, intp is1, char *ip2, intp is2, char *op, intp n,
register @out@ tmp=(@out@)0;
register intp i;
tmp += (@out@)(*((@type@ *)ip1)) * \
*((@type@ *)op) = (@type@) tmp;
Note that the function may call BLAS in practice, but you can figure the use
of the arguments from the above. Ignore the @type@ sort of stuff, it's
replaced by real types by the code generator.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion