After a few hours study I have found the magic syntax.
First I use Armadillo "uvec" type (a column vector of "uword" or unsigned long long int), I cast the functions to these uwords and then cast them back in the called function.
Code:
#include <armadillo>
using namespace arma ;
double f1( vec x ) ;
double f2( vec x ) ;
double f3( vec x ) ;
int main()
{
vec x = ones<vec>(3) ;
uvec U ;
U << (uword) f1 << (uword) f2 << (uword) f3 ;
vec V = my_function( U, x ) ;
----
}
vec my_function( uvec U, vec x )
{
int M = U.n_item ;
double (*func)(vec) = (double (*)(vec)) U(0) ;
double y = func(x) ;
....
}
It appears that the STL <vector> will also work.
Code:
#include <vector>
using namespace std ;
int main()
{
....
vector<double (*)(arma::vec)> V ;
V.push_back( f1 ) ;
V.push_back( f2 ) ;
V.push_back( f3 ) ;
arma::mat J = my_function( V, x ) ;
....
}
arma::mat my_function( vector<double (*)(arma::vec)> V,
arma::vec x )
{
double (*func)(arma::vec) = V.at(0) ;
....
}
Personally I prefer using the Armadillo uvec but the g++ compiler is accepting both approaches.