Эх сурвалжийг харах

introduced namespace NICE::MatlabConversion for data flow in MEX files

Johannes Ruehle 11 жил өмнө
parent
commit
d687956011

+ 10 - 18
matlab/ConverterMatlabToNICE.cpp

@@ -3,21 +3,13 @@
 
 using namespace NICE;
 
-ConverterMatlabToNICE::ConverterMatlabToNICE()
-{
-}
-
-ConverterMatlabToNICE::~ConverterMatlabToNICE()
-{
-}
-
 /* Pass analyze_sparse a pointer to a sparse mxArray.  A sparse mxArray
    only stores its nonzero elements.  The values of the nonzero elements 
    are stored in the pr and pi arrays.  The tricky part of analyzing
    sparse mxArray's is figuring out the indices where the nonzero
    elements are stored.  (See the mxSetIr and mxSetJc reference pages
    for details. */  
-std::vector< const NICE::SparseVector * > ConverterMatlabToNICE::convertSparseMatrixToNice( const mxArray *array_ptr ) const
+std::vector< const NICE::SparseVector * > MatlabConversion::convertSparseMatrixToNice( const mxArray *array_ptr )
 {
   double   *pr;//, *pi;
   mwIndex  *ir, *jc;
@@ -79,10 +71,10 @@ std::vector< const NICE::SparseVector * > ConverterMatlabToNICE::convertSparseMa
 }
 
 // b_adaptIndexMtoC: if true, dim k will be inserted as k, not as k-1 (which would be the default for  M->C)
