Help build: remove the householder image demo which open scinotes
[scilab.git] / scilab / modules / linear_algebra / help / en_US / factorization / householder.xml
index 84c957f..c5a751f 100644 (file)
@@ -2,7 +2,8 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2008 - INRIA
- * 
+ * Copyright (C) 2015 - Samuel GOUGEON
+ *
  * Copyright (C) 2012 - 2016 - Scilab Enterprises
  *
  * This file is hereby licensed under the terms of the GNU GPL v2.0,
@@ -11,8 +12,6 @@
  * and continues to be available under such terms.
  * For more information, see the COPYING file which you should have received
  * along with this program.
- * === LICENSE_END ===
- *
  -->
 <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="householder">
     <refnamediv>
         <refpurpose>Householder orthogonal reflexion matrix</refpurpose>
     </refnamediv>
     <refsynopsisdiv>
-        <title>Calling Sequence</title>
-        <synopsis>u=householder(v [,w])</synopsis>
+        <title>Syntax</title>
+        <synopsis>
+            householder() // demo
+            u = householder(v [,w])
+            [u, H] = householder(v [,w])
+        </synopsis>
     </refsynopsisdiv>
-    <refsection>
+    <refsection role="arguments">
         <title>Arguments</title>
         <variablelist>
             <varlistentry>
                 <term>w</term>
                 <listitem>
                     <para>
-                        real or complex column vector with same size as <literal>v</literal>. Default value is <literal>eye(v)</literal>
+                        real or complex column vector with same size as <literal>v</literal>.
+                        Default value is <literal>eye(v)</literal> ((Ox) axis).
                     </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>u</term>
                 <listitem>
-                    <para>real or complex column vector</para>
+                    <para>
+                        unit vector lying in the <literal>(v,w)</literal> plane and orthogonal
+                        to the bisectrix of <literal>(v,w)</literal>.
+                        Column of size(v) of real or complex numbers.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>H</term>
+                <listitem>
+                    <para>
+                        Orthogonal Householder reflexion matrix: <literal>H= eye() - 2*u*u'</literal>.
+                        <varname>H</varname> is such that <literal>inv(H)==H</literal>,
+                        <literal>H'==H</literal>, and <literal>det(H)==-1</literal>.
+                    </para>
+                    <para>
+                        If <varname>v</varname> and <varname>w</varname> are real,
+                        <literal>H*v</literal> is proportional to <varname>w</varname>.
+                    </para>
                 </listitem>
             </varlistentry>
         </variablelist>
     </refsection>
-    <refsection>
+    <refsection role="description">
         <title>Description</title>
         <para>
