Additional (Success) Note on Simplification :
Similar to gcd_SK_GHB.m's modification over gcd.m, here too,
we suppress u2, v2 and t2 calcs at intermediate steps
to avoid calculations on the "0, 1" part. Refer Bradley's suggestion
as given in Knuth, 4.5.2, Vol2 / P342, 343.
However, in tests involving upto 20000 random numbers in the
Time Diff Test below, the time taken by the Suppressed case
has surprisingly come out to be higher !
Functional Description :
I developed CMPLX_GCD.m because I could not find a Matlab's
Standard function which could find the GCD for complex numbers.
CMPLX_GCD is on the lines of Matlab's standard gcd.m ;
I developed CMPLX_GCD.m mainly to solve some Exercise problems
of I.2, specially Problem 15, in Pages 15 - 18 of the book :
A course in Number Theory and Cryptography by Neal Koblitz
a and b are input complex vectors of the same size, whose GCD is
output as g.
c and d output vectors are such that a.*c + b.*d = g
str_q_limit is by default = 'round' ; other choices are 'floor' and ' ceil'.
It is used to get Gaussian Integers (complex numbers whose real and
imag are integers) of the quotient at every intermediate step.
The Default chosen is round (q).
You may also refer to Gen_Primes_Eq_2_Sqs.m where I "generate /
discover" a series of primes which are sum of squares of 2 integers.
The Usage Egs below show many variations of applying this programme.
More explanation of Problems 15a,b, c of Exercise I.2 of the book
is given in my notes at the end.
A good explanation of the concept can also be had
Oct 2004 :
In the earlier version , I had kept the real part of g always positive.
But now, I have removed that restriction.
Also to facilitate easy calling within Poly_GCD_Main.m, an additional
output k_divs is brought out.
July 2005 : iter has been added. If an error is thrown with iter,
try other options for str_q_limit.
See also my code(s) gcd_SK_GHB, Poly_GCD, Poly_POWER
Should generally work in R13 and R12 also.
Sundar Krishnan (2023). GCD of Complex Numbers (https://www.mathworks.com/matlabcentral/fileexchange/5583-gcd-of-complex-numbers), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!