Created
September 30, 2012 16:59
-
-
Save rahcola/3807597 to your computer and use it in GitHub Desktop.
a PSEUDO C translation of week 4. exercise 2.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*THIS IS PSEUDO*/ | |
divResult mod_div_polynomials(int mod, | |
termNode* p, | |
termNode* q) { | |
termNode* r = p; | |
termNode* s = NULL; | |
int b_inverse = ...; | |
for (int i = p->deg - q->deg; i >= 0; i--) { | |
if (r->deg == q->deg + i) { | |
int qi = r->coef * b_inverse; | |
termNode* t = mod_mul_polynomials(mod, make_term(i, -qi), q); | |
r = mod_add_polynomials(mod, r, t); | |
s = mod_add_polynomials(mod, s, make_term(i, qi)); | |
} | |
} | |
return {s, r}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment