a = [1,2;3,4];
b = a;
b(:,:,2) = [5,6;7,8];
a1 = [1; 3; 2; 4];
a2 = [1, 3];
a3 = [1, 2; 3, 4];
a4 = [1; 3];
a5 = 1;
a6 = [1; 3];
a7 = [1, 2; 3, 4];
a8(:,:,1) = [1, 2; 3, 4];
a8(:,:,2) = [1, 2; 3, 4];
a9(:,:,1,1) = [1, 2; 3, 4];
a9(:,:,1,2) = [1, 2; 3, 4];
a10(:,:,1,1) = [1, 2; 3, 4];
a10(:,:,2,1) = [1, 2; 3, 4];
a10(:,:,1,2) = [1, 2; 3, 4];
a10(:,:,2,2) = [1, 2; 3, 4];
a11 = zeros (1, 0);
a12 = zeros (1, 0, 2);
a13 = zeros (1, 1, 0);
b1 = [1; 3; 2; 4; 5; 7; 6; 8];
b2 = [1, 2, 5, 6; 3, 4, 7, 8];
b3 = [1; 3];
b4(:,:,1) = [1, 2; 3, 4];
b4(:,:,2) = [5, 6; 7, 8];
b5 = [1; 3];
b6(:,:,1,1) = [1; 3];
b6(:,:,1,2) = [1; 3];
b7 = 5;
b8 = [5, 6];
b9 = [1, 2, 5, 6];
b10 = zeros (1, 0, 2);
b11 = zeros (1, 0);

function retval = eq (a, b)
  sza = size (a);
  szb = size (b);
  retval = (length (sza) == length (szb)
	    && all (size (a) == size (b))
	    && all (a(:) == b(:)));
endfunction

r = [eq(a(:), a1);
     eq(a(1:2), a2);
     eq(a(:,:), a3);
     eq(a(:,1), a4);
     eq(a(1,1), a5);
     eq(a(1:2,1), a6);
     eq(a(:,:,1), a7);
     eq(a(:,:,[1,1]), a8);
     eq(a(:,:,1,[1,1]), a9);
     eq(a(:,:,[1,1],[1,1]), a10);
     eq(a(1,[]), a11);
     eq(a(1,[],[1,1]), a12);
     eq(a(1,1,[]), a13);
     eq(b(:), b1);
     eq(b(:,:), b2);
     eq(b(:,1), b3);
     eq(b(:,:,:), b4);
     eq(b(:,1,1), b5);
     eq(b(:,1,1,[1,1]), b6);
     eq(b(1,3), b7);
     eq(b(1,[3,4]), b8);
     eq(b(1,1:4), b9);
     eq(b(1,[],:), b10);
     eq(b(1,[]), b11)];

if (all (r))
  printf ("ok\n");
else
  find (r == 0)
endif