-            given 2 column vectors <literal>v</literal>, <literal> w</literal> of same size, <literal>householder(v,w)</literal> returns a unitary 
-            column vector <literal>u</literal>, such that <literal> (eye()-2*u*u')*v</literal> is proportional to <literal>w</literal>.
-            <literal>(eye()-2*u*u')</literal> is the orthogonal Householder reflexion matrix .
+            <literal>householder(..)</literal> computes the unit vector <varname>u</varname>
+            lying in the <literal>(v,w)</literal> plane and orthogonal to the bisectrix of
+            <literal>(v,w)</literal>.
         </para>
         <para>
-            <literal>w</literal> default value is <literal> eye(v)</literal>. In this case vector <literal> (eye()-2*u*u')*v</literal> is the 
-            vector  <literal> eye(v)*norm(v)</literal>.
+            If <varname>v</varname> and <varname>w</varname> are proportional:
+            <itemizedlist>
+                <listitem>
+                    <para>
+                        If they are opposite, <literal>u= v/|v|</literal> is returned.
+                    </para>
+                </listitem>
+                <listitem>
+                    If they are real and have the same direction, <varname>u</varname> is set
+                    in the (xOy) plane with a priori <literal>u(1)>0</literal>, and orthogonal to
+                    <varname>v</varname> (<literal>u'*v==0</literal>). However,
+                    <itemizedlist>
+                        <listitem>
+                            If they are along (Ox), <literal>u = (Oy+)</literal> is returned instead.
+                        </listitem>
+                        <listitem>
+                            If <varname>v</varname> and <varname>w</varname> are scalars with same
+                            signs, the orthogonal sub-space is restricted to <literal>{0}</literal>
+                            that can't be normalized:
+                            <varname>u</varname> and <varname>H</varname> are then set to
+                            <literal>%nan</literal>.
+                        </listitem>
+                    </itemizedlist>
+                </listitem>
+            </itemizedlist>
         </para>
+        <para>
+            If the related reflexion matrix <varname>H</varname> is computed, for any point A
+            of column coordinates <literal>a</literal>, <literal>H*a</literal> are the coordinates of
+            the reflected image of A (see the example below).
+        </para>
+        <note>
+            If <varname>v</varname> or/and <varname>w</varname> are in row, they are priorly
+            transposed into columns.
+        </note>
+        <warning>
+            If <varname>v</varname> or/and <varname>w</varname> are <literal>[]</literal>,
+            <literal>[]</literal> is returned for <varname>u</varname> and <varname>H</varname>.
+        </warning>
+    </refsection>
+    <refsection role="examples">
+        <title>Examples</title>
+        <programlisting role="example"><![CDATA[
+a = [ rand(1,1) 0  0 ]';
+[ra hm] = householder(a);
+[a ra hm*a ]
+norm(ra)
+
+b = rand(3,1);
+[rb, hm] = householder(b);
+[b rb eye(b) clean(hm*b) ]
+norm(rb)
+
+[rb2b, hm] = householder(b, 2*b);
+[b rb2b clean(hm*b ./ b) ]  // last column must be uniform
+norm(rb2b)                  // must be 1
+
+c = rand(3,1);
+[rbc, hm] = householder(b,c);
+norm(rbc)          // must be 1
+hm*b ./c           // must be uniform
+
+d = b + %i*c;
+e = rand(3,1) + %i*rand(3,1);
+[rde, hm] = householder(d,e);
+norm(rbc)               // must be 1
+clean(inv(hm) - hm)     // must be zeros(3,3)
+clean(hm' - hm)         // must be zeros(3,3)
+clean(det(hm))          // must be -1
+ ]]></programlisting>
+        
+        <para>
+            <emphasis role="bold"> Application:</emphasis> Reflected image of an object w.r. to a given plane
+        </para>
+        <programlisting role="example"><![CDATA[
+// (OA) = [0 0 1] is reflected in O into (OB) = [ 1 1 0.3 ]:
+[n, H] = householder([0 0 1]', [ 1 1 0.3 ]');
+// "n" is the unit vector orthogonal to the reflecting plane
+
+// Emitting object (feature from shell demo):
+u = linspace(0,2*%pi,40);
+v = linspace(0,2*%pi,20);
+Xe = (cos(u).*u)'*(1+cos(v)/2)+10;
+Ye = (u/2)'*sin(v);
+Ze = (sin(u).*u)'*(1+cos(v)/2);
+
+// Reflected object:
+Pe = [ Xe(:)' ; Ye(:)' ; Ze(:)'];
+Pr = H*Pe;
+Xr = matrix(Pr(1,:),40,-1);
+Yr = matrix(Pr(2,:),40,-1);
+Zr = matrix(Pr(3,:),40,-1);
+
+// Reflecting plane containing O: n(1).x + n(2).y + n(3).z = 0
+//   Sampling space:
+x = linspace(min([Xe(:);Xr(:)]), max([Xe(:);Xr(:)]),20);
+y = linspace(min([Ye(:);Yr(:)]), max([Ye(:);Yr(:)]),20);
+[X, Y] = meshgrid(x,y);
+//   Generating the mirror:
+deff("z = mirror(x,y,n)","z = -n(1)/n(3)*x - n(2)/n(3)*y")
+Zm = mirror(X,Y,n);
+
+// Plotting:
+clf
+drawlater
+f = gcf();
+f.color_map = [ 0.8 0.8 0.8 ; jetcolormap(100)];
+surf(Xe,Ye,Ze)
+surf(X,Y,Zm)
+surf(Xr,Yr,Zr)
+a = gca();
+a.isoview = "on";
+a.rotation_angles = [74 123];
+a.children.color_flag = 0;
+a.children.color_mode = 0;
+a.children(1).foreground = color("red");
+a.children(2).foreground = 1;
+a.children(3).foreground = color("green");
+drawnow
+ ]]></programlisting>
     </refsection>
     <refsection role="see also">
         <title>See Also</title>
             </member>
         </simplelist>
     </refsection>
+    <refsection role="history">
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>6.0</revnumber>
+                <revdescription>
+                    <para>Householder reflexion matrix added as second output parameter.
+                        Demo householder() added. Help page reviewed.
+                    </para>
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>