barrowing function across c++ libraries (newbie)

Go To StackoverFlow.com

-1

I would like to know how one goes about adding functionality from one open source c++ library to another. To make things concrete, here is an example. I really like the "find" function in the Armadillo library and now that i find myself using eigen more i kinda miss it. How hard would it be to write an equivalent of "find" that would be fully integrated into eigen (i.e. using eigen objects etc...)? How does one go about doing this? Where can i find the source code of the "find" function?

thanks in advance,

2012-04-04 08:04
by user189035


1

You will have to write it on your own, taking into consideration differences between libraries. It may require some knowledge about the library that you are trying to extend, though.

Start from reading the code of armadillo, to understand what they do in this function. Then proceed to understand how analogous structures are implemented in eigen and modify the code. If you want to integrate it into eigen, so that you need to link against only one library (only your custom eigen, not standard eigen and your custom eigen extensions), you will need to compile eigen with your files added to a Makefile/Cmake (or whatever eigen is using).

You can find sources of armadillo in tar.gz archive here: http://arma.sourceforge.net/download.html

If you ask where is find operator in armadillo sources, check include/armadillo_bits/op_find_bones.hpp and include/armadillo_bits/op_find_meat.hpp

2012-04-04 08:18
by stanwise
i knew about the .tar.gz (it's a bit hard to use armadillo w/o it...) i have difficulty locating in it the "source" of "find()" in there [this may be the most newbie part of my question]...functions do not seem to be called by their familiar names in the sources...what is principled way to find a function (say "find()") in this jungle - user189035 2012-04-04 08:25
@user189035 See now, I just understood that you might have meant that, before I read your comment : - stanwise 2012-04-04 08:26
one more question: the file opfindbones is an .hpp whereas the codes in "/eigen-eigen-6e7488e20373/Eigen/src/.../" are all ".h" files. Is that an added complication - user189035 2012-04-04 08:36
Do not expect a .cpp file. This is all templates, so whole implementation is in .hpp files. Declarations are in op_find_bones.hpp, and definitions in op_find_meat.hppstanwise 2012-04-04 08:40
.h and .hpp is just the same. Depends on your naming convention (some people use hpp to signify it is a C++ header), for a compiler it doesn't matter - stanwise 2012-04-04 08:41
Ads