~ubuntu-branches/ubuntu/raring/scilab/raring-proposed

« back to all changes in this revision

Viewing changes to modules/elementary_functions/help/en_US/complex/complex.xml

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2012-08-30 14:42:38 UTC
  • mfrom: (1.4.7)
  • Revision ID: package-import@ubuntu.com-20120830144238-c1y2og7dbm7m9nig
Tags: 5.4.0-beta-3-1~exp1
* New upstream release
* Update the scirenderer dep
* Get ride of libjhdf5-java dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 *
12
12
 -->
13
13
<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" version="5.0-subset Scilab" xml:id="complex" xml:lang="en">
14
 
  <refnamediv>
15
 
    <refname>complex</refname>
16
 
    <refpurpose>Create a complex number.</refpurpose>
17
 
  </refnamediv>
18
 
  <refsynopsisdiv>
19
 
    <title>Calling Sequence</title>
20
 
    <synopsis>
21
 
      c=complex(a)
22
 
      c=complex(a,b)
23
 
    </synopsis>
24
 
  </refsynopsisdiv>
25
 
  <refsection>
26
 
    <title>Arguments</title>
27
 
    <variablelist>
28
 
      <varlistentry>
29
 
        <term>a</term>
30
 
        <listitem>
31
 
          <para>
32
 
            a 1-by-1 or a n-by-m real matrix of doubles, the real part.
33
 
            If <literal>a</literal> has an imaginary part, an error 
34
 
            is generated.
35
 
          </para>
36
 
        </listitem>
37
 
      </varlistentry>
38
 
      <varlistentry>
39
 
        <term>b</term>
40
 
        <listitem>
41
 
          <para>
42
 
            a 1-by-1 or a n-by-m real matrix of doubles, the imaginary part (default b=0).
43
 
            If <literal>b</literal> has an imaginary part, an error 
44
 
            is generated.
45
 
          </para>
46
 
        </listitem>
47
 
      </varlistentry>
48
 
      <varlistentry>
49
 
        <term>c</term>
50
 
        <listitem>
51
 
          <para>a n-by-m complex matrix of doubles, the complex number.</para>
52
 
        </listitem>
53
 
      </varlistentry>
54
 
    </variablelist>
55
 
  </refsection>
56
 
  <refsection>
57
 
    <title>Description</title>
58
 
    <para>
59
 
      c=complex(a) creates a complex number from its real part <literal>a</literal> 
60
 
      and zero as the imaginary part.
61
 
    </para>
62
 
    <para>
63
 
      c=complex(a,b) creates a complex number from its real part <literal>a</literal> 
64
 
      and imaginary part <literal>b</literal>.
65
 
    </para>
66
 
    <para>
67
 
      This function is a substitute for expressions such as <literal>a+%i*b</literal>,
68
 
      especially in cases where the complex arithmetic interferes with particular
69
 
      floating point numbers such as <literal>%inf</literal> or
70
 
      <literal>%nan</literal>.
71
 
    </para>
72
 
  </refsection>
73
 
  <refsection>
74
 
    <title>Examples</title>
75
 
    <para>
76
 
      In the following example, we create a complex number from
77
 
      its real and imaginary parts.
78
 
    </para>
