-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwo_net.m
39 lines (38 loc) · 833 Bytes
/
two_net.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function pick=two_net(nop,no)
tic
pick=zeros(nop,1);
factor=sqrt(nop);
counter=1;
step=1;
x=mod(no,factor);
y=floor(no/factor)+1;
while(counter~=nop)
target=x+step;
while(x~=target && counter~=nop)
x=x+1;
pick(counter)=factor*(y-1)+x;
counter=counter+1;
end
target=y-step;
while(y~=target && counter~=nop)
y=y-1;
pick(counter)=factor*(y-1)+x;
counter=counter+1;
end
step=step+1;
target=x-step;
while(x~=target && counter~=nop)
x=x-1;
pick(counter)=factor*(y-1)+x;
counter=counter+1;
end
target=y+step;
while(y~=target && counter~=nop)
y=y+1;
pick(counter)=factor*(y-1)+x;
counter=counter+1;
end
step=step+1;
end
pick(pick>nop)=pick(pick>nop)-nop;
pick(pick<=0)=pick(pick<=0)+nop;