ALPSCore reference
rectangularize.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1998-2018 ALPS Collaboration. See COPYRIGHT.TXT
3  * All rights reserved. Use is subject to license terms. See LICENSE.TXT
4  * For use in publications, see ACKNOWLEDGE.TXT
5  */
6 
11 #ifndef ALPS_NUMERIC_RECTANGULARIZE_HPP_08679765945f4171af5c396beff05503
12 #define ALPS_NUMERIC_RECTANGULARIZE_HPP_08679765945f4171af5c396beff05503
13 
14 #include <vector>
15 
16 namespace alps {
17  namespace numeric {
18 
20  template <typename T>
21  void rectangularize(const T&) {}
22 
24 
29  template <typename T>
30  void rectangularize(std::vector< std::vector<T> >& vec)
31  {
32  std::size_t mx_size=0;
33  for(std::vector<T>& val: vec) {
34  // FIXME: // would be needed for 3-tensors, but not quite working:
35  // FIXME: rectangularize(val);
36  if (mx_size<val.size()) mx_size=val.size();
37  }
38  for(std::vector<T>& val: vec) {
39  val.resize(mx_size);
40  }
41  }
42 
43  }
44 }
45 
46 #endif /* ALPS_NUMERIC_RECTANGULARIZE_HPP_08679765945f4171af5c396beff05503 */
void rectangularize(const T &)
Make sure that vector-of-vectors is a rectangular matrix (generic dummy template) ...