-NICE::SparseVector ConverterMatlabToNICE::convertSparseVectorToNice(
+NICE::SparseVector MatlabConversion::convertSparseVectorToNice(
                const mxArray* array_ptr,
                const bool & b_adaptIndexMtoC
-    )  const
+    )
 {
   double   *pr, *pi;
   mwIndex  *ir, *jc;
@@ -147,7 +139,7 @@ NICE::SparseVector ConverterMatlabToNICE::convertSparseVectorToNice(
   return svec;
 }
 
-NICE::Matrix ConverterMatlabToNICE::convertDoubleMatrixToNice( const mxArray* matlabMatrix ) const
+NICE::Matrix MatlabConversion::convertDoubleMatrixToNice( const mxArray* matlabMatrix )
 {
   if( !mxIsDouble( matlabMatrix ) )
     mexErrMsgIdAndTxt( "mexnice:error","Expected double in convertDoubleMatrixToNice" );
@@ -169,7 +161,7 @@ NICE::Matrix ConverterMatlabToNICE::convertDoubleMatrixToNice( const mxArray* ma
 }
 
 
-NICE::Vector ConverterMatlabToNICE::convertDoubleVectorToNice( const mxArray* matlabMatrix ) const
+NICE::Vector MatlabConversion::convertDoubleVectorToNice( const mxArray* matlabMatrix )
 {
   if( !mxIsDouble( matlabMatrix ) )
     mexErrMsgIdAndTxt( "mexnice:error","Expected double in convertDoubleVectorToNice" );
@@ -202,7 +194,7 @@ NICE::Vector ConverterMatlabToNICE::convertDoubleVectorToNice( const mxArray* ma
 
 
 
-std::string ConverterMatlabToNICE::convertMatlabToString( const mxArray *matlabString ) const
+std::string MatlabConversion::convertMatlabToString( const mxArray *matlabString )
 {
   if( !mxIsChar( matlabString ) )
     mexErrMsgIdAndTxt("mexnice:error","Expected string");
@@ -214,7 +206,7 @@ std::string ConverterMatlabToNICE::convertMatlabToString( const mxArray *matlabS
 }
 
 
-int ConverterMatlabToNICE::convertMatlabToInt32( const mxArray *matlabInt32 ) const
+int MatlabConversion::convertMatlabToInt32( const mxArray *matlabInt32 )
 {
   if( !mxIsInt32( matlabInt32 ) )
     mexErrMsgIdAndTxt("mexnice:error","Expected int32");
@@ -223,7 +215,7 @@ int ConverterMatlabToNICE::convertMatlabToInt32( const mxArray *matlabInt32 ) co
   return ptr[0];
 }
 
-double ConverterMatlabToNICE::convertMatlabToDouble( const mxArray *matlabDouble ) const
+double MatlabConversion::convertMatlabToDouble( const mxArray *matlabDouble )
 {
   if( !mxIsDouble(matlabDouble) )
     mexErrMsgIdAndTxt("mexnice:error","Expected double");
@@ -232,11 +224,11 @@ double ConverterMatlabToNICE::convertMatlabToDouble( const mxArray *matlabDouble
   return ptr[0];
 }
 
-bool ConverterMatlabToNICE::convertMatlabToBool( const mxArray *matlabBool ) const
+bool MatlabConversion::convertMatlabToBool( const mxArray *matlabBool )
 {
   if( !mxIsLogical( matlabBool ) )
     mexErrMsgIdAndTxt("mexnice:error","Expected bool");
 
   bool* ptr = (bool*) mxGetData( matlabBool );
   return ptr[0];
-}
+}

+ 14 - 34
matlab/ConverterMatlabToNICE.h

@@ -18,29 +18,13 @@
 
 namespace NICE {
 
- /** 
- * @class ConverterMatlabToNICE
- * @author Alexander Freytag
- * @brief Several methods for converting Matlab data into NICE containers
- */
+ namespace MatlabConversion {
 
-class ConverterMatlabToNICE
-{
-
-  protected:
-  
-  public:
-
-    /**
-     * @brief Default constructor
-     **/
-    ConverterMatlabToNICE();
+     /**
+     * @author Alexander Freytag, Johannes Ruehle
+     * @brief Several methods for converting Matlab data into NICE containers
+     */
 
-    /**
-     *@brief Default destructor
-     **/    
-    ~ConverterMatlabToNICE();
-  
     /**
      * @brief Convert a sparse matlab matrix into an std::vector of NICE::SparseVectors *
      * @TODO could be also converted into VVector!
@@ -48,7 +32,7 @@ class ConverterMatlabToNICE
      * @param array_ptr Sparse MxD Matlab matrix
      * @return std::vector< NICE::SparseVector * >
      **/  
-    std::vector< const NICE::SparseVector * > convertSparseMatrixToNice( const mxArray *array_ptr ) const;
+    std::vector< const NICE::SparseVector * > convertSparseMatrixToNice( const mxArray *array_ptr );
 
     /**
      * @brief Convert a sparse 1xD Matlab matrix into a SparseVector
@@ -57,11 +41,7 @@ class ConverterMatlabToNICE
      * @param b_adaptIndexMtoC if true, dim k will be inserted as k, not as k-1 (which would be the default for  M->C). Defaults to false.
      * @return NICE::SparseVector
      **/
-    NICE::SparseVector convertSparseVectorToNice(
-		  const mxArray* array_ptr,
-		  const bool & b_adaptIndexMtoC = false
-	) const;
-
+    NICE::SparseVector convertSparseVectorToNice( const mxArray* array_ptr,  const bool & b_adaptIndexMtoC = false );
 
     /**
      * @brief Convert a MxD Matlab matrix into a NICE::Matrix
@@ -69,7 +49,7 @@ class ConverterMatlabToNICE
      * @param matlabMatrix a matlab MxD matrix
      * @return NICE::Matrix
      **/
-    NICE::Matrix convertDoubleMatrixToNice( const mxArray* matlabMatrix ) const;
+    NICE::Matrix convertDoubleMatrixToNice( const mxArray* matlabMatrix );
     
     /**
      * @brief Convert a 1xD Matlab matrix into a NICE::Vector
@@ -77,7 +57,7 @@ class ConverterMatlabToNICE
      * @param matlabMatrix a matlab 1xD matrix
      * @return  NICE::Vector
      **/
-    NICE::Vector convertDoubleVectorToNice( const mxArray* matlabMatrix ) const;
+    NICE::Vector convertDoubleVectorToNice( const mxArray* matlabMatrix );
 
     /**
      * @brief Convert a Matlab char array into an std::string
@@ -85,7 +65,7 @@ class ConverterMatlabToNICE
      * @param matlabString a matlab char array variable
      * @return std::string
      **/
-    std::string convertMatlabToString( const mxArray *matlabString ) const;
+    std::string convertMatlabToString( const mxArray *matlabString );
 
     /**
      * @brief Convert a Matlab int32 variable into an std::int
@@ -93,7 +73,7 @@ class ConverterMatlabToNICE
      * @param matlabInt32 a matlab int32 variable
      * @return int
      **/
-    int convertMatlabToInt32( const mxArray *matlabInt32 ) const;
+    int convertMatlabToInt32( const mxArray *matlabInt32 );
     
     /**
      * @brief Convert a Matlab double variable into an std::double
@@ -101,7 +81,7 @@ class ConverterMatlabToNICE
      * @param matlabDouble a matlab double variable
      * @return double
      **/
-    double convertMatlabToDouble( const mxArray *matlabDouble ) const;
+    double convertMatlabToDouble( const mxArray *matlabDouble );
     
     /**
      * @brief Convert a Matlab bool variable into an std::bool
@@ -109,9 +89,9 @@ class ConverterMatlabToNICE
      * @param matlabBool a matlab bool variable
      * @return bool
      **/    
-    bool convertMatlabToBool( const mxArray *matlabBool ) const;
+    bool convertMatlabToBool( const mxArray *matlabBool );
 
-};
+} //ns MatlabConversion
 
 }
 

+ 4 - 12
matlab/ConverterNICEToMatlab.cpp

@@ -2,18 +2,10 @@
 #include "ConverterNICEToMatlab.h"
 
 using namespace NICE;
-
-ConverterNICEToMatlab::ConverterNICEToMatlab()
-{
-}
-
-ConverterNICEToMatlab::~ConverterNICEToMatlab()
-{
-}
-
+using namespace NICE::MatlabConversion;
 
 // b_adaptIndexCtoM: if true, dim k will be inserted as k, not as k+1 (which would be the default for C->M)
-mxArray* ConverterNICEToMatlab::convertSparseVectorFromNice( const NICE::SparseVector & niceSvec, const bool & b_adaptIndexCtoM ) const
+mxArray* MatlabConversion::convertSparseVectorFromNice( const NICE::SparseVector & niceSvec, const bool & b_adaptIndexCtoM )
 {
     mxArray * matlabSparseVec = mxCreateSparse( niceSvec.getDim() /*m*/, 1/*n*/, niceSvec.size()/*nzmax*/, mxREAL);
     
@@ -49,7 +41,7 @@ mxArray* ConverterNICEToMatlab::convertSparseVectorFromNice( const NICE::SparseV
     return matlabSparseVec;
 }
 
-mxArray* ConverterNICEToMatlab::convertMatrixFromNice( const NICE::Matrix & niceMatrix ) const
+mxArray* MatlabConversion::convertMatrixFromNice( const NICE::Matrix & niceMatrix )
 {
   mxArray *matlabMatrix = mxCreateDoubleMatrix( niceMatrix.rows(), niceMatrix.cols(), mxREAL );
   double* matlabMatrixPtr = mxGetPr( matlabMatrix );
@@ -65,7 +57,7 @@ mxArray* ConverterNICEToMatlab::convertMatrixFromNice( const NICE::Matrix & nice
   return matlabMatrix;
 }
 
-mxArray* ConverterNICEToMatlab::convertVectorFromNice( const NICE::Vector & niceVector ) const
+mxArray* MatlabConversion::convertVectorFromNice( const NICE::Vector & niceVector )
 {
   mxArray *matlabVector = mxCreateDoubleMatrix( niceVector.size(), 1, mxREAL );
   double* matlabVectorPtr = mxGetPr( matlabVector );

+ 9 - 27
matlab/ConverterNICEToMatlab.h

@@ -17,29 +17,11 @@
 
 namespace NICE {
 
- /** 
- * @class ConverterNICEToMatlab
- * @author Alexander Freytag
- * @brief Several methods for converting Matlab data into NICE containers
- */
-
-class ConverterNICEToMatlab
-{
-
-  protected:
-  
-  public:
-
-    /**
-     * @brief Default constructor
-     **/
-    ConverterNICEToMatlab();
-
-    /**
-     *@brief Default destructor
-     **/    
-    ~ConverterNICEToMatlab();
-  
+/**
+* @author Alexander Freytag, Johannes Ruehle
+* @brief Several methods for converting Matlab data into NICE containers
+*/
+namespace MatlabConversion {
 
     /**
      * @brief Convert a SparseVector into a Matlab 1xD sparse matrix
@@ -50,7 +32,7 @@ class ConverterNICEToMatlab
      * @param b_adaptIndexCtoM if true, dim k will be inserted as k, not as k+1 (which would be the default for C->M) Defaults to false.
      * @return mxArray*
      **/
-    mxArray* convertSparseVectorFromNice( const NICE::SparseVector & niceSvec, const bool & b_adaptIndexCtoM = false ) const;
+    mxArray* convertSparseVectorFromNice( const NICE::SparseVector & niceSvec, const bool & b_adaptIndexCtoM = false );
 
     /**
      * @brief Convert a NICE::Matrix into a full Matlab MxD matrix
@@ -60,7 +42,7 @@ class ConverterNICEToMatlab
      * @param niceMatrix a NICE::Matrix
      * @return mxArray*
      **/
-    mxArray* convertMatrixFromNice( const NICE::Matrix & niceMatrix ) const;
+    mxArray* convertMatrixFromNice( const NICE::Matrix & niceMatrix );
     
     /**
      * @brief Convert a NICE::Vector into a full Matlab 1xD matrix
@@ -71,9 +53,9 @@ class ConverterNICEToMatlab
      * @return mxArray*
      **/
     
-    mxArray* convertVectorFromNice( const NICE::Vector & niceVector ) const;
+    mxArray* convertVectorFromNice( const NICE::Vector & niceVector );
 
-};
+} // ns MatlabConversion
 
 }
 

+ 41 - 45
matlab/GPHIKClassifierMex.cpp

@@ -25,10 +25,6 @@
 #include "gp-hik-core/matlab/ConverterMatlabToNICE.h"
 #include "gp-hik-core/matlab/ConverterNICEToMatlab.h"
 
-const NICE::ConverterMatlabToNICE converterMtoNICE;
-const NICE::ConverterNICEToMatlab converterNICEtoM;
-
-
 using namespace std; //C basics
 using namespace NICE;  // nice-core
 
@@ -41,10 +37,10 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
   // read the config accordingly
   
   int i_start ( 0 );
-  std::string variable = converterMtoNICE.convertMatlabToString(prhs[i_start]);
+  std::string variable = MatlabConversion::convertMatlabToString(prhs[i_start]);
   if(variable == "conf")
   {
-      conf = NICE::Config ( converterMtoNICE.convertMatlabToString( prhs[i_start+1] )  );
+      conf = NICE::Config ( MatlabConversion::convertMatlabToString( prhs[i_start+1] )  );
       i_start = i_start+2;
   }
   
@@ -52,7 +48,7 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
   // and add them to the config
   for( int i=i_start; i < nrhs; i+=2 )
   {
-    std::string variable = converterMtoNICE.convertMatlabToString(prhs[i]);
+    std::string variable = MatlabConversion::convertMatlabToString(prhs[i]);
     
     /////////////////////////////////////////
     // READ STANDARD BOOLEAN VARIABLES
@@ -64,7 +60,7 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
     {
       if ( mxIsChar( prhs[i+1] ) )
       {
-        string value = converterMtoNICE.convertMatlabToString( prhs[i+1] );
+        string value = MatlabConversion::convertMatlabToString( prhs[i+1] );
         if ( (value != "true") && (value != "false") )
         {
           std::string errorMsg = "Unexpected parameter value for \'" +  variable + "\'. In string modus, \'true\' or \'false\' expected.";
@@ -78,7 +74,7 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
       }
       else if ( mxIsLogical( prhs[i+1] ) )
       {
-        bool value = converterMtoNICE.convertMatlabToBool( prhs[i+1] );
+        bool value = MatlabConversion::convertMatlabToBool( prhs[i+1] );
         conf.sB("GPHIKClassifier", variable, value);
       }
       else
@@ -96,12 +92,12 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
     {
       if ( mxIsDouble( prhs[i+1] ) )
       {
-        double value = converterMtoNICE.convertMatlabToDouble(prhs[i+1]);
+        double value = MatlabConversion::convertMatlabToDouble(prhs[i+1]);
         conf.sI("GPHIKClassifier", variable, (int) value);        
       }
       else if ( mxIsInt32( prhs[i+1] ) )
       {
-        int value = converterMtoNICE.convertMatlabToInt32(prhs[i+1]);
+        int value = MatlabConversion::convertMatlabToInt32(prhs[i+1]);
         conf.sI("GPHIKClassifier", variable, value);          
       }
       else
@@ -119,7 +115,7 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
     {
       if ( mxIsDouble( prhs[i+1] ) )
       {
-        double value = converterMtoNICE.convertMatlabToDouble(prhs[i+1]);
+        double value = MatlabConversion::convertMatlabToDouble(prhs[i+1]);
         if( value < 1 )
         {
           std::string errorMsg = "Expected parameter value larger than 0 for \'" +  variable + "\'.";
@@ -129,7 +125,7 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
       }
       else if ( mxIsInt32( prhs[i+1] ) )
       {
-        int value = converterMtoNICE.convertMatlabToInt32(prhs[i+1]);
+        int value = MatlabConversion::convertMatlabToInt32(prhs[i+1]);
         if( value < 1 )
         {
           std::string errorMsg = "Expected parameter value larger than 0 for \'" +  variable + "\'.";
@@ -153,7 +149,7 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
     {
       if ( mxIsDouble( prhs[i+1] ) )
       {
-        double value = converterMtoNICE.convertMatlabToDouble(prhs[i+1]);
+        double value = MatlabConversion::convertMatlabToDouble(prhs[i+1]);
         if( value < 0.0 )
         {
           std::string errorMsg = "Expected parameter value larger than 0 for \'" +  variable + "\'.";
@@ -174,7 +170,7 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
 
     if(variable == "ils_method")
     {
-      string value = converterMtoNICE.convertMatlabToString(prhs[i+1]);
+      string value = MatlabConversion::convertMatlabToString(prhs[i+1]);
       if(value != "CG" && value != "CGL" && value != "SYMMLQ" && value != "MINRES")
         mexErrMsgIdAndTxt("mexnice:error","Unexpected parameter value for \'ils_method\'. \'CG\', \'CGL\', \'SYMMLQ\' or \'MINRES\' expected.");
         conf.sS("GPHIKClassifier", variable, value);
@@ -183,7 +179,7 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
 
     if(variable == "optimization_method")
     {
-      string value = converterMtoNICE.convertMatlabToString(prhs[i+1]);
+      string value = MatlabConversion::convertMatlabToString(prhs[i+1]);
       if(value != "greedy" && value != "downhillsimplex" && value != "none")
         mexErrMsgIdAndTxt("mexnice:error","Unexpected parameter value for \'optimization_method\'. \'greedy\', \'downhillsimplex\' or \'none\' expected.");
         conf.sS("GPHIKClassifier", variable, value);
@@ -191,7 +187,7 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
 
     if(variable == "transform")
     {
-      string value = converterMtoNICE.convertMatlabToString( prhs[i+1] );
+      string value = MatlabConversion::convertMatlabToString( prhs[i+1] );
       if(value != "absexp" && value != "exp" && value != "MKL" && value != "WeightedDim")
         mexErrMsgIdAndTxt("mexnice:error","Unexpected parameter value for \'transform\'. \'absexp\', \'exp\' , \'MKL\' or \'WeightedDim\' expected.");
         conf.sS("GPHIKClassifier", variable, value);
@@ -200,7 +196,7 @@ NICE::Config parseParametersGPHIKClassifier(const mxArray *prhs[], int nrhs)
   
     if(variable == "varianceApproximation")
     {
-      string value = converterMtoNICE.convertMatlabToString(prhs[i+1]);
+      string value = MatlabConversion::convertMatlabToString(prhs[i+1]);
       if(value != "approximate_fine" && value != "approximate_rough" && value != "exact" && value != "none")
         mexErrMsgIdAndTxt("mexnice:error","Unexpected parameter value for \'varianceApproximation\'. \'approximate_fine\', \'approximate_rough\', \'none\' or \'exact\' expected.");
         conf.sS("GPHIKClassifier", variable, value);
@@ -224,7 +220,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     if( !mxIsChar( prhs[0] ) )
         mexErrMsgTxt("First argument needs to be the command, ie.e, the class method to call... Aborting!");        
     
-    std::string cmd = converterMtoNICE.convertMatlabToString( prhs[0] );
+    std::string cmd = MatlabConversion::convertMatlabToString( prhs[0] );
       
         
     // create object
@@ -242,7 +238,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         
          
         // handle to the C++ instance
-        plhs[0] = convertPtr2Mat<NICE::GPHIKClassifier>( classifier );
+        plhs[0] = MatlabConversion::convertPtr2Mat<NICE::GPHIKClassifier>( classifier );
         return;
     }
     
@@ -255,13 +251,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     if ( !strcmp("delete", cmd.c_str() ) )
     {
         // Destroy the C++ object
-        destroyObject<NICE::GPHIKClassifier>(prhs[1]);
+        MatlabConversion::destroyObject<NICE::GPHIKClassifier>(prhs[1]);
         return;
     }
     
     // get the class instance pointer from the second input
     // every following function needs the classifier object
-    NICE::GPHIKClassifier * classifier = convertMat2Ptr<NICE::GPHIKClassifier>(prhs[1]);
+    NICE::GPHIKClassifier * classifier = MatlabConversion::convertMat2Ptr<NICE::GPHIKClassifier>(prhs[1]);
     
     
     ////////////////////////////////////////
@@ -285,12 +281,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
         if ( mxIsSparse( prhs[2] ) )
         {
-            examplesTrain = converterMtoNICE.convertSparseMatrixToNice( prhs[2] );
+            examplesTrain = MatlabConversion::convertSparseMatrixToNice( prhs[2] );
         }
         else
         {
             NICE::Matrix dataTrain;
-            dataTrain = converterMtoNICE.convertDoubleMatrixToNice(prhs[2]);
+            dataTrain = MatlabConversion::convertDoubleMatrixToNice(prhs[2]);
             
             //----------------- convert data to sparse data structures ---------
             examplesTrain.resize( dataTrain.rows() );
@@ -303,7 +299,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
             }            
         }
           
-        yMultiTrain = converterMtoNICE.convertDoubleVectorToNice(prhs[3]);
+        yMultiTrain = MatlabConversion::convertDoubleVectorToNice(prhs[3]);
 
         //----------------- train our classifier -------------
         classifier->train ( examplesTrain , yMultiTrain );
@@ -334,7 +330,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         if ( mxIsSparse( prhs[2] ) )
         {
             NICE::SparseVector * example;
-            example = new NICE::SparseVector ( converterMtoNICE.convertSparseVectorToNice( prhs[2] ) );
+            example = new NICE::SparseVector ( MatlabConversion::convertSparseVectorToNice( prhs[2] ) );
             classifier->classify ( example,  result, scores, uncertainty );
             
             //----------------- clean up -------------
@@ -343,7 +339,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         else
         {
             NICE::Vector * example;
-            example = new NICE::Vector ( converterMtoNICE.convertDoubleVectorToNice(prhs[2]) ); 
+            example = new NICE::Vector ( MatlabConversion::convertDoubleVectorToNice(prhs[2]) );
             classifier->classify ( example,  result, scores, uncertainty );
             
             //----------------- clean up -------------
@@ -358,7 +354,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
           
           if(nlhs >= 2)
           {
-            plhs[1] = converterNICEtoM.convertSparseVectorFromNice( scores, true  /*b_adaptIndex*/);
+            plhs[1] = MatlabConversion::convertSparseVectorFromNice( scores, true  /*b_adaptIndex*/);
           }
           if(nlhs >= 3)
           {
@@ -383,7 +379,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         if ( mxIsSparse( prhs[2] ) )
         {
             NICE::SparseVector * example;
-            example = new NICE::SparseVector ( converterMtoNICE.convertSparseVectorToNice( prhs[2] ) );
+            example = new NICE::SparseVector ( MatlabConversion::convertSparseVectorToNice( prhs[2] ) );
             classifier->predictUncertainty( example, uncertainty );
             
             //----------------- clean up -------------
@@ -392,7 +388,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         else
         {
             NICE::Vector * example;
-            example = new NICE::Vector ( converterMtoNICE.convertDoubleVectorToNice(prhs[2]) ); 
+            example = new NICE::Vector ( MatlabConversion::convertDoubleVectorToNice(prhs[2]) );
             classifier->predictUncertainty( example, uncertainty );
             
             //----------------- clean up -------------
@@ -423,15 +419,15 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
         if ( dataIsSparse )
         {
-            dataTest_sparse = converterMtoNICE.convertSparseMatrixToNice( prhs[2] );
+            dataTest_sparse = MatlabConversion::convertSparseMatrixToNice( prhs[2] );
         }
         else
         {    
-            dataTest_dense = converterMtoNICE.convertDoubleMatrixToNice(prhs[2]);          
+            dataTest_dense = MatlabConversion::convertDoubleMatrixToNice(prhs[2]);
         }        
 
         NICE::Vector yMultiTest;
-        yMultiTest = converterMtoNICE.convertDoubleVectorToNice(prhs[3]);
+        yMultiTest = MatlabConversion::convertDoubleVectorToNice(prhs[3]);
 
         
         // ------------------------------------------
@@ -547,9 +543,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         plhs[0] = mxCreateDoubleScalar( recRate );
 
         if(nlhs >= 2)
-          plhs[1] = converterNICEtoM.convertMatrixFromNice(confusionMatrix);
+          plhs[1] = MatlabConversion::convertMatrixFromNice(confusionMatrix);
         if(nlhs >= 3)
-          plhs[2] = converterNICEtoM.convertMatrixFromNice(scores);          
+          plhs[2] = MatlabConversion::convertMatrixFromNice(scores);
           
           
         return;
@@ -575,24 +571,24 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
         if ( mxIsSparse( prhs[2] ) )
         {
-            newExample = new NICE::SparseVector ( converterMtoNICE.convertSparseVectorToNice( prhs[2] ) );
+            newExample = new NICE::SparseVector ( MatlabConversion::convertSparseVectorToNice( prhs[2] ) );
         }
         else
         {
             NICE::Vector * example;
-            example = new NICE::Vector ( converterMtoNICE.convertDoubleVectorToNice(prhs[2]) ); 
+            example = new NICE::Vector ( MatlabConversion::convertDoubleVectorToNice(prhs[2]) );
             newExample = new NICE::SparseVector ( *example );
             //----------------- clean up -------------
             delete example;            
         }
         
-        newLabel = converterMtoNICE.convertMatlabToDouble( prhs[3] );
+        newLabel = MatlabConversion::convertMatlabToDouble( prhs[3] );
         
         // setting performOptimizationAfterIncrement is optional
         if ( nrhs > 4 )
         {
           bool performOptimizationAfterIncrement;          
-          performOptimizationAfterIncrement = converterMtoNICE.convertMatlabToBool( prhs[4] );
+          performOptimizationAfterIncrement = MatlabConversion::convertMatlabToBool( prhs[4] );
           
           classifier->addExample ( newExample,  newLabel, performOptimizationAfterIncrement );
         }
@@ -624,12 +620,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
         if ( mxIsSparse( prhs[2] ) )
         {
-            newExamples = converterMtoNICE.convertSparseMatrixToNice( prhs[2] );
+            newExamples = MatlabConversion::convertSparseMatrixToNice( prhs[2] );
         }
         else
         {
             NICE::Matrix newData;
-            newData = converterMtoNICE.convertDoubleMatrixToNice(prhs[2]);
+            newData = MatlabConversion::convertDoubleMatrixToNice(prhs[2]);
             
             //----------------- convert data to sparse data structures ---------
             newExamples.resize( newData.rows() );
@@ -642,13 +638,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
             }            
         }
           
-        newLabels = converterMtoNICE.convertDoubleVectorToNice(prhs[3]);
+        newLabels = MatlabConversion::convertDoubleVectorToNice(prhs[3]);
         
         // setting performOptimizationAfterIncrement is optional
         if ( nrhs > 4 )
         {
           bool performOptimizationAfterIncrement;          
-          performOptimizationAfterIncrement = converterMtoNICE.convertMatlabToBool( prhs[4] );
+          performOptimizationAfterIncrement = MatlabConversion::convertMatlabToBool( prhs[4] );
           
           classifier->addMultipleExamples ( newExamples,  newLabels, performOptimizationAfterIncrement );
         }
@@ -684,7 +680,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         if ( nrhs < 3 )
             mexErrMsgTxt("store: no destination given.");        
                
-        std::string s_destination = converterMtoNICE.convertMatlabToString( prhs[2] );
+        std::string s_destination = MatlabConversion::convertMatlabToString( prhs[2] );
           
         std::filebuf fb;
         fb.open ( s_destination.c_str(), ios::out );
@@ -704,7 +700,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         if ( nrhs < 3 )
             mexErrMsgTxt("restore: no destination given.");        
                
-        std::string s_destination = converterMtoNICE.convertMatlabToString( prhs[2] );
+        std::string s_destination = MatlabConversion::convertMatlabToString( prhs[2] );
         
         std::cerr << " aim at restoring the classifier from " << s_destination << std::endl;
           

+ 39 - 43
matlab/GPHIKRegressionMex.cpp

@@ -25,10 +25,6 @@
 #include "gp-hik-core/matlab/ConverterMatlabToNICE.h"
 #include "gp-hik-core/matlab/ConverterNICEToMatlab.h"
 
-const NICE::ConverterMatlabToNICE converterMtoNICE;
-const NICE::ConverterNICEToMatlab converterNICEtoM;
-
-
 using namespace std; //C basics
 using namespace NICE;  // nice-core
 
@@ -41,10 +37,10 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
   // read the config accordingly
   
   int i_start ( 0 );
-  std::string variable = converterMtoNICE.convertMatlabToString(prhs[i_start]);
+  std::string variable = MatlabConversion::convertMatlabToString(prhs[i_start]);
   if(variable == "conf")
   {
-      conf = NICE::Config ( converterMtoNICE.convertMatlabToString( prhs[i_start+1] )  );
+      conf = NICE::Config ( MatlabConversion::convertMatlabToString( prhs[i_start+1] )  );
       i_start = i_start+2;
   }
   
@@ -52,7 +48,7 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
   // and add them to the config
   for( int i=i_start; i < nrhs; i+=2 )
   {
-    std::string variable = converterMtoNICE.convertMatlabToString(prhs[i]);
+    std::string variable = MatlabConversion::convertMatlabToString(prhs[i]);
     
     /////////////////////////////////////////
     // READ STANDARD BOOLEAN VARIABLES
@@ -64,7 +60,7 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
     {
       if ( mxIsChar( prhs[i+1] ) )
       {
-        string value = converterMtoNICE.convertMatlabToString( prhs[i+1] );
+        string value = MatlabConversion::convertMatlabToString( prhs[i+1] );
         if ( (value != "true") && (value != "false") )
         {
           std::string errorMsg = "Unexpected parameter value for \'" +  variable + "\'. In string modus, \'true\' or \'false\' expected.";
@@ -78,7 +74,7 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
       }
       else if ( mxIsLogical( prhs[i+1] ) )
       {
-        bool value = converterMtoNICE.convertMatlabToBool( prhs[i+1] );
+        bool value = MatlabConversion::convertMatlabToBool( prhs[i+1] );
         conf.sB("GPHIKRegression", variable, value);
       }
       else
@@ -96,12 +92,12 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
     {
       if ( mxIsDouble( prhs[i+1] ) )
       {
-        double value = converterMtoNICE.convertMatlabToDouble(prhs[i+1]);
+        double value = MatlabConversion::convertMatlabToDouble(prhs[i+1]);
         conf.sI("GPHIKRegression", variable, (int) value);        
       }
       else if ( mxIsInt32( prhs[i+1] ) )
       {
-        int value = converterMtoNICE.convertMatlabToInt32(prhs[i+1]);
+        int value = MatlabConversion::convertMatlabToInt32(prhs[i+1]);
         conf.sI("GPHIKRegression", variable, value);          
       }
       else
@@ -119,7 +115,7 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
     {
       if ( mxIsDouble( prhs[i+1] ) )
       {
-        double value = converterMtoNICE.convertMatlabToDouble(prhs[i+1]);
+        double value = MatlabConversion::convertMatlabToDouble(prhs[i+1]);
         if( value < 1 )
         {
           std::string errorMsg = "Expected parameter value larger than 0 for \'" +  variable + "\'.";
@@ -129,7 +125,7 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
       }
       else if ( mxIsInt32( prhs[i+1] ) )
       {
-        int value = converterMtoNICE.convertMatlabToInt32(prhs[i+1]);
+        int value = MatlabConversion::convertMatlabToInt32(prhs[i+1]);
         if( value < 1 )
         {
           std::string errorMsg = "Expected parameter value larger than 0 for \'" +  variable + "\'.";
@@ -153,7 +149,7 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
     {
       if ( mxIsDouble( prhs[i+1] ) )
       {
-        double value = converterMtoNICE.convertMatlabToDouble(prhs[i+1]);
+        double value = MatlabConversion::convertMatlabToDouble(prhs[i+1]);
         if( value < 0.0 )
         {
           std::string errorMsg = "Expected parameter value larger than 0 for \'" +  variable + "\'.";
@@ -174,7 +170,7 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
 
     if(variable == "ils_method")
     {
-      string value = converterMtoNICE.convertMatlabToString(prhs[i+1]);
+      string value = MatlabConversion::convertMatlabToString(prhs[i+1]);
       if(value != "CG" && value != "CGL" && value != "SYMMLQ" && value != "MINRES")
         mexErrMsgIdAndTxt("mexnice:error","Unexpected parameter value for \'ils_method\'. \'CG\', \'CGL\', \'SYMMLQ\' or \'MINRES\' expected.");
         conf.sS("GPHIKRegression", variable, value);
@@ -183,7 +179,7 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
 
     if(variable == "optimization_method")
     {
-      string value = converterMtoNICE.convertMatlabToString(prhs[i+1]);
+      string value = MatlabConversion::convertMatlabToString(prhs[i+1]);
       if(value != "greedy" && value != "downhillsimplex" && value != "none")
         mexErrMsgIdAndTxt("mexnice:error","Unexpected parameter value for \'optimization_method\'. \'greedy\', \'downhillsimplex\' or \'none\' expected.");
         conf.sS("GPHIKRegression", variable, value);
@@ -191,7 +187,7 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
 
     if(variable == "transform")
     {
-      string value = converterMtoNICE.convertMatlabToString( prhs[i+1] );
+      string value = MatlabConversion::convertMatlabToString( prhs[i+1] );
       if(value != "absexp" && value != "exp" && value != "MKL" && value != "WeightedDim")
         mexErrMsgIdAndTxt("mexnice:error","Unexpected parameter value for \'transform\'. \'absexp\', \'exp\' , \'MKL\' or \'WeightedDim\' expected.");
         conf.sS("GPHIKRegression", variable, value);
@@ -200,7 +196,7 @@ NICE::Config parseParametersGPHIKRegression(const mxArray *prhs[], int nrhs)
   
     if(variable == "varianceApproximation")
     {
-      string value = converterMtoNICE.convertMatlabToString(prhs[i+1]);
+      string value = MatlabConversion::convertMatlabToString(prhs[i+1]);
       if(value != "approximate_fine" && value != "approximate_rough" && value != "exact" && value != "none")
         mexErrMsgIdAndTxt("mexnice:error","Unexpected parameter value for \'varianceApproximation\'. \'approximate_fine\', \'approximate_rough\', \'none\' or \'exact\' expected.");
         conf.sS("GPHIKRegression", variable, value);
@@ -224,7 +220,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     if( !mxIsChar( prhs[0] ) )
         mexErrMsgTxt("First argument needs to be the command, ie.e, the class method to call... Aborting!");        
     
-    std::string cmd = converterMtoNICE.convertMatlabToString( prhs[0] );
+    std::string cmd = MatlabConversion::convertMatlabToString( prhs[0] );
       
         
     // create object
@@ -242,7 +238,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         
          
         // handle to the C++ instance
-        plhs[0] = convertPtr2Mat<NICE::GPHIKRegression>( regressor );
+        plhs[0] = MatlabConversion::convertPtr2Mat<NICE::GPHIKRegression>( regressor );
         return;
     }
     
@@ -255,13 +251,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
     if ( !strcmp("delete", cmd.c_str() ) )
     {
         // Destroy the C++ object
-        destroyObject<NICE::GPHIKRegression>(prhs[1]);
+        MatlabConversion::destroyObject<NICE::GPHIKRegression>(prhs[1]);
         return;
     }
     
     // get the class instance pointer from the second input
     // every following function needs the regressor object
-    NICE::GPHIKRegression * regressor = convertMat2Ptr<NICE::GPHIKRegression>(prhs[1]);
+    NICE::GPHIKRegression * regressor = MatlabConversion::convertMat2Ptr<NICE::GPHIKRegression>(prhs[1]);
     
     
     ////////////////////////////////////////
@@ -285,12 +281,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
         if ( mxIsSparse( prhs[2] ) )
         {
-            examplesTrain = converterMtoNICE.convertSparseMatrixToNice( prhs[2] );
+            examplesTrain = MatlabConversion::convertSparseMatrixToNice( prhs[2] );
         }
         else
         {
             NICE::Matrix dataTrain;
-            dataTrain = converterMtoNICE.convertDoubleMatrixToNice(prhs[2]);
+            dataTrain = MatlabConversion::convertDoubleMatrixToNice(prhs[2]);
             
             //----------------- convert data to sparse data structures ---------
             examplesTrain.resize( dataTrain.rows() );
@@ -303,7 +299,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
             }            
         }
           
-        yValuesTrain = converterMtoNICE.convertDoubleVectorToNice(prhs[3]);
+        yValuesTrain = MatlabConversion::convertDoubleVectorToNice(prhs[3]);
 
         //----------------- train our regressor -------------
         regressor->train ( examplesTrain , yValuesTrain );
@@ -333,7 +329,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         if ( mxIsSparse( prhs[2] ) )
         {
             NICE::SparseVector * example;
-            example = new NICE::SparseVector ( converterMtoNICE.convertSparseVectorToNice( prhs[2] ) );
+            example = new NICE::SparseVector ( MatlabConversion::convertSparseVectorToNice( prhs[2] ) );
             regressor->estimate ( example,  result, uncertainty );
             
             //----------------- clean up -------------
@@ -342,7 +338,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         else
         {
             NICE::Vector * example;
-            example = new NICE::Vector ( converterMtoNICE.convertDoubleVectorToNice(prhs[2]) ); 
+            example = new NICE::Vector ( MatlabConversion::convertDoubleVectorToNice(prhs[2]) );
             regressor->estimate ( example,  result, uncertainty );
             
             //----------------- clean up -------------
@@ -378,7 +374,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         if ( mxIsSparse( prhs[2] ) )
         {
             NICE::SparseVector * example;
-            example = new NICE::SparseVector ( converterMtoNICE.convertSparseVectorToNice( prhs[2] ) );
+            example = new NICE::SparseVector ( MatlabConversion::convertSparseVectorToNice( prhs[2] ) );
             regressor->predictUncertainty( example, uncertainty );
             
             //----------------- clean up -------------
@@ -387,7 +383,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         else
         {
             NICE::Vector * example;
-            example = new NICE::Vector ( converterMtoNICE.convertDoubleVectorToNice(prhs[2]) ); 
+            example = new NICE::Vector ( MatlabConversion::convertDoubleVectorToNice(prhs[2]) );
             regressor->predictUncertainty( example, uncertainty );
             
             //----------------- clean up -------------
@@ -418,15 +414,15 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
         if ( dataIsSparse )
         {
-            dataTest_sparse = converterMtoNICE.convertSparseMatrixToNice( prhs[2] );
+            dataTest_sparse = MatlabConversion::convertSparseMatrixToNice( prhs[2] );
         }
         else
         {    
-            dataTest_dense = converterMtoNICE.convertDoubleMatrixToNice(prhs[2]);          
+            dataTest_dense = MatlabConversion::convertDoubleMatrixToNice(prhs[2]);
         }        
 
         NICE::Vector yValuesTest;
-        yValuesTest = converterMtoNICE.convertDoubleVectorToNice(prhs[3]);
+        yValuesTest = MatlabConversion::convertDoubleVectorToNice(prhs[3]);
 	
         int i_numTestSamples ( yValuesTest.size() );
         
@@ -499,7 +495,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         plhs[0] = mxCreateDoubleScalar( l2loss );
 
         if(nlhs >= 2)
-          plhs[1] = converterNICEtoM.convertVectorFromNice(scores);          
+          plhs[1] = MatlabConversion::convertVectorFromNice(scores);
           
           
         return;
@@ -525,24 +521,24 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
         if ( mxIsSparse( prhs[2] ) )
         {
-            newExample = new NICE::SparseVector ( converterMtoNICE.convertSparseVectorToNice( prhs[2] ) );
+            newExample = new NICE::SparseVector ( MatlabConversion::convertSparseVectorToNice( prhs[2] ) );
         }
         else
         {
             NICE::Vector * example;
-            example = new NICE::Vector ( converterMtoNICE.convertDoubleVectorToNice(prhs[2]) ); 
+            example = new NICE::Vector ( MatlabConversion::convertDoubleVectorToNice(prhs[2]) );
             newExample = new NICE::SparseVector ( *example );
             //----------------- clean up -------------
             delete example;            
         }
         
-        newLabel = converterMtoNICE.convertMatlabToDouble( prhs[3] );
+        newLabel = MatlabConversion::convertMatlabToDouble( prhs[3] );
         
         // setting performOptimizationAfterIncrement is optional
         if ( nrhs > 4 )
         {
           bool performOptimizationAfterIncrement;          
-          performOptimizationAfterIncrement = converterMtoNICE.convertMatlabToBool( prhs[4] );
+          performOptimizationAfterIncrement = MatlabConversion::convertMatlabToBool( prhs[4] );
           
           regressor->addExample ( newExample,  newLabel, performOptimizationAfterIncrement );
         }
@@ -574,12 +570,12 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
 
         if ( mxIsSparse( prhs[2] ) )
         {
-            newExamples = converterMtoNICE.convertSparseMatrixToNice( prhs[2] );
+            newExamples = MatlabConversion::convertSparseMatrixToNice( prhs[2] );
         }
         else
         {
             NICE::Matrix newData;
-            newData = converterMtoNICE.convertDoubleMatrixToNice(prhs[2]);
+            newData = MatlabConversion::convertDoubleMatrixToNice(prhs[2]);
             
             //----------------- convert data to sparse data structures ---------
             newExamples.resize( newData.rows() );
@@ -592,13 +588,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
             }            
         }
           
-        newLabels = converterMtoNICE.convertDoubleVectorToNice(prhs[3]);
+        newLabels = MatlabConversion::convertDoubleVectorToNice(prhs[3]);
         
         // setting performOptimizationAfterIncrement is optional
         if ( nrhs > 4 )
         {
           bool performOptimizationAfterIncrement;          
-          performOptimizationAfterIncrement = converterMtoNICE.convertMatlabToBool( prhs[4] );
+          performOptimizationAfterIncrement = MatlabConversion::convertMatlabToBool( prhs[4] );
           
           regressor->addMultipleExamples ( newExamples,  newLabels, performOptimizationAfterIncrement );
         }
@@ -634,7 +630,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         if ( nrhs < 3 )
             mexErrMsgTxt("store: no destination given.");        
                
-        std::string s_destination = converterMtoNICE.convertMatlabToString( prhs[2] );
+        std::string s_destination = MatlabConversion::convertMatlabToString( prhs[2] );
           
         std::filebuf fb;
         fb.open ( s_destination.c_str(), ios::out );
@@ -654,7 +650,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
         if ( nrhs < 3 )
             mexErrMsgTxt("restore: no destination given.");        
                
-        std::string s_destination = converterMtoNICE.convertMatlabToString( prhs[2] );
+        std::string s_destination = MatlabConversion::convertMatlabToString( prhs[2] );
         
         std::cerr << " aim at restoring the regressor from " << s_destination << std::endl;
           

+ 8 - 0
matlab/classHandleMtoC.h

@@ -18,6 +18,10 @@
 
 #define CLASS_HANDLE_SIGNATURE 0xFF00F0A3
 
+namespace NICE {
+
+namespace MatlabConversion {
+
   /** 
   * @class ClassHandle
   * @brief Generic class to pass C++ objects to matlab
@@ -140,4 +144,8 @@ template<class objectClass> inline void destroyObject(const mxArray *in)
     mexUnlock();
 }
 
+}
+
+}
+
 #endif // _NICE_CLASSHANDLEMTOCINCLUDE