* Bug 15058 fixed: gcd and lcm result could be puzzingly <0
[scilab.git] / scilab / modules / elementary_functions / help / en_US / discrete / lcm.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  * Copyright (C) 2012 - 2016 - Scilab Enterprises
7  *
8  * This file is hereby licensed under the terms of the GNU GPL v2.0,
9  * pursuant to article 5.3.4 of the CeCILL v.2.1.
10  * This file was originally licensed under the terms of the CeCILL v2.1,
11  * and continues to be available under such terms.
12  * For more information, see the COPYING file which you should have received
13  * along with this program.
14  *
15  -->
16 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17           xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
18           xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
19           xml:lang="en" xml:id="lcm">
20     <refnamediv>
21         <refname>lcm</refname>
22         <refpurpose>least common (positive) multiple of integers or of polynomials</refpurpose>
23     </refnamediv>
24     <refsynopsisdiv>
25         <title>Syntax</title>
26         <synopsis>
27            pp = lcm(p)
28           [pp, fact] = lcm(p)
29         </synopsis>
30     </refsynopsisdiv>
31     <refsection>
32         <title>Arguments</title>
33         <variablelist>
34             <varlistentry>
35                 <term>p</term>
36                 <listitem>
37                     <para>
38                         a polynomial row vector <literal>p = [p1, ..., pn]</literal> (type equal to 2) or
39                         an integer row vector (type equal to 1 or 8).
40                     </para>
41                 </listitem>
42             </varlistentry>
43             <varlistentry>
44                 <term>fact</term>
45                 <listitem>
46                     <para>a polynomial vector or an integer vector.</para>
47                 </listitem>
48             </varlistentry>
49             <varlistentry>
50                 <term>pp</term>
51                 <listitem>
52                     <para>a polynomial or an integer.</para>
53                 </listitem>
54             </varlistentry>
55         </variablelist>
56     </refsection>
57     <refsection>
58         <title>Description</title>
59         <para>
60             <code>pp = lcm(p)</code> computes the lcm <varname>pp</varname> of polynomial vector <varname>p</varname>.
61         </para>
62         <para>
63             <code>[pp, fact] = lcm(p)</code> computes in addition the vector <varname>fact</varname>
64             such that <literal>p.*fact = pp*ones(p)</literal>.
65         </para>
66         <para>
67           If <literal>p</literal> is a set of integers with some negative ones, the returned value
68           <literal>pp</literal> of their LCM is always positive.
69         </para>
70         <para>
71             If <literal>p</literal> is an array of decimal integers, they are priorly converted
72             into <literal>int32</literal> before processing.
73         </para>
74         <para>
75             The least common multiple of an array <literal>p</literal> of real numbers can be
76             obtained by converting it to a polynomial before calling <literal>lcm</literal>,
77             through <code>p = inv_coeff(p, 0)</code>.
78         </para>
79     </refsection>
80     <refsection>
81         <title>Examples</title>
82         <programlisting role="example"><![CDATA[
83 // Polynomial case
84 s = %s;
85 p = [s s*(s+1)^2 s^2*(s+2)];
86 [pp,fact] = lcm(p);
87 p.*fact, pp
88
89 // Integer case
90 V = int32([2^2*3^5, 2^3*3^2,2^2*3^4*5]);
91 lcm(V)
92
93 // Double case
94 V = [2^2*3^5, 2^3*3^2,2^2*3^4*5];
95 lcm(V)
96  ]]></programlisting>
97     </refsection>
98     <refsection role="see also">
99         <title>See also</title>
100         <simplelist type="inline">
101             <member>
102                 <link linkend="gcd">gcd</link>
103             </member>
104             <member>
105                 <link linkend="bezout">bezout</link>
106             </member>
107         </simplelist>
108     </refsection>
109     <refsection role="history">
110         <title>History</title>
111         <revhistory>
112             <revision>
113                 <revnumber>6.0.1</revnumber>
114                 <revdescription>
115                    For input integers possibly negative, the returned LCM is now always positive.
116                 </revdescription>
117             </revision>
118         </revhistory>
119     </refsection>
120 </refentry>