bugGNU Octave - Bugs: bug #66263, [octave package] (communications)...

 
 

bug #66263: [octave package] (communications) rsenc() produces incorrect result when called with B and S vs G as arguments

Submitter:  sean173 <sean173>
Submitted:  Fri 27 Sep 2024 03:57:09 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Sean Sneed Open/Closed:  * Open
Release:  * 9.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 30 Sep 2024 08:37:39 PM UTC, comment #6: 

I have done some additional tests using rsgenpoly() and rsenc() using matlab and found that I made a mistake in my Comment #4 below. 

PRIM=2 is incorrect, as the PRIM argument that octave's rsenc() is looking for is the index, or exponent on alpha, not alpha itself.  In other words, I should have used PRIM=1 since alpha^PRIM=2 is what should be used for this particular toy reed solomon code.

Once I made this change, all codewords produced by rsenc() for 0<=FCR<=15 worked as expected.

Thank you Nicholas for your assistance.

Sean

sean173 <sean173>
Fri 27 Sep 2024 09:01:17 PM UTC, comment #5: 

yes, i agree something seems off.  as you found in comment #0, B = 15, PRIM = 1 to get the same output doesn't seem to match expected behavior. not familiar enough with the code to guess what/where the issue lies, but marking report as confirmed. perhaps the package maintainer has a better idea.

Nicholas Jankowski <nrjank>
Group Member
Fri 27 Sep 2024 08:29:36 PM UTC, comment #4: 

Ok.  Thank you for pointing out the difference in definition of arguments between rsgenpoly() and rsgen().  I agree with that, I was defining them incorrectly.  However I have tried defining them according to the help on rsgen() and still haven't obtained the expected results:

FCR=1        ## the first consecutive root, alpha^0 = 1
PRIM=2       ## the primitive element, allpha^1=2 used to make GF
B=FCR*PRIM   ## I believe this should be a mult. on the GF but
             ## I'm making a simple multiply since for this one
             ## case the result is 1*2= 2 is the same

## Then we have,
gf_encWords_4 = rsenc(gf_inWord, 15, 11, B, PRIM)

Array elements =

    1    2    3    4    5    6    7    8    9   10   11   10    1    4    5

Which does not agree with the expected result of

Array elements =

    1    2    3    4    5    6    7    8    9   10   11    3    3   12   12


sean173 <sean173>
Fri 27 Sep 2024 05:55:09 PM UTC, comment #3: 

sorry, forgot to finish: 

in rsgenpoly the definition is:


Function File: G = rsgenpoly (N, K, P, B, S)
...
 The variables B and S determine the form of the generator
     polynomial in the following manner.

          G = (X - A^(B*S)) * (X - A^((B+1)*S)) * ... * (X - A^((B+2*T-1)*S)).

     where T is ‘(N-K)/2’, and A is the primitive element of the Galois
     Field.  Therefore B is the first consecutive root of the generator
     polynomial and S is the primitive element to generate the
     polynomial roots.


if i'm reading that right, B and S in rsgenpoly should not be expected to produce the same result as FCR and PRIM in rsenc.

Nicholas Jankowski <nrjank>
Group Member
Fri 27 Sep 2024 05:52:41 PM UTC, comment #2: 

checking outputs with Octave 9.2.0, communications pkg 1.2.6:


>> inWord = [1 2 3 4 5 6 7 8 9 10 11]
inWord =

    1    2    3    4    5    6    7    8    9   10   11

>> gf_inWord = gf(inWord, 4, 19)
gf_inWord =
GF(2^4) array. Primitive Polynomial = D^4+D+1 (decimal 19)

Array elements =

    1    2    3    4    5    6    7    8    9   10   11

>> B = 0
B = 0
>> S = 1
S = 1
>> gf_GenPoly = rsgenpoly(15, 11, 19, B, S)
gf_GenPoly =
GF(2^4) array. Primitive Polynomial = D^4+D+1 (decimal 19)

Array elements =

    1   15    3    1   12

>> gf_encWords_1 = rsenc(gf_inWord, 15, 11, gf_GenPoly)
gf_encWords_1 =
GF(2^4) array. Primitive Polynomial = D^4+D+1 (decimal 19)

Array elements =

    1    2    3    4    5    6    7    8    9   10   11    3    3   12   12

>> gf_encWords_2 = rsenc(gf_inWord, 15, 11, B, S)
gf_encWords_2 =
GF(2^4) array. Primitive Polynomial = D^4+D+1 (decimal 19)

Array elements =

    1    2    3    4    5    6    7    8    9   10   11   11   10   14    6

>> B=15;
>> gf_encWords_3 = rsenc(gf_inWord, 15, 11, B, S)
gf_encWords_3 =
GF(2^4) array. Primitive Polynomial = D^4+D+1 (decimal 19)

Array elements =

    1    2    3    4    5    6    7    8    9   10   11    3    3   12   12


