|
@@ -1,5 +1,9 @@
|
|
|
#include "Example.h"
|
|
|
|
|
|
+#ifdef NICE_USELIB_OPENMP
|
|
|
+#include <omp.h>
|
|
|
+#endif
|
|
|
+
|
|
|
using namespace OBJREC;
|
|
|
using namespace std;
|
|
|
using namespace NICE;
|
|
@@ -216,3 +220,28 @@ bool Examples::wrapExamplesAroundFeatureMatrix(const Matrix &p_MatFeaturesColumW
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+bool Examples::wrapExamplesAroundFeatureMatrix(const Matrix &p_MatFeaturesColumWiseSamples, const VectorT<int> &p_VecLabels, Examples &p_Examples)
|
|
|
+{
|
|
|
+ size_t t_iNumSamples = p_MatFeaturesColumWiseSamples.cols();
|
|
|
+ size_t t_iNumFeatures = p_MatFeaturesColumWiseSamples.rows();
|
|
|
+
|
|
|
+ if(p_VecLabels.size() != t_iNumSamples) // for every columnwise sample there need to be a label
|
|
|
+ return false;
|
|
|
+ p_Examples.reserve( t_iNumSamples );
|
|
|
+ const double *pDataPtr = p_MatFeaturesColumWiseSamples.getDataPointer();
|
|
|
+
|
|
|
+#ifdef NICE_USELIB_OPENMP
|
|
|
+#pragma omp parallel for default(none) shared(p_VecLabels, p_Examples, t_iNumFeatures, t_iNumSamples, pDataPtr)
|
|
|
+#endif
|
|
|
+ for (size_t i = 0; i < t_iNumSamples; i++)
|
|
|
+ {
|
|
|
+ const double *pDataIteration = pDataPtr + (i * t_iNumFeatures);
|
|
|
+ NICE::Vector *t_pVecTrainData = new NICE::Vector( (double*) pDataIteration , t_iNumFeatures, VectorBase::external);
|
|
|
+ // OBJREC::Example t_Example(t_pVecTrainData, t_fWeight);
|
|
|
+
|
|
|
+ p_Examples[i] = std::pair<int, OBJREC::Example>( p_VecLabels[i], OBJREC::Example(t_pVecTrainData, 1.0) ) ;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+}
|