* Bug #7782 fixed - Trick for lcm and gcd
[scilab.git] / scilab / modules / elementary_functions / help / en_US / discrete / gcd.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) 2006-2008 - INRIA
5  *
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at
10  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
11  *
12  -->
13 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="gcd">
14     <refnamediv>
15         <refname>gcd</refname>
16         <refpurpose>Greatest Common Divisor</refpurpose>
17     </refnamediv>
18     <refsynopsisdiv>
19         <title>Calling Sequence</title>
20         <synopsis>[pgcd, U] = gcd(p)</synopsis>
21     </refsynopsisdiv>
22     <refsection>
23         <title>Arguments</title>
24         <variablelist>
25             <varlistentry>
26                 <term>p</term>
27                 <listitem>
28                     <para>
29                         a polynomial row vector <literal>p = [p1, ..., pn]</literal> (type equal to 2) or
30                         an integer row vector (type equal to 8).
31                     </para>
32                 </listitem>
33             </varlistentry>
34         </variablelist>
35     </refsection>
36     <refsection>
37         <title>Description</title>
38         <para>
39             <code>[pgcd, U] = gcd(p)</code> computes the gcd of components of <varname>p</varname> (<varname>pgcd</varname>) and a
40             unimodular matrix (with polynomial inverse) <varname>U</varname>, with minimal degree such that
41         </para>
42         <para>
43             <literal>p*U = [0 ... 0 pgcd]</literal>.
44         </para>
45         <para>
46             In mathematics, a <emphasis role='italic'>unimodular</emphasis> matrix
47             <literal>U</literal> is a square integer matrix having
48             determinant <literal>+1</literal> or <literal>-1</literal>.
49         </para>
50         <para>
51             The greatest common divisor of an array <literal>p</literal> of real numbersof real numbers can be obtained by
52             converting it to a polynomial before calling <literal>gcd</literal>, through <code>p = inv_coeff(p, 0)</code>.
53         </para>
54     </refsection>
55     <refsection>
56         <title>Examples</title>
57         <programlisting role="example"><![CDATA[
58 //polynomial case
59 s=poly(0,'s');
60 p=[s,s*(s+1)^2,2*s^2+s^3];
61 [pgcd,u]=gcd(p);
62 p*u
63
64 //integer case
65 V=int32([2^2*3^5, 2^3*3^2,2^2*3^4*5]);
66 [thegcd,U]=gcd(V)
67 V*U
68
69 gcd(uint8([15 20]))
70
71 gcd([iconvert(15,4) iconvert(20,4)])
72
73 gcd(iconvert([15 20],4))
74
75  ]]></programlisting>
76     </refsection>
77     <refsection role="see also">
78         <title>See Also</title>
79         <simplelist type="inline">
80             <member>
81                 <link linkend="bezout">bezout</link>
82             </member>
83             <member>
84                 <link linkend="lcm">lcm</link>
85             </member>
86             <member>
87                 <link linkend="hermit">hermit</link>
88             </member>
89         </simplelist>
90     </refsection>
91 </refentry>