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

  Write complete java program to read from keyboard

Write complete Java program to read, from keyboard, a student's first and last name and six grades. It will display on screen last name then first letter of first name with a period.

  Write down java program for furniture company

Write down a Java program for the furniture company. Ask user to select P for Pine, O for Oak or M for Mahogany. Illustrate price of table manufactured with chosen wood.

  Write specifications for method which advances date by one

Write specifications for the method which advances any given date by one day. Comprise a statement of purpose, pre- and post-conditions, and description of parameters.

  Write java program which will permit user to make selection

Write the Java Program which will permit the user to make selection. You will present user with two options to perform, then you will perform action selected by user.

  Java application which creates bank records

Write down a java application which creates 10000 bank records and the allow user ti enter a balance and customer account info. using a an account number.

  Write a recursive instance method

Write a recursive instance method

  Robot preparing for competition

Create an event so that the skateboard can be controlled by game player

  Java application to permit user to enter ten numbers

Write down Java application which permits a user to enter 10 numbers (double precision) into the array and then sorts and displays numbers from lowest to highest.

  Create a recursive factorial program

Assignment 1: Create a recursive factorial program that prompts the user for an integer  N  and writes out a series of equations representing the calculation of  N !. For example, if the input is 4, the output could be:

  Develop java code to compute monthly rent for housing units

Develop a java code that computes monthly rent for 3 housing units namely Bungalows,Apartments and hostels. All housing units have got size,color and monthly rental rate.

  Develop a graphical user interface based java program

Develop a Java program that can communicate with a real SMTP email server for sending emails. TNE 60003 - introduction to network programming, You program should provide a GUI and can successfully send the SMTP commands to the mail server

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

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