From 52427a342673dff2f3ac12c9e989eec3662ad7e6 Mon Sep 17 00:00:00 2001
From: Yoann Guilhem <yoann.guilhem@esrf.fr>
Date: Thu, 2 May 2013 14:42:49 +0200
Subject: [PATCH] Got rid of roll function (use built-in funciton circshift
 instead).

Signed-off-by: Yoann Guilhem <yoann.guilhem@esrf.fr>
---
 zUtil_ID19/correlate1.m  |  2 +-
 zUtil_ID19/findshifts3.m |  3 ++-
 zUtil_ID19/roll.m        | 30 ------------------------------
 3 files changed, 3 insertions(+), 32 deletions(-)
 delete mode 100644 zUtil_ID19/roll.m

diff --git a/zUtil_ID19/correlate1.m b/zUtil_ID19/correlate1.m
index 333c9162..2b5502db 100644
--- a/zUtil_ID19/correlate1.m
+++ b/zUtil_ID19/correlate1.m
@@ -45,7 +45,7 @@ cc=abs(ifft(fft(z1).*conj(fft(z2))));
 % translation of the zero displacement to the center of the vector because this is where the maximum will be
 % to avoid to look at start and end of the vector
 c=rem(c+n/2-1,n)+1;
-cc=roll(cc,n/2,0);
+cc = circshift(cc, [round*(n/2) 0];
 
 % parabolic fit using w points around the maximum to go sub-pixel
 w=3;
diff --git a/zUtil_ID19/findshifts3.m b/zUtil_ID19/findshifts3.m
index 68f45a9f..083d0b7d 100644
--- a/zUtil_ID19/findshifts3.m
+++ b/zUtil_ID19/findshifts3.m
@@ -259,7 +259,8 @@ end
 
 function sfUpdateFigure
   colormap gray;
-  im_tmp=roll(app.im1,app.vshift*app.zoom,app.hshift*app.zoom);
+  shiftVector = round([app.vshift app.hshift] * app.zoom);
+  im_tmp = circshift(app.im1, shiftVector);
   switch app.mode
     case 'add'
       imshow(app.im0+im_tmp,app.clima);
diff --git a/zUtil_ID19/roll.m b/zUtil_ID19/roll.m
deleted file mode 100644
index c8e0398d..00000000
--- a/zUtil_ID19/roll.m
+++ /dev/null
@@ -1,30 +0,0 @@
-% function rm=roll(matrix,r,c)
-% cycles a matrix (or vector) r rows down and c columns to the right
-% rm(i,j)=rm(i-r,j-c)
-% origin: peter
-
-function rm=roll(matrix,r,c)
-[n,m]=size(matrix);
-
-
-if r>0
-      rm=[matrix(n-r+1:n,:) ; matrix(1:n-r,:)];
-elseif r<0
-      rm=[matrix(1-r:n,:) ; matrix(1:-r,:)];
-else
-      rm=matrix;
-end
-
-if c>0
-      rm=[rm(:,m-c+1:m) rm(:,1:m-c)];
-elseif c<0
-      rm=[rm(:,1-c:m) rm(:,1:-c)];
-end
-
-
-
-
-
-
-
-
-- 
GitLab