Download SandMatrix_4 Manual
Transcript
SandMatrix_4 Manual 4.2.2. Polynomial Arithmetic { PSUM , PPRD , PDIV }
The arithmetic functions provide convenient functionality for the basic operations: addition, subtraction,
multiplication and eucliedean division. A distinction is made between the three base routines (PSUM,
PPRD, and PDIV written by JM Baillard), and the four user-friendly drivers that automate the element
data entry and work out all the details behind the scenes.
For the first group, beside the element data entry, the control words for each operand polynomial and
the result are typically input in the X- , Y- and Z-registers of the stack. As follows:
Operation
Addition, Subtraction,
Multiplication
bbb.eee1 in Z
bbb.eee2 in Y
1st. Reg of result in X
Input
bbb.eee of result in X
Output
Euclidean Division
Copy
bbb.eee of dividend in Y
bbb.eee of divisor in Y
bbb.eee of source in Y
bbb or destination in X
bbb.eee of reminder in Y
bbb.eee of quotient in X
bbb.eee or result in X
Because registers R00 to R03 are used internally, they cannot be used to hold the polynomial
coefficients. (ie. all control words must start at bbb = 4 at least). Note also that none of the register
ranges should overlap. In addition, for the Euclidean Division the original polynomials are overwritten
with the results (quotient and reminder).
Let
and
a(x) = a0.xn+a1.xn-1+ ... + an-1.x+an
b(x) = b0.xm+b1.xm-1+ ... + bm-1.x+bm
then there are only 2 other polynomials q(x) and r(x) such that: a = b.q + r , with deg(r) < deg(b) .
Note that PDIV does not work if deg(a) < deg(b), but in this case q=0 and r=a.
Example 1.- Find the result of the polynomial product of a(x) * b(x), where:
a(x) = 2.x5 + 5.x4 - 21.x3 + 23.x2 + 3.x + 5 and b(x) = 2.x2 - 3.x + 1
We’ll use P*P for convenience. It’ll automatically store the coefficients of the operand polynomial in
registers {R04 to R09} and in registers {R10 to R12} respectively. The result polynomial will be stored
starting with register R20, leaving the operand polynomials untouched.
The solution is:
p(x) = 4.x7 + 4.x6 - 55.x5 + 114.x4 - 84.x3 + 24.x2 - 12.x + 5
Example 2.- Find the quotient and reminder for the polynomial division a(x) / b(x), where::
a(x) = 2.x5 + 5.x4 - 21.x3 + 23.x2 + 3.x + 5 and b(x) = 2.x2 - 3.x + 1
We’ll use P/P for convenience. It’ll store the dividend coefficients in registers {R04 to R09} and the
divisor’s in registers {R10 to R12}. Note that in this case the coefficients are already there – as entered
in the previous example, so you just have to press R/S during the process.
The solutions are displayed sequentially, starting with the quotient first. The indices convention
message ” Σ(aK*X^K)” is shown prior to the enumeration of each result polynomial. After completion,
the control word for the reminder is left in X, and the control word for the quatient is saved in R00.
The solutions are:
q(x) = x3 + 4.x 2 -5.x + 2 and r(x) = 14.x + 3
(c) Ángel Martin ‐ August 2013 Page 69