Index: branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeVectorInterpreter.cs
===================================================================
--- branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeVectorInterpreter.cs	(revision 18214)
+++ branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeVectorInterpreter.cs	(revision 18230)
@@ -728,50 +728,54 @@
           }
         case OpCodes.SubVector: {
-          DoubleVector SubVector(DoubleVector v , double start, double end) {
-            int size = v.Count;
-            int startIdx = Math.Abs((int)Math.Round(start * (size - 1)) % size);
-            int endIdx = Math.Abs((int)Math.Round(end * (size - 1)) % size);
-            if (startIdx < endIdx) {
-              return v.SubVector(startIdx, count: endIdx - startIdx);
-            } else { // wrap around
-              var resultVector = DoubleVector.Build.Dense(size: size - (startIdx - endIdx));
-              v.CopySubVectorTo(resultVector, startIdx, 0, size - startIdx); // copy [startIdx:size] to [0:size-startIdx]
-              v.CopySubVectorTo(resultVector, 0, size - startIdx, endIdx);   // copy [0:endIdx]      to [size-startIdx:size]
-              return resultVector;
+            DoubleVector SubVector(DoubleVector v , double start, double end) { 
+              int size = v.Count;
+              int ToIdx(double x) {
+                int idx = (int)Math.Round(x * (size - 1));
+                return (idx % size + size) % size; // positive mod
+              }
+              int startIdx = ToIdx(start);
+              int endIdx = ToIdx(end);
+              if (startIdx <= endIdx) {
+                return v.SubVector(startIdx, count: endIdx - startIdx + 1); // incl end
+              } else { // wrap around
+                var resultVector = DoubleVector.Build.Dense(size: size - (startIdx - endIdx) + 1);
+                v.CopySubVectorTo(resultVector, sourceIndex: startIdx, targetIndex: 0,               count: size - startIdx); // copy [startIdx:size] to [0:size-startIdx]
+                v.CopySubVectorTo(resultVector, sourceIndex: 0,        targetIndex: size - startIdx, count: endIdx);          // copy [0:endIdx]      to [size-startIdx:size]
+                return resultVector;
+              }
             }
-          }
-          var cur = Evaluate(dataset, ref row, state, traceDict);
-          TraceEvaluation(currentInstr, cur);
-          return FunctionApply(cur,
-            s => s,
-            v => {
-              var node = (IWindowedSymbolTreeNode)currentInstr.dynamicNode;
-              return SubVector(v, node.Offset, node.Length);
-            });
+            var cur = Evaluate(dataset, ref row, state, traceDict);
+            TraceEvaluation(currentInstr, cur);
+            return FunctionApply(cur,
+              s => s,
+              v => {
+                var node = (IWindowedSymbolTreeNode)currentInstr.dynamicNode;
+                return SubVector(v, node.Offset, node.Length);
+              });
           }
         case OpCodes.SubVectorSubtree: {
-          DoubleVector SubVector(DoubleVector v, double start, double end) {
-            int Mod(int x, int m) => (x % m + m) % m;
-            int startIdx = Mod((int)Math.Round(start * v.Count), v.Count);
-            int endIdx = Mod((int)Math.Round(end * v.Count), v.Count);
-            int size = v.Count;
-            if (startIdx < endIdx) {
-              return v.SubVector(startIdx, count: endIdx - startIdx);
-            } else { // wrap around
-              var resultVector = DoubleVector.Build.Dense(size: size - (startIdx - endIdx));
-              v.CopySubVectorTo(resultVector, startIdx, 0, size - startIdx); // copy [startIdx:size] to [0:size-startIdx]
-              v.CopySubVectorTo(resultVector, 0, size - startIdx, endIdx);   // copy [0:endIdx]      to [size-startIdx:size]
-              return resultVector;
+            DoubleVector SubVector(DoubleVector v, double start, double end) {
+              int Mod(int x, int m) => (x % m + m) % m;
+              int startIdx = Mod((int)Math.Round(start * v.Count), v.Count);
+              int endIdx = Mod((int)Math.Round(end * v.Count), v.Count);
+              int size = v.Count;
+              if (startIdx < endIdx) {
+                return v.SubVector(startIdx, count: endIdx - startIdx);
+              } else { // wrap around
+                var resultVector = DoubleVector.Build.Dense(size: size - (startIdx - endIdx));
+                v.CopySubVectorTo(resultVector, startIdx, 0, size - startIdx); // copy [startIdx:size] to [0:size-startIdx]
+                v.CopySubVectorTo(resultVector, 0, size - startIdx, endIdx);   // copy [0:endIdx]      to [size-startIdx:size]
+                return resultVector;
+              }
             }
-          }
-          var cur = Evaluate(dataset, ref row, state, traceDict);
-          var offset = Evaluate(dataset, ref row, state, traceDict);
-          var length = Evaluate(dataset, ref row, state, traceDict);
-          TraceEvaluation(currentInstr, cur);
-          return FunctionApply(cur,
-            s => s,
-            v => SubVector(v, offset.Scalar, length.Scalar)
-          );
-        }
+            var cur = Evaluate(dataset, ref row, state, traceDict);
+            var offset = Evaluate(dataset, ref row, state, traceDict);
+            var length = Evaluate(dataset, ref row, state, traceDict);
+            TraceEvaluation(currentInstr, cur);
+            return FunctionApply(cur,
+              s => s,
+              v => SubVector(v, offset.Scalar, length.Scalar)
+            );
+          }
         case OpCodes.Variable: {
             if (row < 0 || row >= dataset.Rows) return EvaluationResult.NaN;
