From 02d69876856f85b92259be10a3b112b48ec53e4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Mon, 23 Jan 2012 13:56:46 +0100
Subject: [PATCH] Fixed bug in EP algorithm.

---
 matlab/ep/extended_path.m | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/matlab/ep/extended_path.m b/matlab/ep/extended_path.m
index beda19f108..806880e873 100644
--- a/matlab/ep/extended_path.m
+++ b/matlab/ep/extended_path.m
@@ -230,15 +230,13 @@ while (t<sample_size)
             end
             % Test if periods is big enough.
             delta = 0;
-            if ~isempty(idx)
-                delta = max(max(abs(tmp(idx,end-options_.ep.lp:end)./tmp(idx, ...
-                                                                  end-options_.ep.lp-1:end-1)-1)));
-            end;
-            if ~isempty(indx)
-                delta = max(delta,max(max(abs(tmp(indx,end-options_.ep.lp: ...
-                                                  end)-tmp(indx,end-options_.ep.lp-1:end-1)))));
+            if length(tmp)>1 && ~isempty(idx)
+                delta = max(max(abs(tmp(idx,end-options_.ep.lp:end)./tmp(idx,end-options_.ep.lp-1:end-1)-1)));
             end
-            if ~increase_periods &&  delta < options_.dynatol.x
+            if length(tmp)>1 && ~isempty(indx)
+                delta = max(delta,max(max(abs(tmp(indx,end-options_.ep.lp:end)-tmp(indx,end-options_.ep.lp-1:end-1)))));
+            end
+            if ~increase_periods &&  delta<options_.dynatol.x
                 break
             else
                 options_.periods = options_.periods + options_.ep.step;
-- 
GitLab