function tdx = maptdx( tnzs, zs, mrlen )
% an one-to-one map: theta -> ep
tdx = zeros(tnzs + 1,3,'int32');
k = 1;
for n = 1:2
    for i = 1:mrlen
        if any(~zs{n,i})
            jdx = 1:i;
            jdx = jdx(~zs{n,i});
            for j = jdx
                k = k + 1;
                tdx(k,:) = [i, j, n];
            end
        end
    end
end

end