function g = matgcd(u) % MATGCD Greatest common divisor % G = MATGCD(U) is the greatest common divisor of % the entries in matrix U. % G = MATGCD(0) is 0 by convention; all other GCDs % are positive integers. % % See also MATLCM % Written by Serge Tchikanda 03/26/96. u = u(:); n=length(u); u1 = u(1); if n == 1 g = u; elseif n==2 g = gcd(u(1),u(2)); else u(1)=[]; g = gcd(u1,matgcd(u)); end