|
basix_doc 0.1
|
#include <int.hpp>
| static I gcd | ( | const I & | a, |
| const I & | b | ||
| ) | [inline, static] |
Definition at line 449 of file int.hpp.
References mmx::I().
{
typedef typename unsigned_of_helper<I>::type U;
I r0 = a, r1 = b, q, t;
if ((r0 == 0) && (r1 != 0)) {
q = (((U) r0) - ((U) r1)) / ((U) r1) + 1;
t = r0 - q * r1;
r0 = r1;
r1 = t;
}
while (r1 != 0) {
q = r0 / r1;
t = r0 - q * r1;
r0 = r1;
r1 = t;
}
return r0;
}
| static I gcd | ( | const I & | a, |
| const I & | b, | ||
| I & | co_a, | ||
| I & | co_b | ||
| ) | [inline, static] |
Definition at line 494 of file int.hpp.
References mmx::I().
{
typedef typename unsigned_of_helper<I>::type U;
I r0 = a, r1 = b, co_a0 = 1, co_a1 = 0, co_b0 = 0, co_b1 = 1, q, t;
if ((r0 == 0) && (r1 != 0)) {
q = (((U) r0) - ((U) r1)) / ((U) r1) + 1;
t = r0 - q * r1;
r0 = r1;
r1 = t;
t = co_a1;
co_a1 = co_a0 - q * co_a1;
co_a0 = t;
t = co_b1;
co_b1 = co_b0 - q * co_b1;
co_b0 = t;
}
while (r1 != 0) {
q = r0 / r1;
t = r0 - q * r1;
r0 = r1;
r1 = t;
t = co_a1;
co_a1 = co_a0 - q * co_a1;
co_a0 = t;
t = co_b1;
co_b1 = co_b0 - q * co_b1;
co_b0 = t;
}
co_a = co_a0;
co_b = co_b0;
return r0;
}
| static I gcd | ( | const I & | a, |
| const I & | b, | ||
| I & | co_a | ||
| ) | [inline, static] |
Definition at line 468 of file int.hpp.
References mmx::I().
{
typedef typename unsigned_of_helper<I>::type U;
I r0 = a, r1 = b, co_a0 = 1, co_a1 = 0, q, t;
if ((r0 == 0) && (r1 != 0)) {
q = (((U) r0) - ((U) r1)) / ((U) r1) + 1;
t = r0 - q * r1;
r0 = r1;
r1 = t;
t = co_a1;
co_a1 = co_a0 - q * co_a1;
co_a0 = t;
}
while (r1 != 0) {
q = r0 / r1;
t = r0 - q * r1;
r0 = r1;
r1 = t;
t = co_a1;
co_a1 = co_a0 - q * co_a1;
co_a0 = t;
}
co_a = co_a0;
return r0;
}