another seemingly unNumpyizeable routine

I hate to bother you guys, but this is how I learn. I have had some success using the take() and add.reduce() routines all by myself. However this one seems intractable: for IEdge in range(0,a.HybrdBoundEdgeNum): for JEdge in range(0,a.HybrdBoundEdgeNum): AVec[IEdge+a.TotInnerEdgeNum] += a.Cdd[IEdge,JEdge]*XVec[JEdge+a.TotInnerEdgeNum] ## below is my attempt at this, but it doesn't work ## h=a.TotInnerEdgeNum ## for IEdge in range(0,a.HybrdBoundEdgeNum): ## AVec[IEdge+h] = add.reduce(a.Cdd[IEdge,0:a.HybrdBoundEdgeNum] * XVec[h:(h+a.HybrdBoundEdgeNum)]) I think the problem lies in that add.reduce is using the slice 0:a.HybridBoundEdgeNum for Cdd, but then has to contend with XVec slice which is offset by h. Is there any elegant way to deal with this. This routine is part of a sparse matrix multiply routine. If I could find SparsePy, maybe I could eliminate it altogether. Thanks, Rob. -- The Numeric Python EM Project www.members.home.net/europax

I figured this out. I step JEdge instead of IEdge. Another big speed boost. Rob. Rob wrote:
I hate to bother you guys, but this is how I learn. I have had some success using the take() and add.reduce() routines all by myself. However this one seems intractable:
for IEdge in range(0,a.HybrdBoundEdgeNum): for JEdge in range(0,a.HybrdBoundEdgeNum): AVec[IEdge+a.TotInnerEdgeNum] += a.Cdd[IEdge,JEdge]*XVec[JEdge+a.TotInnerEdgeNum]
## below is my attempt at this, but it doesn't work ## h=a.TotInnerEdgeNum ## for IEdge in range(0,a.HybrdBoundEdgeNum): ## AVec[IEdge+h] = add.reduce(a.Cdd[IEdge,0:a.HybrdBoundEdgeNum] * XVec[h:(h+a.HybrdBoundEdgeNum)])
I think the problem lies in that add.reduce is using the slice 0:a.HybridBoundEdgeNum for Cdd, but then has to contend with XVec slice which is offset by h. Is there any elegant way to deal with this. This routine is part of a sparse matrix multiply routine. If I could find SparsePy, maybe I could eliminate it altogether.
Thanks, Rob.
-- The Numeric Python EM Project
www.members.home.net/europax
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
-- The Numeric Python EM Project www.members.home.net/europax
participants (1)
-
Rob