Index: src/FunctionApproximation/Extractors.cpp
===================================================================
--- src/FunctionApproximation/Extractors.cpp	(revision 8aa597d50a9e1a99021b44a4fc01ec923c06490d)
+++ src/FunctionApproximation/Extractors.cpp	(revision 8aa597d50a9e1a99021b44a4fc01ec923c06490d)
@@ -0,0 +1,123 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the COPYING file or "Copyright notice" in builder.cpp for details.
+ *
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder is free software: you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation, either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    MoleCuilder is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * Extractors.cpp
+ *
+ *  Created on: 15.10.2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include <utility>
+#include <vector>
+#include <boost/assign.hpp>
+
+#include "CodePatterns/Log.hpp"
+
+#include "LinearAlgebra/Vector.hpp"
+
+#include "FunctionApproximation/Extractors.hpp"
+#include "FunctionApproximation/FunctionArgument.hpp"
+
+using namespace boost::assign;
+
+FunctionModel::arguments_t
+Extractors::_detail::gatherAllDistanceArguments(
+    const Fragment::positions_t &positions,
+    const size_t globalid)
+{
+  FunctionModel::arguments_t result;
+
+  // go through current configuration and gather all other distances
+  Fragment::positions_t::const_iterator firstpositer = positions.begin();
+  for (;firstpositer != positions.end(); ++firstpositer) {
+    Fragment::positions_t::const_iterator secondpositer = positions.begin();//firstpositer;
+    for (; secondpositer != positions.end(); ++secondpositer) {
+      if (firstpositer == secondpositer)
+        continue;
+      argument_t arg;
+      const Vector firsttemp((*firstpositer)[0],(*firstpositer)[1],(*firstpositer)[2]);
+      const Vector secondtemp((*secondpositer)[0],(*secondpositer)[1],(*secondpositer)[2]);
+      arg.distance = firsttemp.distance(secondtemp);
+      arg.indices = std::make_pair(
+          std::distance(
+              positions.begin(), firstpositer),
+          std::distance(
+              positions.begin(), secondpositer)
+          );
+      arg.globalid = globalid;
+      result.push_back(arg);
+    }
+  }
+
+  return result;
+}
+
+FunctionModel::arguments_t
+Extractors::gatherFirstDistance(
+    const Fragment& fragment,
+    const size_t index,
+    const size_t firstelement,
+    const size_t secondelement
+    ) {
+  const Fragment::charges_t charges = fragment.getCharges();
+  const Fragment::positions_t positions = fragment.getPositions();
+  typedef Fragment::charges_t::const_iterator chargeiter_t;
+  std::vector< chargeiter_t > firstpair;
+  firstpair.reserve(2);
+  firstpair +=
+      std::find(charges.begin(), charges.end(), firstelement),
+      std::find(charges.begin(), charges.end(), secondelement);
+  if ((firstpair[0] == charges.end()) || (firstpair[1] == charges.end())) {
+    // complain if tuple not found
+    ELOG(1, "Could not find pair " << firstelement << "," << secondelement
+        << " in fragment " << fragment);
+    return FunctionModel::arguments_t();
+  }
+  // convert position_t to Vector
+  std::vector< std::pair<Vector, size_t> > DistancePair;
+  for (std::vector<chargeiter_t>::const_iterator firstpairiter = firstpair.begin();
+      firstpairiter != firstpair.end(); ++firstpairiter) {
+    Fragment::positions_t::const_iterator positer = positions.begin();
+    const size_t steps = std::distance(charges.begin(), *firstpairiter);
+    std::advance(positer, steps);
+    DistancePair.push_back(
+        std::make_pair(Vector((*positer)[0], (*positer)[1], (*positer)[2]),
+            steps));
+  }
+  // finally convert Vector pair to distance-like argument
+  argument_t arg;
+  arg.indices.first = DistancePair[0].second;
+  arg.indices.second = DistancePair[1].second;
+  arg.distance = DistancePair[0].first.distance(DistancePair[1].first);
+  arg.globalid = index;
+
+  return FunctionModel::arguments_t(1, arg);
+}
Index: src/FunctionApproximation/Extractors.hpp
===================================================================
--- src/FunctionApproximation/Extractors.hpp	(revision 8aa597d50a9e1a99021b44a4fc01ec923c06490d)
+++ src/FunctionApproximation/Extractors.hpp	(revision 8aa597d50a9e1a99021b44a4fc01ec923c06490d)
@@ -0,0 +1,73 @@
+/*
+ * Extractors.hpp
+ *
+ *  Created on: 15.10.2012
+ *      Author: heber
+ */
+
+#ifndef TRAININGDATA_EXTRACTORS_HPP_
+#define TRAININGDATA_EXTRACTORS_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Fragmentation/SetValues/Fragment.hpp"
+#include "FunctionApproximation/FunctionModel.hpp"
+
+class Fragment;
+
+/** Namespace containing all simple extractor functions.
+ *
+ */
+namespace Extractors {
+  /** Namespace for some internal helper functions.
+   *
+   */
+  namespace _detail {
+    /** Gather all distances from a given set of positions.
+     *
+     * \param positins vector of positions
+     * \param globalid index to associated in argument_t with
+     * \return vector of argument_ , each with a distance
+     */
+    FunctionModel::arguments_t
+    gatherAllDistanceArguments(
+        const Fragment::positions_t &positions,
+        const size_t globalid);
+  }
+
+  /** Simple extractor of all unique pair distances of a given \a fragment.
+   *
+   * \param fragment fragment with all nuclei positions
+   * \param index index refers to the index within the global set of configurations
+   * \return vector of of argument_t containing all found distances
+   */
+  inline FunctionModel::arguments_t gatherAllDistances(
+      const Fragment& fragment,
+      const size_t index
+      ) {
+    // get distance out of Fragment
+    return _detail::gatherAllDistanceArguments(fragment.getPositions(), index);
+  }
+
+  /** Gather first distance for the two matching charges.
+   *
+   * \param fragment fragment with all nuclei positions
+   * \param index index refers to the index within the global set of configurations
+   * \param firstelement first element of pair
+   * \param secondelement second element of pair, order is reflected in indices of return argument_t
+   * \return vector of of argument_t containing all found distances
+   */
+  FunctionModel::arguments_t gatherFirstDistance(
+      const Fragment& fragment,
+      const size_t index,
+      const size_t firstelement,
+      const size_t secondelement
+      );
+
+}; /* namespace Extractors */
+
+
+#endif /* TRAININGDATA_EXTRACTORS_HPP_ */
Index: src/FunctionApproximation/Makefile.am
===================================================================
--- src/FunctionApproximation/Makefile.am	(revision 355af848a519d00e953ce3fa5d65e6236684dc1b)
+++ src/FunctionApproximation/Makefile.am	(revision 8aa597d50a9e1a99021b44a4fc01ec923c06490d)
@@ -3,10 +3,12 @@
 
 FUNCTIONAPPROXIMATIONSOURCE = \
