Skip to content

Instantly share code, notes, and snippets.

@sverhoeven
Created October 2, 2020 09:36
Show Gist options
  • Save sverhoeven/3cb247ea186c77f9b7ba83a2a909883f to your computer and use it in GitHub Desktop.
Save sverhoeven/3cb247ea186c77f9b7ba83a2a909883f to your computer and use it in GitHub Desktop.
run-cpp-on-web: vega
const initial_guess = -4;
const tolerance = 0.001;
const newtonraphson = new NewtonRaphson(tolerance);
newtonraphson.solve(initial_guess);
// newtonraphson.iterations is a vector object, which is not
// consumeable by Vega, so we need to convert Emscripten's
// vector of objects to a JavaScript array of objects first
const iterations = new Array(
newtonraphson.iterations.size()
).fill().map(
(_, iteration) => {
return newtonraphson.iterations.get(iteration)
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment