<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA
 *
 * Copyright (C) 2012 - 2016 - Scilab Enterprises
 *
 * This file is hereby licensed under the terms of the GNU GPL v2.0,
 * pursuant to article 5.3.4 of the CeCILL v.2.1.
 * This file was originally licensed under the terms of the CeCILL v2.1,
 * and continues to be available under such terms.
 * For more information, see the COPYING file which you should have received
 * along with this program.
 *
 -->
<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="companion">
    <refnamediv>
        <refname>companion</refname>
        <refpurpose>companion matrix</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>A=companion(p)</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>p</term>
                <listitem>
                    <para>polynomial or vector of polynomials</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>A</term>
                <listitem>
                    <para>square matrix</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            Returns a matrix <literal>A</literal> with characteristic polynomial equal
            to <literal>p</literal> if <literal>p</literal> is monic. If <literal>p</literal> is not monic
            the characteristic polynomial of <literal>A</literal> is equal to
            <literal>p/c</literal> where <literal>c</literal> is the coefficient of largest degree
            in <literal>p</literal>.
        </para>
        <para>
            If <literal>p</literal> is a vector of monic polynomials, <literal>A</literal> is block diagonal,
            and the characteristic polynomial of the ith block is <literal>p(i)</literal>.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
s=poly(0,'s');
p=poly([1,2,3,4,1],'s','c')
det(s*eye(4,4)-companion(p))
roots(p)
spec(companion(p))
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="spec">spec</link>
            </member>
            <member>
                <link linkend="poly">poly</link>
            </member>
            <member>
                <link linkend="randpencil">randpencil</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
