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

  Enterprise java beans (ejb) in software development

Enterprise Java Beans (EJB) in software development, EJB technology, EJB application, Stateless Session Beans (SLSB), Stateful Session Beans (SFSB), Message Driven Bean (MDB), Entity Bean

  Consider a typical certification hierarchy

Why might Bob still not trust that the certificate for Alice truly establishes Alice as the owner of the public key in the certificate?

  Write program in java for total amount of customer-s order

Write down program in Java which would ask for clerk to enter total amount of customer's order. Program will then compute seven percent (7%) sales tax.

  This project is for designing and developing a college

this project is for designing and developing a college registration program. prepare a java program to register

  Eclipse or netbeans environments

As recommendation, you can try to use Eclipse or NetBeans environments that are used also for other courses as: Introduction in Java programming and Intermediate programming.

  Strong authentication can also risk availability

Strong authentication can also risk availability. A simple example is that forgetting your password denies you access to that which required a password. Sometimes the stakes are high, for example, if a network administrator is the only one who knows ..

  Assignmentwrite a gui-based application that allows a user

assignmentwrite a gui-based application that allows a user to play a simple trivia game. the game should have 5

  Implement the application using a singly linked list

Implement the following application using a singly linked list. This application accepts from console and stores a list of 10 names of your friends in the singly linked list

  Create a class account that represents a banking account.

Create a class Account that represents a banking account.

  Write a method named validate to help a local banker

write a method named validate to help a local banker. Your method will need to utilize two input parameters and the method's return value (for its output).

  Create javascript program to find gross pay for employees

Create JavaScript program which will find out the gross pay for each of three employees. Company pays "straight time" for first 40 hours worked by each employee and pays "time and a half".

  Write a java program in a netbeans project

Write a Java program in a NetBeans project

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