Q:

GCD function in matlab

i am looking for a way to implement the "gcd" function used in matlab in another language but i really cant understand the way it functions.
it says in http://www.mathworks.com/access/helpdesk/help/techdoc/ref/gcd.html that:
"[G,C,D] = gcd(A,B) returns both the greatest common divisor array G, and the arrays C and D, which satisfy the equation: A(i).*C(i) + B(i).*D(i) = G(i)."
but it says nothing about how it calculates C and D.
i would be grateful if someone has a clearer idea about this subject! 
thanks:)

A:

The extended Euclidean algorithm.
("Section 4.5.2 Algorithm X" being this can be shown in http://www.fitc.unc.edu.ar/javadev/math/previous/algorithms.html.)

