function D = nddet(A)
	% determinant of 3x3x sz array
	% returns array of size sz containing determinant of each page of A
	s		= size(A);
	if length(s) < 3
		s	= [1 1];
	elseif length(s) < 4
		s	= [s(3) 1];
	else
		s	= s(3:end);
	end
	
	D			= A(1,1,:).*A(2,2,:).*A(3,3,:) ...
				+ A(1,2,:).*A(2,3,:).*A(3,1,:) ...
				+ A(1,3,:).*A(2,1,:).*A(3,2,:) ...
				- A(1,1,:).*A(2,3,:).*A(3,2,:) ...
				- A(1,3,:).*A(2,2,:).*A(3,1,:) ...
				- A(1,2,:).*A(2,1,:).*A(3,3,:);
	D			= reshape(D, s);
end