Skip to content

Instantly share code, notes, and snippets.

@alphaville
Created June 4, 2019 19:41
Show Gist options
  • Select an option

  • Save alphaville/ca71548e1b1fdd0add63996fbe347811 to your computer and use it in GitHub Desktop.

Select an option

Save alphaville/ca71548e1b1fdd0add63996fbe347811 to your computer and use it in GitHub Desktop.
Compilation of auto-generated C file (C bindings to Rust code)
/* Compile with:
* gcc optimizer.c -l:libthe_optimizer.a -L./target/debug -pthread -lm -ldl -o optimizer -Wall
*/
#include <stdio.h>
#include "open_bindings.h"
int main() {
HomotopyCache * y = solver_new();
const double p[2] = {1.0, 10.0};
double u[5] = {0};
CHomotopySolverStatus status = solver_solve(y, u, p);
int i;
for (i=0; i<5; ++i) {
printf("u[%d] = %g\n", i, u[i]);
}
printf("exit status = %d\n", status.exit_status);
printf("iterations = %lu\n", status.num_inner_iterations);
printf("outer iterations = %lu\n", status.num_outer_iterations);
solver_free(y);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment