Giter Site home page Giter Site logo

Comments (1)

b-mare avatar b-mare commented on June 1, 2024 1

hi @cdhainaut

The way you provided the flattened arrays to underlying_function_3D to compute y_3d does not match how the interpolant function creates the grid.

This should work for your 3D example:

import numpy as np
from casadi import interpolant

x1 = np.linspace(0, 100, 2)
x2 = np.linspace(0, 5, 3)
x3 = np.linspace(0, 9, 4)

X1, X2, X3 = np.meshgrid(x1, x2, x3, indexing="ij")
y_3d = X1**2 + (X2 + 1) ** 2 + X3**2
y_3d_flat = y_3d.ravel(order='F')
X_3d = np.stack((X1.ravel("F"), X2.ravel("F"), X3.ravel("F")))

f_3d = interpolant(f"three_d", "linear", [x1, x2, x3], y_3d_flat)
y_i_3d = f_3d(X_3d)
np.testing.assert_allclose(y_3d_flat, np.array(y_i_3d)[0])

from casadi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.