<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA
 * Copyright (C) 2012 - Scilab Enterprises - Adeline CARNIS
 * Copyright (C) 2018 - Samuel GOUGEON
 *
 * 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="cond">
    <refnamediv>
        <refname>cond</refname>
        <refpurpose>condition number of a matrix</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
            c = cond(X)
            c = cond(X, p)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>X</term>
                <listitem>
                    <para>
                        real or complex matrix. For the <literal>c = cond(X,p)</literal> syntax,
                        <varname>X</varname> must be square.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>p</term>
                <listitem>
                    <para>1 | 2 | %inf | "inf" | "fro": Used norm. Default value = 2.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>c</term>
                <listitem>
                    <para>positive decimal number: the condition number.</para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <variablelist>
            <varlistentry>
                <term>c = cond(X)</term>
                <listitem>
                    <para>
                        returns condition number in 2-norm.<literal>cond(X)</literal> is the  ratio
                        of  the largest singular value of <literal>X</literal> to the smallest.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>c = cond(X, p)</term>
                <listitem>
                    <para>
                        returns the condition number in p-norm : <literal>norm(X, p) * norm(inv(X), p)</literal>.
                        <varname>p</varname> possible values are:
                    </para>
                    <para>
                        <table border="0">
                            <tr valign="top">
                                <td align="right"><emphasis role="bold">1 : </emphasis></td>
                                <td>condition number in 1-norm.</td>
                            </tr>
                            <tr valign="top">
                                <td align="right"><emphasis role="bold">2 : </emphasis></td>
                                <td>condition number in 2-norm.</td>
                            </tr>
                            <tr valign="top">
                                <td align="right"><emphasis role="bold">%inf | "inf" : </emphasis></td>
                                <td>condition number in infinite norm</td>
                            </tr>
                            <tr valign="top">
                                <td align="right"><emphasis role="bold">"fro" : </emphasis></td>
                                <td>condition number in Frobenius norm</td>
                            </tr>
                        </table>
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
// Condition number of a non-square matrix
cond([1 0 -1 ; 0 1 -1])

A = testmatrix('hilb',6);
// condition number in 2-norm
cond(A)
cond(A, 2)

// condition number in 1-norm
cond(A, 1)

// condition number in infinity norm
cond(A, %inf)

// condition number in Frobenius norm
cond(A, 'fro')
    ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="rcond">rcond</link>
            </member>
            <member>
                <link linkend="svd">svd</link>
            </member>
            <member>
                <link linkend="norm">norm</link>
            </member>
        </simplelist>
    </refsection>
    <refsection>
        <title>History</title>
        <revhistory>
            <revision>
                <revnumber>5.4.0</revnumber>
                <revdescription>
                    <itemizedlist>
                        <listitem>
                            cond(X) now accepts non square matrix.
                        </listitem>
                        <listitem>
                            New input argument p introduced.
                        </listitem>
                    </itemizedlist>
                </revdescription>
            </revision>
            <revision>
                <revnumber>6.0.2</revnumber>
                <revdescription>
                    cond([]) now returns 0 instead of 1.
                </revdescription>
            </revision>
        </revhistory>
    </refsection>
</refentry>
