GCD of Complex Numbers

GCD of complex numbers.
1.4K Downloads
Updated 14 Jul 2005

No License

CMPLX_GCD_Supr_2.m :
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
in Gen_Primes_Eq_2_Sqs.m

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
and Ch_Rem_Thr_Poly.

Should generally work in R13 and R12 also.

Cite As

Sundar Krishnan (2024). GCD of Complex Numbers (https://www.mathworks.com/matlabcentral/fileexchange/5583-gcd-of-complex-numbers), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Operators and Elementary Operations in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0

'round' a better choice. iter added.