+	FunctionApproximation/Extractors.cpp \
 	FunctionApproximation/FunctionArgument.cpp
 	
 FUNCTIONAPPROXIMATIONHEADER = \
+	FunctionApproximation/Extractors.hpp \
 	FunctionApproximation/FunctionArgument.hpp \
 	FunctionApproximation/FunctionModel.hpp
-
+	
 if CONDLEVMAR
 FUNCTIONAPPROXIMATIONSOURCE += \
Index: src/LevMartester.cpp
===================================================================
--- src/LevMartester.cpp	(revision 355af848a519d00e953ce3fa5d65e6236684dc1b)
+++ src/LevMartester.cpp	(revision 8aa597d50a9e1a99021b44a4fc01ec923c06490d)
@@ -62,4 +62,5 @@
 #include "Fragmentation/Homology/HomologyContainer.hpp"
 #include "Fragmentation/SetValues/Fragment.hpp"
+#include "FunctionApproximation/Extractors.hpp"
 #include "FunctionApproximation/FunctionApproximation.hpp"
 #include "FunctionApproximation/FunctionModel.hpp"
@@ -107,45 +108,4 @@
 }
 
-FunctionModel::arguments_t
-gatherAllDistanceArguments(
-    const Fragment::charges_t &charges,
-    const Fragment::positions_t &positions,
-    const size_t globalid)
-{
-  FunctionModel::arguments_t result;
-
-  // go through current configuration and gather all other distances
-  Fragment::charges_t::const_iterator firstchargeiter = charges.begin();
-  Fragment::positions_t::const_iterator firstpositer = positions.begin();
-  for (;firstchargeiter != charges.end();
-      ++firstchargeiter, ++firstpositer) {
-    Fragment::charges_t::const_iterator secondchargeiter = charges.begin();//firstchargeiter;
-    Fragment::positions_t::const_iterator secondpositer = positions.begin();//firstpositer;
-    for (;
-        secondchargeiter != charges.end();
-        ++secondchargeiter, ++secondpositer) {
-      if (firstchargeiter == secondchargeiter)
-        continue;
-      argument_t arg;
-      const Vector firsttemp((*firstpositer)[0],(*firstpositer)[1],(*firstpositer)[2]);
-      const Vector secondtemp((*secondpositer)[0],(*secondpositer)[1],(*secondpositer)[2]);
-      arg.distance = firsttemp.distance(secondtemp);
-      arg.indices = std::make_pair(
-          std::distance(
-              charges.begin(), firstchargeiter),
-          std::distance(
-              charges.begin(), secondchargeiter)
-          );
-      arg.globalid = globalid;
-      result.push_back(arg);
-    }
-    ASSERT( secondpositer == positions.end(),
-        "gatherAllDistanceArguments() - there are not as many positions as charges.");
-  }
-  ASSERT( firstpositer == positions.end(),
-      "gatherAllDistanceArguments() - there are not as many positions as charges.");
-
-  return result;
-}
 
 /** This function returns the elements of the sum over index "k" for an
@@ -238,75 +198,4 @@
     return angle/divisor;
 }
-
-/** Namespace containing all simple extractor functions.
- *
- */
-namespace Extractors {
-  /** Simple extractor of all unique pair distances of a given \a fragment.
-   *
-   * \param fragment fragment with all nuclei positions
-   * \param index index refers to the index within the global set of configurations
-   * \return vector of of argument_t containing all found distances
-   */
-  FunctionModel::arguments_t gatherAllDistances(
-      const Fragment& fragment,
-      const size_t index
-      ) {
-    // get distance out of Fragment
-    const Fragment::charges_t charges = fragment.getCharges();
-    const Fragment::positions_t positions = fragment.getPositions();
-    return gatherAllDistanceArguments(charges, positions, index);
-  }
-
-  /** Gather first distance for the two matching charges.
-   *
-   * \param fragment fragment with all nuclei positions
-   * \param index index refers to the index within the global set of configurations
-   * \param firstelement first element of pair
-   * \param secondelement second element of pair, order is reflected in indices of return argument_t
-   * \return vector of of argument_t containing all found distances
-   */
-  FunctionModel::arguments_t gatherFirstDistance(
-      const Fragment& fragment,
-      const size_t index,
-      const size_t firstelement,
-      const size_t secondelement
-      ) {
-    const Fragment::charges_t charges = fragment.getCharges();
-    const Fragment::positions_t positions = fragment.getPositions();
-    typedef Fragment::charges_t::const_iterator chargeiter_t;
-    std::vector< chargeiter_t > firstpair;
-    firstpair.reserve(2);
-    firstpair +=
-        std::find(charges.begin(), charges.end(), firstelement),
-        std::find(charges.begin(), charges.end(), secondelement);
-    if ((firstpair[0] == charges.end()) || (firstpair[1] == charges.end())) {
-      // complain if tuple not found
-      ELOG(1, "Could not find pair " << firstelement << "," << secondelement
-          << " in fragment " << fragment);
-      return FunctionModel::arguments_t();
-    }
-    // convert position_t to Vector
-    std::vector< std::pair<Vector, size_t> > DistancePair;
-    for (std::vector<chargeiter_t>::const_iterator firstpairiter = firstpair.begin();
-        firstpairiter != firstpair.end(); ++firstpairiter) {
-      Fragment::positions_t::const_iterator positer = positions.begin();
-      const size_t steps = std::distance(charges.begin(), *firstpairiter);
-      std::advance(positer, steps);
-      DistancePair.push_back(
-          std::make_pair(Vector((*positer)[0], (*positer)[1], (*positer)[2]),
-              steps));
-    }
-    // finally convert Vector pair to distance-like argument
-    argument_t arg;
-    arg.indices.first = DistancePair[0].second;
-    arg.indices.second = DistancePair[1].second;
-    arg.distance = DistancePair[0].first.distance(DistancePair[1].first);
-    arg.globalid = index;
-
-    return FunctionModel::arguments_t(1, arg);
-  }
-
-}; /* namespace Extractors */
 
 /** This class encapsulates the training data for a given potential function
@@ -633,5 +522,5 @@
       const Fragment::positions_t positions = fragment.getPositions();
       FunctionModel::arguments_t args =
-          gatherAllDistanceArguments(charges, positions, DistanceEnergyVector.first.size());
+          Extractors::_detail::gatherAllDistanceArguments(positions, DistanceEnergyVector.first.size());
       DistanceEnergyVector.first.push_back( args );
       DistanceEnergyVector.second.push_back( FunctionModel::results_t(1,energy-EnergySum) );
