<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Scilab ( https://www.scilab.org/ ) - This file is part of Scilab
 * Copyright (C) 2008 - INRIA
 * Copyright (C) 2010 - DIGITEO - Michael Baudin
 *
 * 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:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="isnan" xml:lang="en">
    <refnamediv>
        <refname>isnan</refname>
        <refpurpose>check for "Not a Number" entries</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>r=isnan(x)</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>x</term>
                <listitem>
                    <para>
                        real or complex vector or matrix r : boolean vector or
                        matrix
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            <literal>isnan(x)</literal> returns a boolean vector or matrix which
            contains true entries corresponding with "Not a Number"
            <literal>x</literal> entries and false entries corresponding with regular
            <literal>x</literal> entries.
        </para>
        <para>
            In this paragraph, we give the reason of the existence of this function.
            Consider the floating point number <literal>x</literal> and assume that
            we want to know if this number is a Not A Number.
            The condition <literal>(x==%nan)</literal> is false if <literal>x</literal> is equal
            to <literal>%nan</literal>. This is why the function <literal>isnan</literal> is helpful: it allows to
            see if a floating point number is a NaN, without actually comparing its value
            against <literal>%nan</literal>.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
isnan([1 0.01 -%nan %inf-%inf])
 ]]></programlisting>
        <para>
            In the following example, we see that <literal>%nan</literal> has very particular
            comparison properties and compare the result with the <literal>isnan</literal> function.
        </para>
        <programlisting role="example"><![CDATA[
    %nan == %nan
    %nan <> %nan
    isnan(%nan)
 ]]></programlisting>
        <para>
            In the following example, we extract the non-NaNs values <literal>y</literal> from the array <literal>x</literal>.
        </para>
        <programlisting role="example"><![CDATA[
x = [1 2 %nan 3 %nan 4]
k = find(~isnan(x))
y = x(k)
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="isinf">isinf</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
