mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-25 05:38:46 -05:00
Eliminate redundancies from the calculation of sequence correlations.
This commit is contained in:
parent
ca0804450b
commit
1b59d9dc8c
@ -5,9 +5,9 @@ subroutine get_fst4_bitmetrics(cd,nss,hmod,nmax,nhicoh,bitmetrics,s4,nsync_qual,
|
|||||||
complex cd(0:NN*nss-1)
|
complex cd(0:NN*nss-1)
|
||||||
complex cs(0:3,NN)
|
complex cs(0:3,NN)
|
||||||
complex csymb(nss)
|
complex csymb(nss)
|
||||||
complex, allocatable, save :: c1(:,:) ! ideal waveforms, 20 samples per symbol, 4 tones
|
complex, allocatable, save :: ci(:,:) ! ideal waveforms, 20 samples per symbol, 4 tones
|
||||||
complex cp(0:3) ! accumulated phase shift over symbol types 0:3
|
complex cp(0:3) ! accumulated phase shift over symbol types 0:3
|
||||||
complex csum,cterm
|
complex c1(4,8),c2(16,4),c4(256,2),c8(655356),cterm
|
||||||
integer isyncword1(0:7),isyncword2(0:7)
|
integer isyncword1(0:7),isyncword2(0:7)
|
||||||
integer graymap(0:3)
|
integer graymap(0:3)
|
||||||
integer ip(1)
|
integer ip(1)
|
||||||
@ -25,9 +25,9 @@ subroutine get_fst4_bitmetrics(cd,nss,hmod,nmax,nhicoh,bitmetrics,s4,nsync_qual,
|
|||||||
data first/.true./,nss0/-1/
|
data first/.true./,nss0/-1/
|
||||||
save first,one,cp,nss0
|
save first,one,cp,nss0
|
||||||
|
|
||||||
if(nss.ne.nss0 .and. allocated(c1)) deallocate(c1)
|
if(nss.ne.nss0 .and. allocated(ci)) deallocate(ci)
|
||||||
if(first .or. nss.ne.nss0) then
|
if(first .or. nss.ne.nss0) then
|
||||||
allocate(c1(nss,0:3))
|
allocate(ci(nss,0:3))
|
||||||
one=.false.
|
one=.false.
|
||||||
do i=0,65535
|
do i=0,65535
|
||||||
do j=0,15
|
do j=0,15
|
||||||
@ -40,7 +40,7 @@ subroutine get_fst4_bitmetrics(cd,nss,hmod,nmax,nhicoh,bitmetrics,s4,nsync_qual,
|
|||||||
dp=(itone-1.5)*dphi
|
dp=(itone-1.5)*dphi
|
||||||
phi=0.0
|
phi=0.0
|
||||||
do j=1,nss
|
do j=1,nss
|
||||||
c1(j,itone)=cmplx(cos(phi),sin(phi))
|
ci(j,itone)=cmplx(cos(phi),sin(phi))
|
||||||
phi=mod(phi+dp,twopi)
|
phi=mod(phi+dp,twopi)
|
||||||
enddo
|
enddo
|
||||||
cp(itone)=cmplx(cos(phi),sin(phi))
|
cp(itone)=cmplx(cos(phi),sin(phi))
|
||||||
@ -52,7 +52,7 @@ subroutine get_fst4_bitmetrics(cd,nss,hmod,nmax,nhicoh,bitmetrics,s4,nsync_qual,
|
|||||||
i1=(k-1)*NSS
|
i1=(k-1)*NSS
|
||||||
csymb=cd(i1:i1+NSS-1)
|
csymb=cd(i1:i1+NSS-1)
|
||||||
do itone=0,3
|
do itone=0,3
|
||||||
cs(itone,k)=sum(csymb*conjg(c1(:,itone)))
|
cs(itone,k)=sum(csymb*conjg(ci(:,itone)))
|
||||||
enddo
|
enddo
|
||||||
s4(0:3,k)=abs(cs(0:3,k))**2
|
s4(0:3,k)=abs(cs(0:3,k))**2
|
||||||
enddo
|
enddo
|
||||||
@ -85,49 +85,85 @@ subroutine get_fst4_bitmetrics(cd,nss,hmod,nmax,nhicoh,bitmetrics,s4,nsync_qual,
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
call timer('seqcorrs',0)
|
call timer('seqcorrs',0)
|
||||||
bitmetrics=0.0
|
bitmetrics=0.0
|
||||||
do nseq=1,nmax !Try coherent sequences of 1,2,3,4 or 1,2,4,8 symbols
|
|
||||||
if(nseq.eq.1) nsym=1
|
! Process the frame in 8-symbol chunks. Use 1-symbol correlations to calculate
|
||||||
if(nseq.eq.2) nsym=2
|
! 2-symbol correlations. Then use 2-symbol correlations to calculate 4-symbol
|
||||||
if(nhicoh.eq.0) then
|
! correlations. Finally, use 4-symbol correlations to calculate 8-symbol corrs.
|
||||||
if(nseq.eq.3) nsym=3
|
! This eliminates redundant calculations.
|
||||||
if(nseq.eq.4) nsym=4
|
|
||||||
else
|
do k=1,NN,8
|
||||||
if(nseq.eq.3) nsym=4
|
|
||||||
if(nseq.eq.4) nsym=8
|
do m=1,8 ! do 4 1-symbol correlations for each of 8 symbs
|
||||||
endif
|
|
||||||
nt=4**nsym
|
|
||||||
do ks=1,NN-nsym+1,nsym
|
|
||||||
s2=0
|
s2=0
|
||||||
do i=0,nt-1
|
do n=1,4
|
||||||
csum=0
|
c1(n,m)=cs(graymap(n-1),k+m-1)
|
||||||
! cterm=1 ! hmod.ne.1
|
s2(n-1)=abs(c1(n,m))
|
||||||
term=1
|
|
||||||
do j=0,nsym-1
|
|
||||||
ntone=mod(i/4**(nsym-1-j),4)
|
|
||||||
csum=csum+cs(graymap(ntone),ks+j)*term
|
|
||||||
term=-term
|
|
||||||
! csum=csum+cs(graymap(ntone),ks+j)*cterm ! hmod.ne.1
|
|
||||||
! cterm=cterm*conjg(cp(graymap(ntone))) ! hmod.ne.1
|
|
||||||
enddo
|
|
||||||
s2(i)=abs(csum)
|
|
||||||
enddo
|
enddo
|
||||||
ipt=1+(ks-1)*2
|
ipt=(k-1)*2+2*(m-1)+1
|
||||||
if(nsym.eq.1) ibmax=1
|
do ib=0,1
|
||||||
if(nsym.eq.2) ibmax=3
|
bm=maxval(s2(0:3),one(0:3,1-ib)) - &
|
||||||
if(nsym.eq.3) ibmax=5
|
maxval(s2(0:3),.not.one(0:3,1-ib))
|
||||||
if(nsym.eq.4) ibmax=7
|
|
||||||
if(nsym.eq.8) ibmax=15
|
|
||||||
do ib=0,ibmax
|
|
||||||
bm=maxval(s2(0:nt-1),one(0:nt-1,ibmax-ib)) - &
|
|
||||||
maxval(s2(0:nt-1),.not.one(0:nt-1,ibmax-ib))
|
|
||||||
if(ipt+ib.gt.2*NN) cycle
|
if(ipt+ib.gt.2*NN) cycle
|
||||||
bitmetrics(ipt+ib,nseq)=bm
|
bitmetrics(ipt+ib,1)=bm
|
||||||
enddo
|
enddo
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
|
do m=1,4 ! do 16 2-symbol correlations for each of 4 2-symbol groups
|
||||||
|
s2=0
|
||||||
|
do i=1,4
|
||||||
|
do j=1,4
|
||||||
|
is=(i-1)*4+j
|
||||||
|
c2(is,m)=c1(i,2*m-1)-c1(j,2*m)
|
||||||
|
s2(is-1)=abs(c2(is,m))
|
||||||
|
enddo
|
||||||
|
enddo
|
||||||
|
ipt=(k-1)*2+4*(m-1)+1
|
||||||
|
do ib=0,3
|
||||||
|
bm=maxval(s2(0:15),one(0:15,3-ib)) - &
|
||||||
|
maxval(s2(0:15),.not.one(0:15,3-ib))
|
||||||
|
if(ipt+ib.gt.2*NN) cycle
|
||||||
|
bitmetrics(ipt+ib,2)=bm
|
||||||
|
enddo
|
||||||
|
enddo
|
||||||
|
|
||||||
|
do m=1,2 ! do 256 4-symbol corrs for each of 2 4-symbol groups
|
||||||
|
s2=0
|
||||||
|
do i=1,16
|
||||||
|
do j=1,16
|
||||||
|
is=(i-1)*16+j
|
||||||
|
c4(is,m)=c2(i,2*m-1)+c2(j,2*m)
|
||||||
|
s2(is-1)=abs(c4(is,m))
|
||||||
|
enddo
|
||||||
|
enddo
|
||||||
|
ipt=(k-1)*2+8*(m-1)+1
|
||||||
|
do ib=0,7
|
||||||
|
bm=maxval(s2(0:255),one(0:255,7-ib)) - &
|
||||||
|
maxval(s2(0:255),.not.one(0:255,7-ib))
|
||||||
|
if(ipt+ib.gt.2*NN) cycle
|
||||||
|
bitmetrics(ipt+ib,3)=bm
|
||||||
|
enddo
|
||||||
|
enddo
|
||||||
|
|
||||||
|
s2=0 ! do 65536 8-symbol correlations for the entire group
|
||||||
|
do i=1,256
|
||||||
|
do j=1,256
|
||||||
|
is=(i-1)*256+j
|
||||||
|
c8(is)=c4(i,1)+c4(j,2)
|
||||||
|
s2(is-1)=abs(c8(is))
|
||||||
|
enddo
|
||||||
|
enddo
|
||||||
|
ipt=(k-1)*2+1
|
||||||
|
do ib=0,15
|
||||||
|
bm=maxval(s2(0:65535),one(0:65535,15-ib)) - &
|
||||||
|
maxval(s2(0:65535),.not.one(0:65535,15-ib))
|
||||||
|
if(ipt+ib.gt.2*NN) cycle
|
||||||
|
bitmetrics(ipt+ib,4)=bm
|
||||||
|
enddo
|
||||||
|
|
||||||
enddo
|
enddo
|
||||||
|
|
||||||
call timer('seqcorrs',1)
|
call timer('seqcorrs',1)
|
||||||
|
|
||||||
hbits=0
|
hbits=0
|
||||||
|
Loading…
Reference in New Issue
Block a user