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

In python spline.eval_jacobian(p) returns only the first column of the jacobian #136

Open
slovak194 opened this issue Feb 15, 2023 · 2 comments

Comments

@slovak194
Copy link

Hi!

I've noticed, that only first column of the jacobian is returned when I use python bindings (dev branch, or installed from PyPy).
I had to write my own simple bindings with pybind11 to overcome this issue.
Here is the small test:

import splinterpy
import numpy as np
from itertools import product
np.set_printoptions(suppress=True)


def some_fun(lx):
    return np.array((
        np.sin(lx[0] + lx[1]),
        np.cos(lx[0] - lx[1]),
        np.tan(lx[0]/lx[1])
    )).tolist()


domain = [
    np.linspace(-1, 1, 10),
    np.linspace(-1, 1, 10)
]

x = [list(xx) for xx in product(*domain)]
y = [some_fun(xx) for xx in x]

bspline = splinterpy.bspline_interpolator(x, y, degree=3)

p = np.array((0.7, -0.1))

print("\nbspline.eval:\n", bspline.eval(p))
print("\nbspline.eval_jacobian:\n", bspline.eval_jacobian(p))
bspline.eval:
 [0.5646270834036826, 0.696689837482913, 0.7350330225547118]
bspline.eval_jacobian:
 [[0.8253916603802878, -0.7172947275474233]]

So the bspline.eval_jacobian returns only 2 numbers.

Best regards,
Alex

@slovak194 slovak194 changed the title eval_jacobian returns only first column of the jacobian which is returned in C++ In python spline.eval_jacobian(p) returns only the first column of the jacobian Feb 15, 2023
@gablank
Copy link
Collaborator

gablank commented Feb 15, 2023

Hi Alex!

Thanks for the report! I'm a bit puzzled we haven't seen this earlier. I see that we have actually added a TODO about this issue:

# TODO: add support for self._dim_y > 1

I don't have the time to properly fix the issue now, but I've at the very least made it so that we no longer just return the wrong result with no mention about it being wrong: b0380aa

Thanks for the report! We'll hopefully be able to fix the bug properly soon!

@slovak194
Copy link
Author

Hi Anders,

Thanks for the report! We'll hopefully be able to fix the bug properly soon!
Glad to hear that!

Best regards,
Alex

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

No branches or pull requests

2 participants