Skip to content

Add indexing of arrays? #3

@federkamm

Description

@federkamm

Hi,

this library looks promising, but I couldn't even get my first example running (I use 0.4.1 installed with pip in Python 3.9).

I have a function u, v = f(x, y) from two real variables to two real variables and tried to get its Jacobian matix J at x, y = 0., 0.. I would have expected I could simply do:

import auto_diff, numpy

def helper(z):
    u, v = f(z[0], z[1])
    return numpy.array([u, v])

z = numpy.zeros(2)
with auto_diff.AutoDiff(z) as Z:
    helper_eval = helper(Z)
    w, J = auto_diff.get_value_and_jacobian(helper_eval)

but it fails since Z is not indexable in the call of helper(Z). I would have expect to get a similar interface in Z as z has itself in order to allow Z to be a replacement for z in most cases. Do I do something wrong? Should Z implement indexing in order to allow to differentiate functions that use indexing?

Thank you for your answer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions