Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added member function to Real python bindings to enable numpy usage #268

Merged
merged 1 commit into from
Dec 1, 2022

Conversation

rath3t
Copy link
Contributor

@rath3t rath3t commented Dec 1, 2022

This enables the usages:

from autodiff import *
import numpy as np


def f(x_):
    y_ = np.array([7.0, 7.0])
    return np.sin(np.power(x_,3)) * y_


x = real(2)
x[1] = 1
y = 2
print("Double sol")
print(f(y))

z = f(x)
print("autodiff sol")
print(z)

which prints

Double sol
[6.92550773 6.92550773]
autodiff sol
[autodiff.real(6.92551, -12.222) autodiff.real(6.92551, -12.222)]

Before this lead to an error message similar to

TypeError: Unable to convert function return value to a Python type! The signature was (arg0: autodiff.autodiff4py.dual1st) -> autodiff::detail::UnaryExpr<autodiff::detail::CosOp, autodiff::detail::Dual<double, double> const&>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants