CMS 3D CMS Logo

DataFrameContainer.cc
Go to the documentation of this file.
2 
3 #include <boost/iterator/permutation_iterator.hpp>
4 
5 #include <algorithm>
6 #include <numeric>
7 #include <cstring>
8 
9 namespace edm {
10  namespace {
11  struct TypeCompare {
12  typedef DataFrameContainer::id_type id_type;
13  std::vector<id_type> const& ids_;
14  TypeCompare(std::vector<id_type> const& iType): ids_(iType) {}
15  bool operator()(id_type const& iLHS, id_type const& iRHS) const {
16  return ids_[iLHS] < ids_[iRHS];
17  }
18  };
19  }
20 
22  if (size()<2) return;
23  std::vector<int> indices(size(),1);
24  indices[0]=0;
25  std::partial_sum(indices.begin(),indices.end(),indices.begin());
26  std::sort(indices.begin(), indices.end(), TypeCompare(m_ids));
27  {
28  IdContainer tmp(m_ids.size());
29  std::copy(
30  boost::make_permutation_iterator( m_ids.begin(), indices.begin() ),
31  boost::make_permutation_iterator( m_ids.end(), indices.end() ),
32  tmp.begin());
33  tmp.swap(m_ids);
34  }
35  {
36  // std::transform(indices.begin(),indices.end(),indices.begin(),
37  // std::bind(std::multiplies<int>(),m_stride,std::placeholders::_1));
38  DataContainer tmp(m_data.size());
39  size_type s = m_stride*sizeof(data_type);
40  for(size_type j=0, i=0; i!=indices.size(); ++i, j+=m_stride)
41  ::memcpy(&tmp[j], &m_data[indices[i]*m_stride], s);
42  tmp.swap(m_data);
43  }
44 
45  }
46 
47 }
size
Write out results.
def copy(args, dbName)
std::vector< data_type > DataContainer
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
std::vector< id_type > IdContainer