Errors and erasures is now working for RS.

This commit is contained in:
Joe Taylor 2024-02-02 12:07:40 -05:00
parent 3bfbe4deb4
commit 347e32548c
3 changed files with 44 additions and 19 deletions

View File

@ -17,11 +17,11 @@ CFLAGS= -O9 -Wall
all: rs_sf.a rstest rs_125_49
OBJS1 = rstest.o ran1.o
OBJS1 = rstest.o ran1.o rs_sf.a
rstest: $(OBJS1)
$(FC) -o rstest $(OBJS1) rs_sf.a
OBJS2 = rs_125_49.o ran1.o get_crc14.o
OBJS2 = rs_125_49.o ran1.o get_crc14.o rs_sf.a
rs_125_49: $(OBJS2)
$(FC) -o rs_125_49 $(OBJS2) rs_sf.a

View File

@ -26,14 +26,21 @@ void rs_encode_sf_(int *dgen, int *sent)
// Reverse data order for the Karn codec.
for(i=0; i<kk; i++) {
dat1[i]=dgen[kk-1-i];
// dat1[i]=dgen[kk-1-i];
dat1[i]=dgen[i]; //### Temporary, no reversal ###
}
// Compute the parity symbols
encode_rs_sf(rs_sf,dat1,b);
// Move parity symbols and data into sent[] array, in reverse order.
for (i = 0; i < nroots; i++) sent[nroots-1-i] = b[i];
for (i = 0; i < kk; i++) sent[i+nroots] = dat1[kk-1-i];
for (i = 0; i < nroots; i++) {
// sent[nroots-1-i] = b[i];
sent[i] = b[i]; //### Temporary, no reversal ###
}
for (i = 0; i < kk; i++) {
// sent[i+nroots] = dat1[kk-1-i];
sent[i+nroots] = dat1[i]; //### Temporary, no reversal ###
}
}
void rs_decode_sf_(int *recd0, int *era0, int *numera0, int *decoded, int *nerr)
@ -48,10 +55,23 @@ void rs_decode_sf_(int *recd0, int *era0, int *numera0, int *decoded, int *nerr)
int recd[255];
numera=*numera0;
for(i=0; i<kk; i++) recd[i]=recd0[nn-1-i];
for(i=0; i<nroots; i++) recd[kk+i]=recd0[nroots-1-i];
if(numera)
for(i=0; i<numera; i++) era_pos[i]=era0[i];
for(i=0; i<kk; i++) {
// recd[i]=recd0[nn-1-i];
recd[i]=recd0[i];
}
for(i=0; i<nroots; i++) {
// recd[kk+i]=recd0[nroots-1-i];
recd[kk+i]=recd0[kk+i];
}
if(numera) {
for(i=0; i<numera; i++) {
era_pos[i]=era0[i];
// printf("erased %d %d\n",i,era_pos[i]);
}
}
*nerr=decode_rs_sf(rs_sf,recd,era_pos,numera);
for(i=0; i<kk; i++) decoded[i]=recd[kk-1-i];
for(i=0; i<kk; i++) {
// decoded[i]=recd[kk-1-i];
decoded[i]=recd[nroots+i];
}
}

View File

@ -8,9 +8,9 @@ program rstest
integer iera(0:200) !Positions of erasures
nargs=iargc()
if(nargs.ne.4) then
print*,'Usage: rstest M N K nerr'
print*,'Example: rstest 7 127 51 38'
if(nargs.ne.5) then
print*,'Usage: rstest M N K nera nerr'
print*,'Example: rstest 7 127 51 0 38'
go to 999
endif
nkv=0
@ -21,6 +21,8 @@ program rstest
call getarg(3,arg)
read(arg,*) kk
call getarg(4,arg)
read(arg,*) nera
call getarg(5,arg)
read(arg,*) nerr
! Initialize the Karn codec
@ -28,9 +30,10 @@ program rstest
nfz=3
call rs_init_sf(mm,nq,nn,kk,nfz) !Initialize the Karn RS codec
! Generate and random symbols with values 0 to nq-1
! Generate random message, kk symbols with values 0 to nq-1
do i=1,kk
dgen(i)=int(nq*ran1(idum))
! dgen(i)=int(nq*ran1(idum))
dgen(i)=i
enddo
write(*,1000)
@ -51,15 +54,17 @@ program rstest
1006 format(/'Recovered channel symbols, with errors:')
write(*,1002) gsym(1:nn)
nera=0
iera=0
do i=0,nera-1
iera(i)=i
enddo
call rs_decode_sf(gsym,iera,nera,dat,nfixed)
ibad=count(dat(1:kk).ne.dgen(1:kk))
write(*,1008)
1008 format(/'Decoded result:')
write(*,1002) dat(1:kk)
write(*,1100) nerr,nfixed
1100 format(/'nerr:',i3,' nfixed:',i3)
write(*,1100) nerr,nera,nfixed
1100 format(/'nerr:',i3,' nera:',i3,' nfixed:',i3)
999 end program rstest