In this project you need to write a program called gf2java

Assignment Help JAVA Programming
Reference no: EM13371120

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: EM13371120

Questions Cloud

Prepare and hand in a project proposal including1the nature : prepare and hand in a project proposal including1the nature of the project2the sources of information you plan to use
Objectives understanding planning stage of the audit : objectives understanding planning stage of the audit processnbsp review of client business and perform audit risk
It is a phd level and is about hivaids disease surveillance : it is a phd level and is about hivaids disease surveillance in the united states. there are two articles found online
1 maker systems manufactures automated test systems that : 1. maker systems manufactures automated test systems that perform quality inspections during and at the completion of
In this project you need to write a program called gf2java : in this project you need to write a program called gf2.java to implement the finite field gfpnwhere p is a prime number
Schedulingscheduling is explicitly part of our lives we : schedulingscheduling is explicitly part of our lives. we schedule everything and need to in order to plan our
It lsquos has been claimed that if you drop a standard : it lsquos has been claimed that if you drop a standard thumbtack from a height of 3 feet or more onto a flat hard
Minimum weight design of a variable shape three-bar : minimum weight design of a variable shape three-bar truss.numerical solution using the matlab optimization toolbox
Consider a fluid bounded by two parallel plates extended to : consider a fluid bounded by two parallel plates extended to infinity such that no end effects are encountered. the

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a data set with 100 integer values.

Create a data set with 100 integer values. Create a program that uses the division method of hashing to store the data values into hash tables with table sizes of 7,,51 and 151. Use the linear probing method of collision resolution. Print out the ..

  Objective to learn the use of comments and basic math

objective to learn the use of comments and basic math operators.create a new folder called assign21 under

  Assignment 2 descriptionyou are a mighty warrior and armed

assignment 2 descriptionyou are a mighty warrior and armed with your trusty bow and 3 arrows you enter the caves in

  Modify each sorting algorithm

Modify each sorting algorithm so that it keeps track of the number of comparisons it performs and the number of exchanges (swaps) it performs during a single sorting operation. Keep track of these numbers using two long integer counters

  Write method called median that accepts an array of integer

Write a method called median that accepts an array of integers as its parameter and returns the median of the numbers in the array.

  Write an application that uses an array

Write an application that uses an Array to store 10 messages of type String. You will store this Array with 10 messages of your choosing.

  Method that receives an array and returns with no duplicate

Write a program that contrains a method that receives an array and returns a new array with no duplicates.

  Java :a user-defined starting position (other than 0,0)

modifying the program so that it can start from a user-defined starting position (other than 0,0) and search for a user defined ending point (other than row-1, column-1) .

  Write a program to find solution tocryparithmetic puzzle

Write a program (Crypta.java) that finds a solution to the cryparithmetic puzzle: TOO + TOO + TOO+ TOO = GOOD

  Compute the correct number of square feet needed

The Carpet House owner wants to put a carpet calculator on his website so that visitors can estimate the amount of carpet they will need to purchase.

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Write a java binary search tree program

write a JAVA binary search tree program

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