Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs
===================================================================
--- branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs	(revision 8486)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/SymbolicDataAnalysisExpressionTreeILEmittingInterpreter.cs	(revision 8798)
@@ -565,10 +565,10 @@
         case OpCodes.Variable: {
             VariableTreeNode varNode = (VariableTreeNode)currentInstr.dynamicNode;
+            il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array
+            il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.iArg0);
+            // load correct column of the current variable
+            il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref);
+            il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // rowIndex
             if (!state.InLaggedContext) {
-              il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array
-              il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.iArg0);
-              // load correct column of the current variable
-              il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref);
-              il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // rowIndex
               il.Emit(System.Reflection.Emit.OpCodes.Call, listGetValue);
               il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, varNode.Weight); // load weight
@@ -577,7 +577,4 @@
               var nanResult = il.DefineLabel();
               var normalResult = il.DefineLabel();
-              var cachedValue = il.DefineLabel();
-              var multiplyValue = il.DefineLabel();
-              il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // rowIndex
               il.Emit(System.Reflection.Emit.OpCodes.Dup);
               il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4_0);
@@ -586,21 +583,5 @@
               il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, ds.Rows);
               il.Emit(System.Reflection.Emit.OpCodes.Bge, nanResult);
-              il.Emit(System.Reflection.Emit.OpCodes.Ldarg_3);
-              il.Emit(System.Reflection.Emit.OpCodes.Bge, cachedValue);
-              il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array
-              il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.iArg0);
-              il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref);
-              il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // rowIndex
               il.Emit(System.Reflection.Emit.OpCodes.Call, listGetValue);
-              il.Emit(System.Reflection.Emit.OpCodes.Br, multiplyValue);
-              il.MarkLabel(cachedValue);
-              il.Emit(System.Reflection.Emit.OpCodes.Ldarg_2); // load cached values array
-              il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.iArg0);
-              il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref);
-              il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // rowIndex
-              il.Emit(System.Reflection.Emit.OpCodes.Ldarg_3); // startRow
-              il.Emit(System.Reflection.Emit.OpCodes.Sub); // startRow
-              il.Emit(System.Reflection.Emit.OpCodes.Call, listGetValue);
-              il.MarkLabel(multiplyValue);
               il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, varNode.Weight); // load weight
               il.Emit(System.Reflection.Emit.OpCodes.Mul);
@@ -608,4 +589,5 @@
               il.MarkLabel(nanResult);
               il.Emit(System.Reflection.Emit.OpCodes.Pop); // rowIndex
+              il.Emit(System.Reflection.Emit.OpCodes.Pop); // column reference
               il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, double.NaN);
               il.MarkLabel(normalResult);
@@ -616,7 +598,9 @@
             var nanResult = il.DefineLabel();
             var normalResult = il.DefineLabel();
-            var cachedValue = il.DefineLabel();
-            var multiplyValue = il.DefineLabel();
             LaggedVariableTreeNode varNode = (LaggedVariableTreeNode)currentInstr.dynamicNode;
+            il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array
+            il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.iArg0);
+            // load correct column of the current variable
+            il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref);
             il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, varNode.Lag); // lag
             il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // rowIndex
@@ -628,33 +612,11 @@
             il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, ds.Rows);
             il.Emit(System.Reflection.Emit.OpCodes.Bge, nanResult);
-            il.Emit(System.Reflection.Emit.OpCodes.Ldarg_3); // startindex
-            il.Emit(System.Reflection.Emit.OpCodes.Bge, cachedValue);
-            // normal value
-            il.Emit(System.Reflection.Emit.OpCodes.Ldarg_1); // load columns array
-            il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.iArg0); // load correct column of the current variable
-            il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref);
-            il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, varNode.Lag); // lag
-            il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // rowIndex
-            il.Emit(System.Reflection.Emit.OpCodes.Add); // actualRowIndex = rowIndex + sampleOffset
             il.Emit(System.Reflection.Emit.OpCodes.Call, listGetValue);
-            il.Emit(System.Reflection.Emit.OpCodes.Br, multiplyValue);
-            il.MarkLabel(cachedValue);
-            // cached value
-            il.Emit(System.Reflection.Emit.OpCodes.Ldarg_2); // load cached values
-            il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, (int)currentInstr.iArg0); // load correct column of the current variable
-            il.Emit(System.Reflection.Emit.OpCodes.Ldelem_Ref);
-            il.Emit(System.Reflection.Emit.OpCodes.Ldc_I4, varNode.Lag); // lag
-            il.Emit(System.Reflection.Emit.OpCodes.Ldarg_0); // rowIndex
-            il.Emit(System.Reflection.Emit.OpCodes.Add); // actualRowIndex = rowIndex + sampleOffset
-            il.Emit(System.Reflection.Emit.OpCodes.Ldarg_3); // startRow
-            il.Emit(System.Reflection.Emit.OpCodes.Sub); // startRow            
-            il.Emit(System.Reflection.Emit.OpCodes.Call, listGetValue);
-
-            il.MarkLabel(multiplyValue);
             il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, varNode.Weight); // load weight
             il.Emit(System.Reflection.Emit.OpCodes.Mul);
             il.Emit(System.Reflection.Emit.OpCodes.Br, normalResult);
             il.MarkLabel(nanResult);
-            il.Emit(System.Reflection.Emit.OpCodes.Pop); // pop the row index
+            il.Emit(System.Reflection.Emit.OpCodes.Pop); // sample index
+            il.Emit(System.Reflection.Emit.OpCodes.Pop); // column reference
             il.Emit(System.Reflection.Emit.OpCodes.Ldc_R8, double.NaN);
             il.MarkLabel(normalResult);
@@ -769,5 +731,4 @@
       return alglib.besseli0(x);
     }
-
   }
 }
