<?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 - 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="spaninter">
    <refnamediv>
        <refname>spaninter</refname>
        <refpurpose>subspace intersection</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>[X,dim]=spaninter(A,B [,tol])</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>A, B</term>
                <listitem>
                    <para>two real or complex matrices with equal number of rows</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>X</term>
                <listitem>
                    <para>orthogonal or unitary square matrix</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>dim</term>
                <listitem>
                    <para>
                        integer, dimension of subspace range(<literal>A</literal>) inter range(<literal>B</literal>)
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            computes the intersection of range(<literal>A</literal>) and range(<literal>B</literal>).
        </para>
        <para>
            The first <literal>dim</literal> columns of <literal>X</literal> span this intersection i.e.
            <literal>X(:,1:dim)</literal> is an orthogonal basis for
        </para>
        <para>
            range(<literal>A</literal>) inter range(<literal>B</literal>)
        </para>
        <para>
            In the <literal>X</literal> basis <literal>A</literal> and <literal>B</literal> are respectively represented by:
        </para>
        <para>
            <literal>X'*A</literal> and <literal>X'*B</literal>.
        </para>
        <para>
            <literal>tol</literal> is a threshold (<literal>sqrt(%eps)</literal> is the default value).
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
A=rand(5,3)*rand(3,4);     // A is 5 x 4, rank=3
B=[A(:,2),rand(5,1)]*rand(2,2);
[X,dim]=spaninter(A,B);
X1=X(:,1:dim);    //The intersection
svd(A),svd([X1,A])   // X1 in span(A)
svd(B),svd([B,X1])   // X1 in span(B)
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="spanplus">spanplus</link>
            </member>
            <member>
                <link linkend="spantwo">spantwo</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
