Double Numerical Integration in C++ - c++

I am looking for a good way to compute a double integral numerically using pre-written C++ libraries. The basic integral I'm dealing with is this:
I've done some research and discovered a few libraries that might be useful, however I'm not sure which one to choose based on the problem I'm dealing with. The libraries I have looked at are
GSL - The problem here is it's written in C and so I would have to
find some kind of wrapper to make it compatible with my research
codes.
Cuba - This library seems very appropriate and well documented.
However I would like to avoid importing an entirely new library if I
can because I'm already importing Boost and Blitz and would like to
keep the hassle of compiling everything to a minimum.
Boost - From what I have read in their documentation Boost has
methods for integrating ODE's, but I could not find any libraries
for numerically integrating double integrals of functions. Am I
missing something? This would be the most convenient option as I
already use Boost in my codes and its already in C++.
So my question essentially boils down to this:
Which of these three libraries would be most useful for my purposes? Is it possible to conduct the integral I have specified using Boost? Additionally any tips on how to implement this integral using any of the above libraries would be greatly appreciated.

Take a look at these sources, calling c code from c++ is generally not problematic. It's going the other direction that can be.
How to mix C and C++
How to Call C Function in C++, C++ Function in C (Mix C and C++)

Related

Why can't I compute big integer values in C++ correctly? [duplicate]

I've tried using
long long int
But it wont work for numbers like 3141592653589793238462643383279502884197169399375, I need this up to 10 ^ 80. Any idea? Let me know. Thanks alot.
You can't use any built-in integer type for this. You need a "multiple precision integer" aka "bignum" library. For C++, I would try Boost.Multiprecision first, but be aware that Boost can be considerably more trouble than it is worth, particularly if the module you're using has any shared library (aka DLL) component. The other obvious choice is GNU MP. It only has a C interface, but it is well-maintained, reliable, fast, and very popular (in fact, it appears that Boost.MP is "just" a C++ wrapper for it!)
WARNING: You might want a bignum library because you are trying to implement one of the cryptographic primitives that uses huge numbers, like RSA. Do not do this. The generic bignum libraries are not safe for cryptographic use, and even if they were, there would still be dozens of subtle mistakes you can make that would ruin your security. Use a well-tested cryptography library instead; for C++ I recommend Botan.

Eigenvalue library for c++, recommendations, how to implement, looking for something similar to dgeev from fortran

I am new to C++, with some training using fortran95. Trying to convert my knowledge into the new syntax but have run into a snag.
Many of my programs use modules with subroutines, and subroutines within subroutines and use of functions from a library described by NAG.com which are readily available and searchable.
I am currently looking for a c++ version of
http://www.nag.com/numeric/FL/manual/pdf/F08/f08naf.pdf
From what I have read so far, these libraries exist for c++ and I have used some simple ones thus far(like vector, cmath, math.h) but only ones that are already included in my Xcode package for my mac.
I haven't seen anybody mention one of these which my be included with my Xcode, and I am lacking in how to implement outside libraries I find. I am interested particularly in using:
http://www.alglib.net/download.php
Thus far I have been using subrutines as void type functions and simply including them in all of my code. But my code is becoming exceedingly cumbersome and I would like to make something similar to a fortran module to do chebyshev calculations. And I would much rather find a good library of eignevalue calculators and maybe even chebyshev calculators, . . . which I can use.
Essentially my question is, how do I implement external libraries I find and does anybody have a recommendation for a good one? How can I make my own code which contains a callable set of functions and then call it from within another piece of code?
If I understand right, the part of the NAG library you're using in Fortran is basically LAPACK. There is a C interface to LAPACK, called LAPACKE (http://www.netlib.org/lapack/lapacke.html). You can use it in a C++ program.
I didn't understand the other parts of your question.

C/C++ equivalent for Matlab's imtransform?

Is there something equivalent to matlab's imtransform in C++? I'm having a hard time wrapping my head around the code for imtransform in matlab, and I'm trying to use or rewrite it in C++.
edit: Not built into C++, but any libraries that you may know of which would do the same thing would be great
Check out OpenCV. I don't remember whether it has that exact transform, but it has a lot of related code to take a look at (it's open source).
No. Neither ISO C nor ISO C++ define any kind of image manipulation functions or formats (even including C1X and C++0x). (Your platform or operating system might though)

Pitfalls when converting C++/CLI to C++

I have a library written in C++/CLI and I want to open it up. I want it to be as cross-platform as possible and be able to write bindings to it for other languages to use (Java, Python, etc, etc). To do this, the library needs to be in plain C++ for maximum flexibility. I figure that the logical structures are already there, I just need to replace the .NET libraries it uses with the standard C++ ones. Is this a misguided notion? What should I watch out for when making this transition?
It might be more trouble than it's worth. Here is what you might come across:
There is no garbage collection in C++. This is the big one. This may require a significant redesign of your library just to convert. If you are using at least C++ tr1, or the boost library, you can sort of get there by using shared_ptr, but there are important fundamental differences. For example, you must be wary of circular dependencies. Also, they make debugging difficult without specific support for them in the debugger.
Functions in .Net classes which have no equivalent in C++ stl or the standard library. Probably the biggest hurtle will be any string manipulation code you have written since there are lot of differences there.
Class libraries/assemblies are not built-in to C++ - every platform has its own method of creating dynamic or shared libraries, and there isn't much support for C++ shared libraries - only C libraries in many cases. Be prepared to make everything a static library.
You must manage all your resources yourself.
Never done a port of C++/Cli to C++, but this comes to my mind:
Make sure that you dont have memory leaks. Use smart-pointers instead of gcnew, if possible (if not, make sure your code is exception safe nontheless).
Make sure your libraries interface only consists of builtin types (builtin does not include types of the STL! however this is not coercively necessary if you go open source)

Call C++ code from MATLAB?

I have some code which I need to code in C++ due to heavy reliance on templates. I want to call this code from MATLAB: basically, I need to pass some parameters to the C++ code, and have the C++ code return a matrix to MATLAB. I have heard this is possible with something called a MEX file which I am still looking into. However I am not sure what is supported in these MEX files. Is all of C++ (e.g. STL and Boost) supported? How difficult is it?
EDIT: I don't need any shared libraries, just header-only stuff like shared_ptr.
Have a look at the MEX-files Guide, especially Section 25–27 for C++.
The basic STL/Boost data structures should work, but threading with Boost could be a problem.
cout will not work as expected in C++, mexPrintf has to be used instead.
It's certainly possible to write C++ MEX files which use STL and boost. In general, you should be able to do anything you please inside a C++ MEX file. The main practical restriction is that MATLAB already ships with a bunch of libraries, so if you're using one of the boost pieces that needs a shared library (some are header-only), you'll need to match the version you compile against with that shipping with MATLAB.
For instance, MATLAB R2009b ships with boost 1.36 (you can tell by looking at the names of the libraries in <matlabroot>/bin/<arch>).
The C++ files are actually compiled by an external compiler. Use mex -setup to select which one (here is a list of supported compilers). Therefore, you shouldn't have too many weird things happen, nor should you be too restricted by what you can do.
I did some MEX stuff last year, and my memory is a bit rusty, but you do need to construct MATLAB arrays using MEX functions. I found the MATLAB documentation adequate, and the whole experience not too painful.
STL is definitely supported. Boost probably yet. The point is as long you have your STL and BOOST deployed on your computer, you should be good to go.