I wonder if I can benefit from the Mathematica numerical quadrature routines in a way which integrates completely into an existing C-program. To be more specific I have C-program which does numerical quadrature using C-libraries like GSL (Gnu Scientific Library). These library functions are used by initializing data structures and running quadrature routines which take pointers to C-functions representing the the integrand and a pointer to a parameter structure which is fed to the integrand function as second parameter. Finally the data structures are freed. There is a set of functions for various kinds of integrands, but obviously there are some routines in Mathematica which are not implemented in the GSL. I wonder now if it is worth attempting to write wrapper functions for NIntegrate using MathLink such that I can use Mathematicas integration routines in just the same way as I would use C-library functions. Maybe there are MathLink examples out there which come close to what I want to achieve?

  • $\begingroup$ So what you need is this: call MathKernel from a C program in a way that MathKernel can call back to C to evaluate the function to be integrated. Is this correct? $\endgroup$ – Szabolcs Feb 24 '14 at 16:39
  • $\begingroup$ Yes, something like this. It needs to be efficient too, otherwise it will be useless. $\endgroup$ – highsciguy Feb 24 '14 at 17:14
  • $\begingroup$ I suspect that you are going to lose a lot on efficiency here. $\endgroup$ – Szabolcs Feb 24 '14 at 17:19
  • $\begingroup$ That would be bad. Is there any other option apart from MathLink to use NIntegrate in a C-code? For instance, can the Compile function help me? $\endgroup$ – highsciguy Feb 25 '14 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.