Hi all,

I have the following code fragment:

# Symbols
p,q,r = symbols('p q r')

# Input N by M by 3 Numpy array of floats
pts = np.array((N, M, 3))

# Output array of floats
djac = np.zeros((N, M))

# Points (floats)
pqrpts = np.array((M, 3))

# List of M polynomials as an fn of p,q,r
mpol = [get_poly(midx, p, q, r) for midx in xrange(M)]

# Want to compute
for nidx in xrange(N):
    # mvec is a vector as pts[nidx,midx] is a vector
    mvec = sum(mpol[midx]*pts[nidx,midx] for midx in xrange(M))
    dexp = Matrix(mvec).jacobian([p, q, r]).det()

    for midx in xrange(M):
        p,q,r = pqrpts[midx]
        djac[nidx,midx] = float(dexp.subs(dict(p=p,q=q,r=r)))

where N ~ 10^5, M ~ 27.  I wish to use autowrap so that I can instead write:

# Init code
...

for nidx in xrange(N):
    djac[nidx,:] = wraped_fn(pqrpts, pts[nidx])

While I am comfortable with using autowraps for simple scalar(s)-in and
scalar-out type expressions this is a bit more complicated.  Clearly it
will be necessary to move the mvec and dexp definitions outside the main
for loop using a M*3 array of dummy symbols (to be substituted for
pts[nidx]).  Similarly, mvec and dexp will no longer be single
expressions but will have to become vector/list expressions of length M.
 In addition we are now returning a numpy array/Python list.

Can someone sketch out the steps for accomplishing these things with
autowrap?

Regards, Freddie.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to