Implement the finite field gf

Assignment Help JAVA Programming
Reference no: EM1378965

In this project you need to write a program called "GF2.java" to implement the finite field GF(pn)where p is a prime number andn is a positive integer.You also need to write four methodsto realize "+","-","´", and "/".

Specifically, your program will read parameters and polynomialsfrom a file named "input.txt" (under the same directory).Then your program needs tocreate a file named "output.txt" (under the same directory) and prints the results to "output.txt".

In "input.txt":

1. First line is the prime number p.

2. Second line is the degree n of the irreducible polynomial m(x) over Zp.

3. Third line is the coefficients of m(x), from leading coefficient to the constant, separated by one blank space.

4. Fourth Line is the degree of f(x) over Zp.

5. Fifth line is the coefficients of f(x), from leading coefficient to the constant, separated by one blank space.

6. Sixth line is the degree of g(x) over Zp.

7. Seventh line is the coefficients of g(x), from leading coefficient to the constant, separated by one blank space.

In "output.txt":

1. First line is the coefficients of f(x)+g(x) (mod m(x)), from leading coefficient to the constant, separated by one blank space.

2. Second line is the coefficients of f(x)-g(x) (mod m(x)), from leading coefficient to the constant, separated by one blank space.

3. Third line is the coefficients of f(x)*g(x) (mod m(x)), from leading coefficient to the constant, separated by one blank space.

4. Fourth line is the coefficients of f(x)/g(x) (mod m(x)), from leading coefficient to the constant, separated by one blank space (don't forget to handle the case of g(x) = 0).

Important: leading coefficient should not be 0 unless the polynomial is 0.

Example 1: if p = 3, m(x) = x2 + 1, f(x) = 2x, g(x) = x + 1, then f(x) + g(x) = 1 instead of 0x + 1. Thus in the first line of "output.txt" it should print 1 instead of 0 1.

Example 2: if p = 3, m(x) = x2 + 1, f(x) = 2x + 2, g(x) = x + 1, then f(x) + g(x) = 0 instead of 0x + 0. Thus in the first line of "output.txt" it should print 0 instead of 0 0.

/** * PLDA (Polynomial long division algorithm) over GF(p) * * @param n(x) a polynomial  * @param d(x) a non-zero polynomial  * @param p a prime number  * * @return quotient q(x) and remainder r(x) such that n(x) = q(x)*d(x) + r(x) mod p where deg(r(x)) <deg(d(x)) */   PLDA(n(x), d(x))              

n(x) = n(x) mod p // perform mod p to every coefficient of n(x)               

d(x) = d(x) mod p // perform mod p to every coefficient of d(x)             

(q(x), r(x)) <- (0, n(x))                            

while r(x) != 0 and deg(r(x)) >= deg(d(x)) do                  

t(x) <- lead(r(x))/lead(d(x))                                 /*                              

*  lead() returns the leading term of a polynomial; the division requires EEA.                            

*  E.g. if r(x) = 2x^2 + x + 1, d(x) = 3x + 2, and p = 7,                             

*  then lead(r(x)) = 2x^2, lead(d(x)) = 3x,                    

*  thus t(x) = 2x^2/3x = (2/3)(x^2/x) = 3x,                                 

*  here it needs EEA to compute 2/3 mod 7 = 3.                               

*/ (q(x), r(x)) <- (q(x) + t(x) mod p, r(x) - t(x)*d(x) mod p)                                 return (q(x), r(x))   

/**  * EEAP (Extended Euclidean Algorithm for Polynomials) over GF(p)

* * @param a(x) a polynomial  

* @param b(x) another polynomial

* @param p a prime number   

* * @return polynomial array (u(x),v(x)) satisfying u(x)*a(x) + v(x)*b(x) = gcd(a(x),b(x)) mod p

*/EEAP(a(x), b(x))              

a(x) = a(x) mod p // perform mod p to the coefficients of a(x)               

b(x) = b(x) mod p // perform mod p to the coefficients of b(x)              

if b(x) = 0 then                     

return (1/(leading coefficient of a(x)), 0) // gcd(a(x),0) should be monic          

else                   Q = PLDA(a(x), b(x))                  

q(x) = Q[0] and r(x) = Q[1]                  

R = EEAP(b(x), r(x))                                  

return (R[1] mod p, R[0]-q*R[1] mod p)

Reference no: EM1378965

Questions Cloud

Gui based program to write data to a sequential data file : Design a GUI Based program with a WriteButton used to write data to a sequential information file. Then make another ReadData button to read information from the file created and display it in a JTable on the GUI.
Pseudocode for a recursive function : Think about a language of words, where each word is a string of dots and dashes. The following grammar describes this language:
Debugging facilities for art of programming : The BlueJ development environment offers simple but sufficient debugging facilities for those new to and learning the art of programming.
Determine one number missing from the sequence : Certain major software corporation likes to use in their interviews. Like many algorithm design problems, there are many possible answers, but I have presented one of the more generally accepted ones.
Implement the finite field gf : Write a program called "GF2.java" to implement the finite field GF(p n )where p is a prime number andn is a positive integer.You also need to write four methodsto realize.
Create a table with a primary key to identify business : Construct a table that will store data about each student that took a course and what grade they received. The data should include the semester of completion.
Identify the data type for variable : Assume you manage a dog walking service, in which you interact with both clients and dog walkers. Your task is to schedule dog-walking appointments based on the customers requested dates and times and the availability of the dog walkers.
Tcp sender and receiver sequence : Think about a TCP sender and receiver. Suppose bytes 0 .. 99 have been sent, received, and acknowledged (the sender has received ack's for them). Suppose the sender sends the following segments
Explanations on spreadsheet concepts : A workbook can contain more than one worksheet. Provide an example of a spreadsheet application where it would be necessary to have more than one worksheet, can you describe how that works?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Java application to generate three-digit random number

Write a Java application that generates a 3-digit random number 100 times. Display the output for each of the generated numbers and the sum of all 100 numbers.

  Prepare a java simulation program

Given a hash function h, prepare a java simulation program to determine each of the subsequent quantities after 0.8*tablesize random keys have been generated. The keys should be random integers.

  Create a project in eclipse

Create a new project

  Design and implement a small and simple email server

Design and implement a small and simple email server

  Implement the lexical and syntactic analysis

Implement the lexical and syntactic analysis of Minifun programming language.

  Implementation the two classes

Program Specifications: In the new implementation, the two classes, Student and Grades, are defined with the following operations/methods.

  Write a class array that encapsulates an array

Write a class Array that encapsulates an array and provides bounds-checked access. The private instance variables should be int index and inarray[10]. The public members should be a default constructor and methods (signatures shown below) to provide ..

  Implementation of memory management

Implementation of memory management

  World data app

Prepare WorldDataApp project. It implements the NameIndex portion, including creating it in SetupProgram, and searching, viewing and updating it in UserApp program.

  Write java program to enter number of marks

Write a java program called AverageMark.java. This program should allow the user to enter any number of marks and then display the minimum, maximum & average mark.

  Insert uml design diagrams, use case, classes

Insert UML design diagrams here (use case, class, and sequence diagram).

  Describe principles of data abstraction and inheritance

Study the principles of data abstraction, inheritance and dynamic binding. Use Library to get started on finding resources.You must take the terms and describe it.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd