# HG changeset patch # User Robert T. Short # Date 1301147412 25200 # Node ID dd2c70b30f2803559062ccb74f913187fa4d6d93 # Parent b3c158b8941c74daddf32d32f7c1023e151d90ab Add tests for ifftshift.m diff -r b3c158b8941c -r dd2c70b30f28 scripts/ChangeLog --- a/scripts/ChangeLog Sat Mar 26 06:42:35 2011 -0700 +++ b/scripts/ChangeLog Sat Mar 26 06:50:12 2011 -0700 @@ -1,3 +1,7 @@ +2011-03-26 Robert T. Short + + * signal/ifftshift.m: Add tests. + 2011-03-26 Robert T. Short * signal/fftshift.m: Add tests. diff -r b3c158b8941c -r dd2c70b30f28 scripts/signal/ifftshift.m --- a/scripts/signal/ifftshift.m Sat Mar 26 06:42:35 2011 -0700 +++ b/scripts/signal/ifftshift.m Sat Mar 26 06:50:12 2011 -0700 @@ -71,3 +71,49 @@ endif endfunction + +%!test +%! x = [0:7]; +%! y = ifftshift (x); +%! assert(y, [4 5 6 7 0 1 2 3]); +%! assert(ifftshift (y), x); + +%!test +%! x = [0:6]; +%! y = ifftshift (x); +%! assert(y, [3 4 5 6 0 1 2]); +%! assert(ifftshift (y), [6 0 1 2 3 4 5]); + +%!test +%! x = [0:7]'; +%! y = ifftshift (x); +%! assert(y, [4;5;6;7;0;1;2;3]); +%! assert(ifftshift (y), x); + +%!test +%! x = [0:6]'; +%! y = ifftshift (x); +%! assert(y, [3;4;5;6;0;1;2]); +%! assert(ifftshift (y), [6;0;1;2;3;4;5]); + +%!test +%! x = [0:3]; +%! x = [x;2*x;3*x+1;4*x+1]; +%! y = ifftshift (x); +%! assert(y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]); +%! assert(ifftshift (y), x); + +%!test +%! x = [0:3]; +%! x = [x;2*x;3*x+1;4*x+1]; +%! y = ifftshift (x,1); +%! assert(y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]); +%! assert(ifftshift (y,1), x); + +%!test +%! x = [0:3]; +%! x = [x;2*x;3*x+1;4*x+1]; +%! y = ifftshift (x,2); +%! assert(y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]); +%! assert(ifftshift (y,2), x); +