Index: src/Fragmentation/Summation/SetValues/SamplingGrid.cpp
===================================================================
--- src/Fragmentation/Summation/SetValues/SamplingGrid.cpp	(revision 0287906894892db049741ca98305c9ab54844136)
+++ src/Fragmentation/Summation/SetValues/SamplingGrid.cpp	(revision 5b1e5e3171f6df6d1ae7f2ebc67e13bbf15c764b)
@@ -51,5 +51,5 @@
 
 // static instances
-const double SamplingGrid::zeroOffset[3] = { 0., 0., 0. };
+const double SamplingGrid::zeroOffset[NDIM] = { 0., 0., 0. };
 
 SamplingGrid::SamplingGrid() :
@@ -61,6 +61,6 @@
 }
 
-SamplingGrid::SamplingGrid(const double _begin[3],
-    const double _end[3],
+SamplingGrid::SamplingGrid(const double _begin[NDIM],
+    const double _end[NDIM],
     const int _level) :
   SamplingGridProperties(_begin, _end, _level)
@@ -71,6 +71,6 @@
 }
 
-SamplingGrid::SamplingGrid(const double _begin[3],
-    const double _end[3],
+SamplingGrid::SamplingGrid(const double _begin[NDIM],
+    const double _end[NDIM],
     const int _level,
     const sampledvalues_t &_sampled_grid) :
@@ -119,5 +119,5 @@
   status &= (static_cast<const SamplingGridProperties &>(*this) ==
       static_cast<const SamplingGridProperties &>(_props));
-  for(size_t i = 0; i<3; ++i) {
+  for(size_t i = 0; i<NDIM; ++i) {
     status &= begin_window[i] == _props.begin_window[i];
     status &= end_window[i] == _props.end_window[i];
@@ -160,8 +160,8 @@
   if (isCompatible(other)) {
     /// get minimum of window
-    double min_begin_window[3];
-    double min_end_window[3];
+    double min_begin_window[NDIM];
+    double min_end_window[NDIM];
     bool doShrink = false;
-    for (size_t index=0; index<3;++index) {
+    for (size_t index=0; index<NDIM;++index) {
       if (begin_window[index] <= other.begin_window[index]) {
         min_begin_window[index] = other.begin_window[index];
@@ -201,8 +201,8 @@
   if (isCompatible(other)) {
     /// get maximum of window
-    double max_begin_window[3];
-    double max_end_window[3];
+    double max_begin_window[NDIM];
+    double max_end_window[NDIM];
     bool doExtend = false;
-    for (size_t index=0; index<3;++index) {
+    for (size_t index=0; index<NDIM;++index) {
       if (begin_window[index] >= other.begin_window[index]) {
         max_begin_window[index] = other.begin_window[index];
@@ -273,8 +273,8 @@
 }
 void SamplingGrid::setWindowSize(
-    const double _begin_window[3],
-    const double _end_window[3])
-{
-  for (size_t index=0;index<3;++index) {
+    const double _begin_window[NDIM],
+    const double _end_window[NDIM])
+{
+  for (size_t index=0;index<NDIM;++index) {
     begin_window[index] = getNearestLowerGridPoint(_begin_window[index], index);
     ASSERT( begin_window[index] >= begin[index],
@@ -289,6 +289,6 @@
 
 void SamplingGrid::setWindow(
-    const double _begin_window[3],
-    const double _end_window[3])
+    const double _begin_window[NDIM],
+    const double _end_window[NDIM])
 {
   setWindowSize(_begin_window, _end_window);
@@ -299,6 +299,6 @@
 
 void SamplingGrid::setDomain(
-    const double _begin[3],
-    const double _end[3])
+    const double _begin[NDIM],
+    const double _end[NDIM])
 {
   setDomainSize(_begin, _end);
@@ -309,9 +309,9 @@
 
 void SamplingGrid::extendWindow(
-    const double _begin_window[3],
-    const double _end_window[3])
+    const double _begin_window[NDIM],
+    const double _end_window[NDIM])
 {
 #ifndef NDEBUG
-  for(size_t index=0;index < 3; ++index) {
+  for(size_t index=0;index < NDIM; ++index) {
     // check that we truly have to extend the window
     ASSERT ( begin_window[index] >= _begin_window[index],
@@ -332,7 +332,7 @@
 #endif
   // copy old window size and values
-  double old_begin_window[3];
-  double old_end_window[3];
-  for(size_t index=0;index<3;++index) {
+  double old_begin_window[NDIM];
+  double old_end_window[NDIM];
+  for(size_t index=0;index<NDIM;++index) {
     old_begin_window[index] = begin_window[index];
     old_end_window[index] = end_window[index];
@@ -347,9 +347,9 @@
 
 void SamplingGrid::shrinkWindow(
-    const double _begin_window[3],
-    const double _end_window[3])
+    const double _begin_window[NDIM],
+    const double _end_window[NDIM])
 {
 #ifndef NDEBUG
-  for(size_t index=0;index < 3; ++index) {
+  for(size_t index=0;index < NDIM; ++index) {
     // check that we truly have to shrink the window
     ASSERT ( begin_window[index] <= _begin_window[index],
@@ -370,7 +370,7 @@
 #endif
   // copy old window size and values
-  double old_begin_window[3];
-  double old_end_window[3];
-  for(size_t index=0;index<3;++index) {
+  double old_begin_window[NDIM];
+  double old_end_window[NDIM];
+  for(size_t index=0;index<NDIM;++index) {
     old_begin_window[index] = begin_window[index];
     old_end_window[index] = end_window[index];
@@ -393,6 +393,6 @@
 
 void SamplingGrid::addOntoWindow(
-    const double _begin_window[3],
-    const double _end_window[3],
+    const double _begin_window[NDIM],
+    const double _end_window[NDIM],
     const sampledvalues_t &_sampled_grid,
     const double prefactor)
@@ -410,6 +410,6 @@
 
 void SamplingGrid::addIntoWindow(
-    const double _begin_window[3],
-    const double _end_window[3],
+    const double _begin_window[NDIM],
+    const double _end_window[NDIM],
     const sampledvalues_t &_sampled_grid,
     const double prefactor)
@@ -440,5 +440,5 @@
       (std::numeric_limits<size_t>::round_style == std::round_toward_zero) ?
           0.5 : 0.; // need offset to get to round_toward_nearest behavior
-  for(size_t index=0;index<3;++index) {
+  for(size_t index=0;index<NDIM;++index) {
     if (fabs(end[index] - begin[index]) > std::numeric_limits<double>::epsilon()*1e4) {
       // we refrain from using floor/ceil as the window's starts and ends,
@@ -465,8 +465,8 @@
 
 void SamplingGrid::addWindowOntoWindow(
-    const double larger_wbegin[3],
-    const double larger_wend[3],
-    const double smaller_wbegin[3],
-    const double smaller_wend[3],
+    const double larger_wbegin[NDIM],
+    const double larger_wend[NDIM],
+    const double smaller_wbegin[NDIM],
+    const double smaller_wend[NDIM],
     sampledvalues_t &dest_sampled_grid,
     const sampledvalues_t &source_sampled_grid,
@@ -475,5 +475,5 @@
 {
 #ifndef NDEBUG
-  for(size_t index=0;index<3;++index) {
+  for(size_t index=0;index<NDIM;++index) {
     ASSERT( smaller_wbegin[index] >= larger_wbegin[index],
         "SamplingGrid::addWindowOntoWindow() - given smaller window starts earlier than larger window in component "
@@ -485,8 +485,8 @@
 #endif
   // the only issue are indices
-  size_t pre_offset[3];
-  size_t post_offset[3];
-  size_t length[3];
-  size_t total[3];
+  size_t pre_offset[NDIM];
+  size_t post_offset[NDIM];
+  size_t length[NDIM];
+  size_t total[NDIM];
   getDiscreteWindowIndices(
       larger_wbegin, larger_wend,
@@ -526,5 +526,5 @@
   }
 #endif
-  size_t N[3];
+  size_t N[NDIM];
 //  size_t counter = 0;
   sampledvalues_t::iterator destiter = dest_sampled_grid.begin();
@@ -585,5 +585,5 @@
   if (status) {
     // compare windows
-    for (size_t i=0; i<3; ++i) {
+    for (size_t i=0; i<NDIM; ++i) {
       status &= begin_window[i] == other.begin_window[i];
       status &= end_window[i] == other.end_window[i];
Index: src/Fragmentation/Summation/SetValues/SamplingGrid.hpp
===================================================================
--- src/Fragmentation/Summation/SetValues/SamplingGrid.hpp	(revision 0287906894892db049741ca98305c9ab54844136)
+++ src/Fragmentation/Summation/SetValues/SamplingGrid.hpp	(revision 5b1e5e3171f6df6d1ae7f2ebc67e13bbf15c764b)
@@ -20,4 +20,6 @@
 #include "boost/serialization/export.hpp"
 #include "boost/serialization/vector.hpp"
+
+#include "LinearAlgebra/defs.hpp"
 
 #include "Fragmentation/Summation/SetValues/SamplingGridProperties.hpp"
@@ -51,6 +53,6 @@
    * \param _sampled_grid sample points
    */
-  SamplingGrid(const double _begin[3],
-      const double _end[3],
+  SamplingGrid(const double _begin[NDIM],
+      const double _end[NDIM],
       const int _level,
       const sampledvalues_t &_sampled_grid);
@@ -64,6 +66,6 @@
    * \param _level number of grid points in \f$2^{\mathrm{level}}\f$
    */
-  SamplingGrid(const double _begin[3],
-      const double _end[3],
+  SamplingGrid(const double _begin[NDIM],
+      const double _end[NDIM],
       const int _level);
 
@@ -211,5 +213,5 @@
    * \param _end_window end of window
    */
-  void setWindow(const double _begin_window[3], const double _end_window[3]);
+  void setWindow(const double _begin_window[NDIM], const double _end_window[NDIM]);
 
   /** Helper function to convert begin_window and end_window that are w.r.t.
@@ -255,5 +257,5 @@
    * \param _end end of window
    */
-  void setDomain(const double _begin[3], const double _end[3]);
+  void setDomain(const double _begin[NDIM], const double _end[NDIM]);
 
   /** Sets the size of the domain.
@@ -264,5 +266,5 @@
    * \param _end end of domain
    */
-  void setDomainSize(const double _begin[3], const double _end[3]);
+  void setDomainSize(const double _begin[NDIM], const double _end[NDIM]);
 
   /** Extends the window while keeping the values.
@@ -271,5 +273,5 @@
    * \param _end_window new end of window
    */
-  void extendWindow(const double _begin_window[3], const double _end_window[3]);
+  void extendWindow(const double _begin_window[NDIM], const double _end_window[NDIM]);
 
   /** Shrinks the window while keeping the values.
@@ -278,5 +280,5 @@
    * \param _end_window new end of window
    */
-  void shrinkWindow(const double _begin_window[3], const double _end_window[3]);
+  void shrinkWindow(const double _begin_window[NDIM], const double _end_window[NDIM]);
 
   /** Adds another (smaller) window onto the one in this instance.
@@ -290,6 +292,6 @@
    */
   void addOntoWindow(
-      const double _begin_window[3],
-      const double _end_window[3],
+      const double _begin_window[NDIM],
+      const double _end_window[NDIM],
       const sampledvalues_t &_sampled_grid,
       const double prefactor);
@@ -305,6 +307,6 @@
    */
   void addIntoWindow(
-      const double _begin_window[3],
-      const double _end_window[3],
+      const double _begin_window[NDIM],
+      const double _end_window[NDIM],
       const sampledvalues_t &_sampled_grid,
       const double prefactor);
@@ -334,8 +336,8 @@
    */
   void addWindowOntoWindow(
-      const double larger_wbegin[3],
-      const double larger_wend[3],
-      const double smaller_wbegin[3],
-      const double smaller_wend[3],
+      const double larger_wbegin[NDIM],
+      const double larger_wend[NDIM],
+      const double smaller_wbegin[NDIM],
+      const double smaller_wend[NDIM],
       sampledvalues_t &dest_sampled_grid,
       const sampledvalues_t &source_sampled_grid,
@@ -360,5 +362,5 @@
    * \param _end_window end of window
    */
-  void setWindowSize(const double _begin_window[3], const double _end_window[3]);
+  void setWindowSize(const double _begin_window[NDIM], const double _end_window[NDIM]);
 
 public:
@@ -370,7 +372,7 @@
 
   //!> start of the window relative to SamplingGridProperties::begin and SamplingGridProperties::size
-  double begin_window[3];
+  double begin_window[NDIM];
   //!> end of the window relative to SamplingGridProperties::begin and SamplingGridProperties::size
-  double end_window[3];
+  double end_window[NDIM];
 
 private:
@@ -384,5 +386,5 @@
     ar & boost::serialization::base_object<SamplingGridProperties>(*this);
     ar & const_cast< sampledvalues_t &>(sampled_grid);
-    for(size_t i=0;i<3;++i) {
+    for(size_t i=0;i<NDIM;++i) {
       ar & begin_window[i];
       ar & end_window[i];
@@ -391,5 +393,5 @@
 
   //!> static typedef to use in cstor when no initial values are given
-  static const double zeroOffset[3];
+  static const double zeroOffset[NDIM];
 };
 
Index: src/Fragmentation/Summation/SetValues/SamplingGridProperties.cpp
===================================================================
--- src/Fragmentation/Summation/SetValues/SamplingGridProperties.cpp	(revision 0287906894892db049741ca98305c9ab54844136)
+++ src/Fragmentation/Summation/SetValues/SamplingGridProperties.cpp	(revision 5b1e5e3171f6df6d1ae7f2ebc67e13bbf15c764b)
@@ -44,10 +44,10 @@
 
 SamplingGridProperties::SamplingGridProperties(
-    const double _begin[3],
-    const double _end[3],
+    const double _begin[NDIM],
+    const double _end[NDIM],
     const int _level) :
   level(_level)
 {
-  for(size_t i=0; i<3; ++i) {
+  for(size_t i=0; i<NDIM; ++i) {
     begin[i] = _begin[i];
     end[i] = _end[i];
@@ -58,5 +58,5 @@
   level(_props.level)
 {
-  for(size_t i=0; i<3; ++i) {
+  for(size_t i=0; i<NDIM; ++i) {
     begin[i] = _props.begin[i];
     end[i] = _props.end[i];
@@ -67,5 +67,5 @@
   level(0)
 {
-  for(size_t i=0; i<3; ++i) {
+  for(size_t i=0; i<NDIM; ++i) {
     begin[i] = 0.;
     end[i] = 0.;
@@ -80,5 +80,5 @@
   // check for self-assignment
   if (this != &other) {
-    for(size_t index=0; index<3; ++index) {
+    for(size_t index=0; index<NDIM; ++index) {
       begin[index] = other.begin[index];
       end[index] = other.end[index];
@@ -92,5 +92,5 @@
 {
   bool status = true;
-  for (size_t i=0; i<3; ++i) {
+  for (size_t i=0; i<NDIM; ++i) {
     status &= begin[i] == _props.begin[i];
     status &= end[i] == _props.end[i];
Index: src/Fragmentation/Summation/SetValues/SamplingGridProperties.hpp
===================================================================
--- src/Fragmentation/Summation/SetValues/SamplingGridProperties.hpp	(revision 0287906894892db049741ca98305c9ab54844136)
+++ src/Fragmentation/Summation/SetValues/SamplingGridProperties.hpp	(revision 5b1e5e3171f6df6d1ae7f2ebc67e13bbf15c764b)
@@ -17,4 +17,6 @@
 #include "boost/serialization/array.hpp"
 
+#include "LinearAlgebra/defs.hpp"
+
 #include "Fragmentation/Summation/ZeroInstance.hpp"
 
@@ -31,6 +33,6 @@
    */
   SamplingGridProperties(
-      const double _begin[3],
-      const double _end[3],
+      const double _begin[NDIM],
+      const double _end[NDIM],
       const int _level);
 
@@ -132,7 +134,7 @@
 public:
   //!> offset of grid
-  double begin[3];
+  double begin[NDIM];
   //!> size of grid, i.e. edge length per axis of domain
-  double end[3];
+  double end[NDIM];
   //!> level, i.e. \f$2^{\mathrm{level}}\f$ grid points per axis per unit(!) length
   int level;
@@ -146,7 +148,7 @@
   {
     int i;
-    for (i=0; i<3; ++i)
+    for (i=0; i<NDIM; ++i)
       ar & begin[i];
-    for (i=0; i<3; ++i)
+    for (i=0; i<NDIM; ++i)
       ar & end[i];
     ar & level;
Index: src/Fragmentation/Summation/SetValues/SamplingGridProperties_inline.hpp
===================================================================
--- src/Fragmentation/Summation/SetValues/SamplingGridProperties_inline.hpp	(revision 0287906894892db049741ca98305c9ab54844136)
+++ src/Fragmentation/Summation/SetValues/SamplingGridProperties_inline.hpp	(revision 5b1e5e3171f6df6d1ae7f2ebc67e13bbf15c764b)
@@ -24,5 +24,5 @@
 {
   double volume = 1.;
-  for (size_t i=0;i<3;++i)
+  for (size_t i=0;i<NDIM;++i)
     volume *= end[i]-begin[i];
   return volume;
@@ -34,5 +34,5 @@
 const size_t SamplingGridProperties::getTotalGridPoints() const
 {
-  return pow(getGridPointsPerAxis(),3);
+  return pow(getGridPointsPerAxis(),(int)NDIM);
 }
 
Index: src/Fragmentation/Summation/SetValues/SamplingGrid_inline.hpp
===================================================================
--- src/Fragmentation/Summation/SetValues/SamplingGrid_inline.hpp	(revision 0287906894892db049741ca98305c9ab54844136)
+++ src/Fragmentation/Summation/SetValues/SamplingGrid_inline.hpp	(revision 5b1e5e3171f6df6d1ae7f2ebc67e13bbf15c764b)
@@ -22,5 +22,5 @@
 {
   double volume = 1.;
-  for (size_t i=0;i<3;++i)
+  for (size_t i=0;i<NDIM;++i)
     volume *= end_window[i]-begin_window[i];
   return volume;
@@ -49,8 +49,8 @@
 #endif
 void SamplingGrid::setDomainSize(
-    const double _begin[3],
-    const double _end[3])
+    const double _begin[NDIM],
+    const double _end[NDIM])
 {
-  for (size_t index=0;index<3;++index) {
+  for (size_t index=0;index<NDIM;++index) {
     begin[index] = _begin[index];
     end[index] = _end[index];
Index: src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.cpp
===================================================================
--- src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.cpp	(revision 0287906894892db049741ca98305c9ab54844136)
+++ src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.cpp	(revision 5b1e5e3171f6df6d1ae7f2ebc67e13bbf15c764b)
@@ -62,6 +62,6 @@
 const double grid_value=1.;
 
-#define NUMBEROFSAMPLES(n) (size_t)(pow(pow(2,n),3))
-#define DOMAINVOLUME(l) (size_t)pow(l,3)
+#define NUMBEROFSAMPLES(n) (size_t)(pow(pow(2,n),(int)NDIM))
+#define DOMAINVOLUME(l) (size_t)pow(l,(int)NDIM)
 
 // Registers the fixture into the 'registry'
@@ -75,6 +75,6 @@
 
   // create the grid
-  const double begin[3] = { 0., 0., 0. };
-  const double end[3] = { 1., 1., 1. };
+  const double begin[NDIM] = { 0., 0., 0. };
+  const double end[NDIM] = { 1., 1., 1. };
   for (size_t i=0; i< DOMAINVOLUME(1)*NUMBEROFSAMPLES(2); ++i)
     values += grid_value;
@@ -94,6 +94,6 @@
 {
   // check illegal grid
-  const double begin[3] = { 0., 0., 0. };
-  const double end[3] = { 2., 2., 2. };
+  const double begin[NDIM] = { 0., 0., 0. };
+  const double end[NDIM] = { 2., 2., 2. };
   SamplingGridProperties illegal_props(begin, end, 5);
   SamplingGridProperties legal_props(begin, end, 2);
@@ -125,8 +125,8 @@
 void SamplingGridTest::isCongruent_Test()
 {
-  const double begin[3] = { 0., 0., 0. };
-  const double end[3] = { 2., 2., 2. };
-  const double otherbegin[3] = { 0.1, 0.1, 0.1 };
-  const double otherend[3] = { 1., 1., 1. };
+  const double begin[NDIM] = { 0., 0., 0. };
+  const double end[NDIM] = { 2., 2., 2. };
+  const double otherbegin[NDIM] = { 0.1, 0.1, 0.1 };
+  const double otherend[NDIM] = { 1., 1., 1. };
   SamplingGridProperties illegal_begin_props(otherbegin, end, 5);
   SamplingGridProperties illegal_end_props(begin, otherend, 5);
@@ -135,8 +135,8 @@
 
   // differing windows
-//  const double begin_window[3] = { 0.5, 0.5, 0.5 };
-//  const double end_window[3] = { 1., 1., 1. };
-  const double otherbegin_window[3] = { 0.45, 0.45, 0.45 };
-  const double otherend_window[3] = { 1.05, 1.05, 1.05 };
+//  const double begin_window[NDIM] = { 0.5, 0.5, 0.5 };
+//  const double end_window[NDIM] = { 1., 1., 1. };
+  const double otherbegin_window[NDIM] = { 0.45, 0.45, 0.45 };
+  const double otherend_window[NDIM] = { 1.05, 1.05, 1.05 };
 
   // check that incompatible grid are also incongruent
@@ -238,6 +238,6 @@
 
   // create another one and check its size, too
-  const double begin[3] = { 0., 0., 0. };
-  const double end[3] = { 1., 1., 1. };
+  const double begin[NDIM] = { 0., 0., 0. };
+  const double end[NDIM] = { 1., 1., 1. };
   for (size_t level = 3; level<=6; ++level) {
     values.clear();
@@ -257,13 +257,13 @@
 {
   // we have a grid with size of one, extend to twice the size and check
-  const double begin[3] = { 0., 0., 0. };
+  const double begin[NDIM] = { 0., 0., 0. };
   const double size = 2.;
-  const double end[3] = { size, size, size };
-  double offset[3];
+  const double end[NDIM] = { size, size, size };
+  double offset[NDIM];
   for (offset[0] = 0.; offset[0] <= 1.; offset[0] += .5)
     for (offset[1] = 0.; offset[1] <= 1.; offset[1] += .5)
       for (offset[2] = 0.; offset[2] <= 1.; offset[2] += .5) {
-        const double window_begin[3] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
-        const double window_end[3] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]};
+        const double window_begin[NDIM] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
+        const double window_end[NDIM] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]};
         SamplingGrid newgrid(begin, end, 2);
         newgrid.setWindowSize(window_begin, window_end);
@@ -292,17 +292,17 @@
 {
   std::cout << "SamplingGridTest::extendWindow_asymmetric_Test()" << std::endl;
-  const double begin[3] = { 0., 0., 0. };
-  const double end[3] = { 2., 2., 2. };
-  double offset[3];
+  const double begin[NDIM] = { 0., 0., 0. };
+  const double end[NDIM] = { 2., 2., 2. };
+  double offset[NDIM];
   for (offset[0] = 0.; offset[0] <= 1.; offset[0] += .5)
     for (offset[1] = 0.; offset[1] <= 1.; offset[1] += .5)
       for (offset[2] = 0.; offset[2] <= 1.; offset[2] += .5) {
-        const double window_begin[3] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
-        const double window_end[3] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]};
+        const double window_begin[NDIM] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
+        const double window_end[NDIM] = { 1.+offset[0], 1.+offset[1], 1.+offset[2]};
         SamplingGrid newgrid(begin, end, 2);
         CPPUNIT_ASSERT_EQUAL( (size_t)0, newgrid.getWindowGridPoints() );
         newgrid.setWindowSize(window_begin, window_end);
         // window size is only half of domain size
-        const size_t max_samples = NUMBEROFSAMPLES(newgrid.level)*pow(0.5,3);
+        const size_t max_samples = NUMBEROFSAMPLES(newgrid.level)*pow(0.5,(int)NDIM);
         for (size_t i=0; i< max_samples; ++i)
           newgrid.sampled_grid += grid_value*i;
@@ -326,11 +326,11 @@
   // create values for half-sized window
   values.clear();
-  for (size_t i=0; i< (size_t)pow(.5*pow(2,2),3); ++i)
+  for (size_t i=0; i< (size_t)pow(.5*pow(2,2),(int)NDIM); ++i)
     values += grid_value;
 
   // check that too large a window throws
 #ifndef NDEBUG
-  const double begin[3] = { .5, .5, .5 };
-  const double wrongend[3] = { 1.5, 1.5, 1.5 };
+  const double begin[NDIM] = { .5, .5, .5 };
+  const double wrongend[NDIM] = { 1.5, 1.5, 1.5 };
   std::cout << "The following assertion is intended and does not indicate a failure of the test." << std::endl;
   CPPUNIT_ASSERT_THROW( grid->addOntoWindow(begin, wrongend, values, +1.), Assert::AssertionFailure );
@@ -338,10 +338,10 @@
 
   // create another window from (.5,.5,.5) to (1., 1., 1.)
-  double offset[3];
+  double offset[NDIM];
   for (offset[0] = 0.; offset[0] <= .5; offset[0] += .5)
     for (offset[1] = 0.; offset[1] <= .5; offset[1] += .5)
       for (offset[2] = 0.; offset[2] <= .5; offset[2] += .5) {
-        const double window_begin[3] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
-        const double window_end[3] = { .5+offset[0], .5+offset[1], .5+offset[2]};
+        const double window_begin[NDIM] = { 0.+offset[0], 0.+offset[1], 0.+offset[2]};
+        const double window_end[NDIM] = { .5+offset[0], .5+offset[1], .5+offset[2]};
 
         SamplingGrid newgrid(*grid);
@@ -350,5 +350,5 @@
 
         // check integral to be one and one eighth times the old value
-        CPPUNIT_ASSERT_EQUAL( (1.+pow(.5,3))*grid_value, newgrid.integral() );
+        CPPUNIT_ASSERT_EQUAL( (1.+pow(.5,(int)NDIM))*grid_value, newgrid.integral() );
       }
 }
@@ -383,6 +383,6 @@
 {
   // create other grid
-  const double begin[3] = { 0., 0., 0. };
-  const double end[3] = { 1., 1., 1. };
+  const double begin[NDIM] = { 0., 0., 0. };
+  const double end[NDIM] = { 1., 1., 1. };
   SamplingGrid::sampledvalues_t othervalues;
   const double othergrid_value = 1.5;
@@ -407,6 +407,6 @@
 {
   // create other grid
-  const double begin[3] = { 0., 0., 0. };
-  const double end[3] = { 1., 1., 1. };
+  const double begin[NDIM] = { 0., 0., 0. };
+  const double end[NDIM] = { 1., 1., 1. };
   SamplingGrid::sampledvalues_t othervalues;
   const double othergrid_value = 1.5;
@@ -431,12 +431,12 @@
 void SamplingGridTest::equality_Test()
 {
-  const double begin[3] = { 0., 0., 0. };
-  const double otherbegin[3] = { .5, 0.1, -0.5 };
-  const double end[3] = { 1., 1., 1. };
-  const double otherend[3] = { 2., 2., 2. };
-  const double begin_window[3] = { 0., 0., 0. };
-  const double otherbegin_window[3] = { .75, 0.1, 0. };
-  const double end_window[3] = { 1., 1., 1. };
-  const double otherend_window[3] = { .9, .9, .9 };
+  const double begin[NDIM] = { 0., 0., 0. };
+  const double otherbegin[NDIM] = { .5, 0.1, -0.5 };
+  const double end[NDIM] = { 1., 1., 1. };
+  const double otherend[NDIM] = { 2., 2., 2. };
+  const double begin_window[NDIM] = { 0., 0., 0. };
+  const double otherbegin_window[NDIM] = { .75, 0.1, 0. };
+  const double end_window[NDIM] = { 1., 1., 1. };
+  const double otherend_window[NDIM] = { .9, .9, .9 };
 
   // create other grid
@@ -515,2 +515,3 @@
   delete samegrid;
 }
+
