Bladeren bron

minor bug fix for dim-index in nice->matlab with sparse features

Alexander Freytag 9 jaren geleden
bovenliggende
commit
48729528f7
1 gewijzigde bestanden met toevoegingen van 7 en 1 verwijderingen
  1. 7 1
      matlab/ConverterNICEToMatlab.cpp

+ 7 - 1
matlab/ConverterNICEToMatlab.cpp

@@ -8,7 +8,13 @@ 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* MatlabConversion::convertSparseVectorFromNice( const NICE::SparseVector & niceSvec, const bool & b_adaptIndexCtoM )
 {
-    mxArray * matlabSparseVec = mxCreateSparse( niceSvec.getDim() /*m*/, 1/*n*/, niceSvec.size()/*nzmax*/, mxREAL);
+    mxArray * matlabSparseVec;
+    
+    if ( b_adaptIndexCtoM ) 
+       matlabSparseVec = mxCreateSparse( niceSvec.getDim() -1 /*m*/, 1/*n*/, niceSvec.size() -1 /*nzmax*/, mxREAL);
+    else
+      matlabSparseVec = mxCreateSparse( niceSvec.getDim() /*m*/, 1/*n*/, niceSvec.size() /*nzmax*/, mxREAL);
+
     
     // To make the returned sparse mxArray useful, you must initialize the pr, ir, jc, and (if it exists) pi arrays.    
     // mxCreateSparse allocates space for: