[ntl] Help needed regarding conversion from GF2E to long and long to GF2E
ishtiaq shah
syed_ishtiaq7 at hotmail.com
Mon May 9 16:52:57 CDT 2011
Dear all members,
I am working on GF(2^8).GF(2^8) has 256 elements.In my own written program I am using elements(0,1,2,....,255) instead of polynomials.In NTL library GF2E is taking input as polynomial of form [1 0 1 1 0 1 1 1].The respective element for this polynomial is 237.How I can change my elements which are in long data type to GF2E,and in output I also want result back in element form.The direct conversion of long to GF2E only convert the element to [1] or [0] not to whole polynomial.
Mathematically Conversion from polynomial to elements is as follows
[1 0 1 1 0 1 1 1]=1 + 0*X + 1*X^2 + 1*X^3 + 0*X^4 + 1*X^5 + 1*X^6 + 1*X^7=1 + 0 + 4 +8 +0 +32 +64 +128=237I am also appending my code below.
#include <NTL/GF2XFactoring.h>#include <NTL/GF2EXFactoring.h>#include <NTL/GF2X.h>#include <NTL/matrix.h>#include <NTL/vec_vec_GF2E.h>#include <NTL/GF2E.h>#include <NTL/vector.h>#include <NTL/mat_GF2E.h>#include <NTL/version.h>
NTL_OPEN_NNSNTL_CLOSE_NNSNTL_CLIENT
int main(){ GF2X p; BuildIrred(p,8); cout<<p<<endl; GF2E::init(p);
GF2E a; long e; cin>>e; a=e;//Conversion from long to GF2E but not as desired cout<<a;
mat_GF2E A; A.SetDims(1,1); A(1,1)=a; cout<<A; long i; //i=A(1,1); Conversion from long to GF2E returns error
system("pause"); return 0;}
Kindly help me in this matter.If anybody knows please tell me how I can convert element to polynomial and polynomial back to element after desired operations.
Bundle of Thanks in advanceHave a nice day.Regards,Ishtiaq
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shoup.net/pipermail/ntl_shoup.net/attachments/20110509/3feb6324/attachment.html>
More information about the ntl
mailing list