Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
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? –  Szabolcs Feb 24 at 16:39
    
Yes, something like this. It needs to be efficient too, otherwise it will be useless. –  highsciguy Feb 24 at 17:14
    
I suspect that you are going to lose a lot on efficiency here. –  Szabolcs Feb 24 at 17:19
    
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? –  highsciguy Feb 25 at 10:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.