Dear Ed & others, Many thanks for your reply! A inline module sounds (much) better, but looking through the documentation it seems a bit beyond my current skill level. If you/someone else on the list would be available to implement this as a small project, please let me know! I have some funding available.
But for now, I'll use inline:CPP directly - and to clarify my previous explanation, the "dlib/matrix" is indeed an external library that will not be found automatically.. So, I've looked at the Inline C documentation, and probably need something like this in Inline Cpp format: use Inline C => config => libs => '-L/your/path -lyourlib'; I also need to provide the following commands to the GCC compiler: '-std=c++11 -O3 -fopenmp' but haven't found any documentation on this yet.. And I need to make sure that inlines writes to a location where it has read/write permission: use Inline (Config => DIRECTORY => '/usr/local/apache/Inline', ); because I my survey system uses CGI (wasn't aware of this before, but I noticed this in the Inline C documentation) Could you/someone else show me how to implement this (correctly) in the Perl script below)? Many thanks, Marcel [% Begin Unverified Perl use Inline 'CPP'; # Script for tasks 2-21 my $task = 9; my $prevTask = $task-1; # A. Add the previous choice task to “observedVector” my @observedVector = GETVALUE("observedVector"); push @observedVector, VALUE("task".$prevTask); SETVALUE("observedVector",join("",@observedVector)); # B. Remove the previous choice task from “futureVector” my @futureVector = GETVALUE("futureVector"); splice @futureVector, 0, 10; # C. CALL C++ FUNCTION: # something (approximately) like this: @futureVector = CppAdaptive(@pastVector,@futureVector,$prevTask); # D. Save futureVector and set next choice task SETVALUE("futureVector",join("",@futureVector)); SETVALUE("task".$task, substr(@futurevector,1,10)); __END__ __CPP__ use Inline (Config => DIRECTORY => '/usr/local/apache/Inline', ); use Inline Cpp => config => libs => '-L/your/path -lyourlib'; # pass '-std=c++11 -O3 -fopenmp' to the compiler #include <string> #include "dlib/matrix.h" using namespace std; using namespace dlib; string CppAdaptive(const string &observedVector, const string &futureVector, const int prevTask) { // test dlib matrix module integration matrix <int> design(12, 6); design = 1, 3, 3, 3, 1, 1, 1, 3, 1, 3, 1, 3, 1, 1, 2, 2, 2, 1, 2, 2, 1, 1, 3, 2, 2, 3, 2, 1, 1, 3, 3, 3, 1, 1, 2, 3, 2, 1, 3, 3, 2, 2, 3, 1, 3, 2, 2, 2, 3, 2, 1, 2, 3, 3, 3, 2, 2, 1, 3, 1, 1, 2, 3, 2, 1, 2, 2, 1, 2, 3, 3, 2; // return futureVector return futureVector; } End Unverified %]