checking Matlab 2024a for compatibility, it doesn't accept S for rsgenpoly, but since it's 1 here it should be equivalent, and rsenc doesn't take the extended generator poly terms directly, only a gf array. but:


>> inWord = [1 2 3 4 5 6 7 8 9 10 11];
>> gf_inWord = gf(inWord, 4, 19)

gf_inWord = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

    1    2    3    4    5    6    7    8    9   10   11

>> B = 0;
>> S = 1;
>> gf_GenPoly = rsgenpoly(15, 11, 19, B, S)
Error using rsgenpoly (line 107)
The outputFormat parameter value must be either 'double' or 'gf'.

>> gf_GenPoly = rsgenpoly(15, 11, 19, B, "gf")

gf_GenPoly = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

    1   15    3    1   12

>> gf_encWords_1 = rsenc(gf_inWord, 15, 11, gf_GenPoly)

gf_encWords_1 = GF(2^4) array. Primitive polynomial = D^4+D+1 (19 decimal)

Array elements =

    1    2    3    4    5    6    7    8    9   10   11    3    3   12   12


so this appears to confirms the difference. the output is correct with a GF input, but different when the same terms are passed directly. Now, is it supposed to be the same? 


-- Loadable Function: CODE = rsenc (MSG, N, K, FCR, PRIM)
...
 FCR is an integer value, and it is taken to be
     the first consecutive root of the generator polynomial.  The
     variable PRIM is then the primitive element used to construct the
     generator polynomial, such that

     G = (X - A^B) * (X - A^(B+PRIM)) * ...  * (X - A^(B+2*T*PRIM-1)).

     where B is equal to ‘FCR * PRIM’.  By default FCR and PRIM are both
     1.


it seems from this definition that the input terms are not expected to be B and S as you described them.

Nicholas Jankowski <nrjank>
Group Member
Fri 27 Sep 2024 05:03:56 PM UTC, comment #1: 

cc package maintainer

Nicholas Jankowski <nrjank>
Group Member
Fri 27 Sep 2024 03:57:09 PM UTC, original submission:  

When calling rsenc() with G generated by calling rsgenpoly() with B=0 and S=1 first, the results of rsenc are correct.  But when calling rsenc() with the B and S arguments directly, without G, the results are incorrect.  It seems that by decrementing B by 1 mod 2^m-1 when calling rsenc() that the results are then correct.

Here is a code snippet to reproduce the results:


inWord = [1 2 3 4 5 6 7 8 9 10 11];

## Generate a word on the RS code 15,11) with GF on primpoly = 19 decimal
gf_inWord = gf(inWord, 4, 19);

## Generate a field generator polynomial for encoding in method 1 to follow
B = 0;  ## First consecutive roots
S = 1;  ## primitive element
fprintf("\nOctave produced this generator poly with method 1 using rsgenpoly:\n");
gf_GenPoly = rsgenpoly(15, 11, 19, B, S)

fprintf("\nOctave produced this encoded output using the rsgenpoly output:\n");
gf_encWords_1 = rsenc(gf_inWord, 15, 11, gf_GenPoly)

fprintf("\nBut Octave produced this encoded output using B and S parameters instead of the generator poly as an argument:\n");
gf_encWords_2 = rsenc(gf_inWord, 15, 11, B, S)

fprintf("\nI would have expected that when you pass B and S instead of G to rsenc\n");
fprintf("that the results would be the same in the output word.  It appears that\n");
fprintf("when you set B=B-1 mod 2^m-1 when calling rsenc that the results are consistent\n");
fprintf("as shown here for at least the case where B=0:\n");

B=15;
gf_encWords_3 = rsenc(gf_inWord, 15, 11, B, S)


sean173 <sean173>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #56460:  GNU_Octave_rsenc_bug_report_script.m added by sean173 (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank
  • -email is unavailable- added by nrjank (Updated the item)
  • -email is unavailable- added by sean173 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-09-27 nrjank StatusNeed Info Confirmed
    2024-09-27 nrjank StatusNone Need Info
        Release8.2.0 9.2.0
        Operating SystemMicrosoft Windows Any
    2024-09-27 nrjank Carbon-Copy- Added nir_krakauer
    2024-09-27 nrjank Carbon-CopyRemoved -email is unavailable- -
    2024-09-27 nrjank Carbon-Copy- Added -email is unavailable-
    2024-09-27 nrjank Carbon-CopyRemoved nir -
    2024-09-27 nrjank Carbon-Copy- Added nir
    2024-09-27 nrjank Summaryrsenc() produces incorrect result when called with B and S vs G as arguments [octave package] (communications) rsenc() produces incorrect result when called with B and S vs G as arguments
    2024-09-27 sean173 Attached File- Added GNU_Octave_rsenc_bug_report_script.m, #56460

    Back to the top

    Powered by Savane 3.13-5884.
    Corresponding source code