CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 <cstdlib>
8 #include <cstring>
9 
10 namespace edm {
11  namespace {
12  struct TypeCompare {
13  typedef DataFrameContainer::id_type id_type;
14  std::vector<id_type> const& ids_;
15  TypeCompare(std::vector<id_type> const& iType): ids_(iType) {}
16  bool operator()(id_type const& iLHS, id_type const& iRHS) const {
17  return ids_[iLHS] < ids_[iRHS];
18  }
19  };
20  }
21 
23  if (size()<2) return;
24  std::vector<int> indices(size(),1);
25  indices[0]=0;
26  std::partial_sum(indices.begin(),indices.end(),indices.begin());
27  std::sort(indices.begin(), indices.end(), TypeCompare(m_ids));
28  {
29  IdContainer tmp(m_ids.size());
30  std::copy(
31  boost::make_permutation_iterator( m_ids.begin(), indices.begin() ),
32  boost::make_permutation_iterator( m_ids.end(), indices.end() ),
33  tmp.begin());
34  tmp.swap(m_ids);
35  }
36  {
37  // std::transform(indices.begin(),indices.end(),indices.begin(),
38  // boost::bind(std::multiplies<int>(),m_stride,_1));
39  DataContainer tmp(m_data.size());
40  size_type s = m_stride*sizeof(data_type);
41  for(size_type j=0, i=0; i!=indices.size(); ++i, j+=m_stride)
42  ::memcpy(&tmp[j], &m_data[indices[i]*m_stride], s);
43  tmp.swap(m_data);
44  }
45 
46  }
47 
48 }
int i
Definition: DBlmapReader.cc:9
std::vector< data_type > DataContainer
int j
Definition: DBlmapReader.cc:9
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
std::vector< id_type > IdContainer