79
 
    <programlisting role="example"><![CDATA[ 
 
14
    <refnamediv>
 
15
        <refname>complex</refname>
 
16
        <refpurpose>Create a complex number.</refpurpose>
 
17
    </refnamediv>
 
18
    <refsynopsisdiv>
 
19
        <title>Calling Sequence</title>
 
20
        <synopsis>
 
21
            c=complex(a)
 
22
            c=complex(a,b)
 
23
        </synopsis>
 
24
    </refsynopsisdiv>
 
25
    <refsection>
 
26
        <title>Arguments</title>
 
27
        <variablelist>
 
28
            <varlistentry>
 
29
                <term>a</term>
 
30
                <listitem>
 
31
                    <para>
 
32
                        a 1-by-1 or a n-by-m real matrix of doubles, the real part.
 
33
                        If <literal>a</literal> has an imaginary part, an error 
 
34
                        is generated.
 
35
                    </para>
 
36
                </listitem>
 
37
            </varlistentry>
 
38
            <varlistentry>
 
39
                <term>b</term>
 
40
                <listitem>
 
41
                    <para>
 
42
                        a 1-by-1 or a n-by-m real matrix of doubles, the imaginary part (default b=0).
 
43
                        If <literal>b</literal> has an imaginary part, an error 
 
44
                        is generated.
 
45
                    </para>
 
46
                </listitem>
 
47
            </varlistentry>
 
48
            <varlistentry>
 
49
                <term>c</term>
 
50
                <listitem>
 
51
                    <para>a n-by-m complex matrix of doubles, the complex number.</para>
 
52
                </listitem>
 
53
            </varlistentry>
 
54
        </variablelist>
 
55
    </refsection>
 
56
    <refsection>
 
57
        <title>Description</title>
 
58
        <para>
 
59
            c=complex(a) creates a complex number from its real part <literal>a</literal> 
 
60
            and zero as the imaginary part.
 
61
        </para>
 
62
        <para>
 
63
            c=complex(a,b) creates a complex number from its real part <literal>a</literal> 
 
64
            and imaginary part <literal>b</literal>.
 
65
        </para>
 
66
        <para>
 
67
            This function is a substitute for expressions such as <literal>a+%i*b</literal>,
 
68
            especially in cases where the complex arithmetic interferes with particular
 
69
            floating point numbers such as <literal>%inf</literal> or
 
70
            <literal>%nan</literal>.
 
71
        </para>
 
72
    </refsection>
 
73
    <refsection>
 
74
        <title>Examples</title>
 
75
        <para>
 
76
            In the following example, we create a complex number from
 
77
            its real and imaginary parts.
 
78
        </para>
 
79
        <programlisting role="example"><![CDATA[ 
80
80
complex(1,2)
81
81
complex([1 2],[3 4])
82
82
 ]]></programlisting>
83
 
    <para>
84
 
      If <literal>a</literal> only is specified, then the imaginary 
85
 
      part is set to zero.
86
 
    </para>
87
 
    <programlisting role="example"><![CDATA[ 
 
83
        <para>
 
84
            If <literal>a</literal> only is specified, then the imaginary 
 
85
            part is set to zero.
 
86
        </para>
 
87
        <programlisting role="example"><![CDATA[ 
88
88
complex([1 2 3])
89
89
 ]]></programlisting>
90
 
    <para>
91
 
      If <literal>a</literal> is a scalar and <literal>b</literal> 
92
 
      is a matrix, then the result <literal>c</literal> has the same 
93
 
      size as <literal>b</literal>.
94
 
      Similarily, if <literal>b</literal> is a scalar and <literal>a</literal> 
95
 
      is a matrix, then the result <literal>c</literal> has the same 
96
 
      size as <literal>a</literal>.
97
 
    </para>
98
 
    <programlisting role="example"><![CDATA[ 
 
90
        <para>
 
91
            If <literal>a</literal> is a scalar and <literal>b</literal> 
 
92
            is a matrix, then the result <literal>c</literal> has the same 
 
93
            size as <literal>b</literal>.
 
94
            Similarily, if <literal>b</literal> is a scalar and <literal>a</literal> 
 
95
            is a matrix, then the result <literal>c</literal> has the same 
 
96
            size as <literal>a</literal>.
 
97
        </para>
 
98
        <programlisting role="example"><![CDATA[ 
99
99
c = complex([1 2 3], 4)
100
100
c = complex(1, [2 3 4])
101
101
 ]]></programlisting>
102
 
    <para>
103
 
      If <literal>a</literal> and <literal>b</literal> are two 
104
 
      matrices with different sizes, an error is generated, as in the 
105
 
      following session.
106
 
    </para>
107
 
    <screen><![CDATA[ 
 
102
        <para>
 
103
            If <literal>a</literal> and <literal>b</literal> are two 
 
104
            matrices with different sizes, an error is generated, as in the 
 
105
            following session.
 
106
        </para>
 
107
        <screen><![CDATA[ 
108
108
-->complex(ones(2,3),ones(4,5))
109
109
 !--error 10000 
110
110
complex: Incompatible input arguments #1 and #2: Same sizes expected.
111
111
at line      33 of function complex called by :  
112
112
complex(ones(2,3),ones(4,5))
113
113
 ]]></screen>
114
 
    <para>
115
 
      The purpose of the <literal>complex</literal> function is to manage 
116
 
      IEEE floating point numbers such as Nans or Infinities. 
117
 
      In the following example, we show that creating a complex number where
118
 
      the real and imaginary parts are complex is not straightforward if
119
 
      we use the complex arithmetic.
120
 
      This is because the product <literal>%i</literal> times <literal>%inf</literal>
121
 
      is evaluated as <literal>(0+%i) * (%inf+%i*0)</literal>.
122
 
      This produces the intermediate expression <literal>0*%inf</literal>,
123
 
      which is <literal>%nan</literal>.
124
 
    </para>
125
 
    <screen><![CDATA[ 
 
114
        <para>
 
115
            The purpose of the <literal>complex</literal> function is to manage 
 
116
            IEEE floating point numbers such as Nans or Infinities. 
 
117
            In the following example, we show that creating a complex number where
 
118
            the real and imaginary parts are complex is not straightforward if
 
119
            we use the complex arithmetic.
 
120
            This is because the product <literal>%i</literal> times <literal>%inf</literal>
 
121
            is evaluated as <literal>(0+%i) * (%inf+%i*0)</literal>.
 
122
            This produces the intermediate expression <literal>0*%inf</literal>,
 
123
            which is <literal>%nan</literal>.
 
124
        </para>
 
125
        <screen><![CDATA[ 
126
126
-->%inf+%i*%inf
127
127
 ans  =
128
128
    Nan + Inf 
129
129
 ]]></screen>
130
 
    <para>
131
 
      The solution of this issue is to use the <literal>complex</literal>
132
 
      function.
133
 
    </para>
134
 
    <screen><![CDATA[ 
 
130
        <para>
 
131
            The solution of this issue is to use the <literal>complex</literal>
 
132
            function.
 
133
        </para>
 
134
        <screen><![CDATA[ 
135
135
-->complex(%inf,%inf)
136
136
 ans  =
137
137
    Inf + Inf 
138
138
 ]]></screen>
139
 
  </refsection>
140
 
  <refsection role="see also">
141
 
    <title>See Also</title>
142
 
    <simplelist type="inline">
143
 
      <member>
144
 
        <link linkend="imult">imult</link>
145
 
      </member>
146
 
    </simplelist>
147
 
  </refsection>
 
139
    </refsection>
 
140
    <refsection role="see also">
 
141
        <title>See Also</title>
 
142
        <simplelist type="inline">
 
143
            <member>
 
144
                <link linkend="imult">imult</link>
 
145
            </member>
 
146
        </simplelist>
 
147
    </refsection>
148
148
</refentry>