changeset 12540:b3c158b8941c

Add tests for fftshift.m.
author Robert T. Short <octave@phaselockedsystems.com.com>
date Sat, 26 Mar 2011 06:42:35 -0700
parents ccd0572e5e93
children dd2c70b30f28
files scripts/ChangeLog scripts/signal/fftshift.m
diffstat 2 files changed, 50 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Fri Mar 25 13:37:11 2011 -0400
+++ b/scripts/ChangeLog	Sat Mar 26 06:42:35 2011 -0700
@@ -1,3 +1,7 @@
+2011-03-26  Robert T. Short  <octave@phaselockedsystems.com.com>
+
+	* signal/fftshift.m: Add tests.
+
 2011-03-21  Rik  <octave@nomad.inbox5.com>
 
 	* signal/ifftshift.m: Fix bug #32873, ifftshift fails.
--- a/scripts/signal/fftshift.m	Fri Mar 25 13:37:11 2011 -0400
+++ b/scripts/signal/fftshift.m	Sat Mar 26 06:42:35 2011 -0700
@@ -83,3 +83,49 @@
   endif
 
 endfunction
+
+%!test
+%!  x = [0:7];
+%!  y = fftshift (x);
+%!  assert(y, [4 5 6 7 0 1 2 3]);
+%!  assert(fftshift (y), x);
+
+%!test
+%!  x = [0:6];
+%!  y = fftshift (x);
+%!  assert(y, [4 5 6 0 1 2 3]);
+%!  assert(fftshift (y), [1 2 3 4 5 6 0]);
+
+%!test
+%!  x = [0:7]';
+%!  y = fftshift (x);
+%!  assert(y, [4;5;6;7;0;1;2;3]);
+%!  assert(fftshift (y), x);
+
+%!test
+%!  x = [0:6]';
+%!  y = fftshift (x);
+%!  assert(y, [4;5;6;0;1;2;3]);
+%!  assert(fftshift (y), [1;2;3;4;5;6;0]);
+
+%!test
+%!  x = [0:3];
+%!  x = [x;2*x;3*x+1;4*x+1];
+%!  y = fftshift (x);
+%!  assert(y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]);
+%!  assert(fftshift (y), x);
+
+%!test
+%!  x = [0:3];
+%!  x = [x;2*x;3*x+1;4*x+1];
+%!  y = fftshift (x,1);
+%!  assert(y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]);
+%!  assert(fftshift (y,1), x);
+
+%!test
+%!  x = [0:3];
+%!  x = [x;2*x;3*x+1;4*x+1];
+%!  y = fftshift (x,2);
+%!  assert(y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]);
+%!  assert(fftshift (y,2), x);
+