function V=ray_num(v0,m,d,k) %only numerator
n=k*d^m;
D=(d^k-1)*d^m;%denominator
if m==0
    initial_id=0;
else
    initial_id=d^m;
end
V=zeros(d*n,2);
for j=1:n
    for l=0:(d-1)
        V((j-1)*d+l+1,1)=mod(v0(j,1)+l*D,d*D);
    end
end
V=sort(V);
j=1;
while ~ae(V(j,1),d*v0(1,1))
    j=addone(j,d*n);
end
V_new=zeros(d*n,2);
for l=j:(d*n)
    V_new(l-j+1,1)=V(l,1);
end
for l=(d*n-j+2):(d*n)
    V_new(l,1)=V(l-d*n+j-1);
end
V=V_new;
count_v0=1;
j=1;

count=1;
for j=1:(d*n)
    if ae(V(j,1),d*v0(count,1))
        V(j,2)=v0(count,2);
        count=addone(count,n);
    end
end

l=1;
for j=1:(d*n)
    if (V(j,2)==0)
        V(j,2)=initial_id+1;
        l=l+1;
        if(l>k)
            l=1;
            initial_id=initial_id+1;
        end
    end
end

end