summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel GOUGEON <sgougeon@free.fr>2016-08-07 01:57:55 +0200
committerClément DAVID <clement.david@scilab-enterprises.com>2016-12-16 15:27:19 +0100
commit5998194a77c8268b9ef93c162217ef274b54be3b (patch)
treee0bf832afc671bbf64826aa59b5c7af46172071a
parentb1be205a4987f1a3fb49db86f042ec5a3aab203c (diff)
downloadscilab-5998194a77c8268b9ef93c162217ef274b54be3b.zip
scilab-5998194a77c8268b9ef93c162217ef274b54be3b.tar.gz
Bug #592 fixed - linspace(a,b, n<=0) returned b instead of [].
* http://bugzilla.scilab.org/592 * The bug was fixed in 2006 by displaying an error message, but this was silently cancelled in 2009. See the report. * Arguments checking improved * unit test extended * Help page overhauled. Retranslation in (ja,pt,ru) will be needed. Change-Id: I8f3f5235be96a7cb5b97e0ab94274b86ba111030
-rw-r--r--scilab/CHANGES.md2
-rw-r--r--scilab/modules/core/tests/nonreg_tests/bug_8086.dia.ref3
-rw-r--r--scilab/modules/core/tests/nonreg_tests/bug_8086.tst3
-rw-r--r--scilab/modules/elementary_functions/help/en_US/elementarymatrices/linspace.xml146
-rw-r--r--scilab/modules/elementary_functions/help/fr_FR/elementarymatrices/linspace.xml171
-rw-r--r--scilab/modules/elementary_functions/help/ja_JP/elementarymatrices/linspace.xml95
-rw-r--r--scilab/modules/elementary_functions/help/pt_BR/elementarymatrices/linspace.xml77
-rw-r--r--scilab/modules/elementary_functions/help/ru_RU/elementarymatrices/linspace.xml142
-rw-r--r--scilab/modules/elementary_functions/macros/linspace.sci54
-rw-r--r--scilab/modules/elementary_functions/macros/logspace.sci12
-rw-r--r--scilab/modules/elementary_functions/tests/nonreg_tests/bug_12913.dia.ref2
-rw-r--r--scilab/modules/elementary_functions/tests/nonreg_tests/bug_12913.tst2
-rw-r--r--scilab/modules/elementary_functions/tests/nonreg_tests/bug_592.dia.ref21
-rw-r--r--scilab/modules/elementary_functions/tests/nonreg_tests/bug_592.tst25
-rw-r--r--scilab/modules/elementary_functions/tests/unit_tests/linspace.dia.ref30
-rw-r--r--scilab/modules/elementary_functions/tests/unit_tests/linspace.tst31
-rw-r--r--scilab/modules/elementary_functions/tests/unit_tests/logspace.dia.ref2
-rw-r--r--scilab/modules/elementary_functions/tests/unit_tests/logspace.tst3
18 files changed, 549 insertions, 272 deletions
diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md
index 9376dc4..7a639ad 100644
--- a/scilab/CHANGES.md
+++ b/scilab/CHANGES.md
@@ -179,6 +179,7 @@ input and output arguments.
179* `pdiv`: Return a matrix of type 'constant' when all the rank are 0. 179* `pdiv`: Return a matrix of type 'constant' when all the rank are 0.
180* `test_run` can now take "[]" as argument to be used on console; for instance: `test_run string [] no_check_ref`. 180* `test_run` can now take "[]" as argument to be used on console; for instance: `test_run string [] no_check_ref`.
181* `typeof(:)` and `typeof(n:$)` now return `"implicitlist"` instead of respectively `"constant"` and `"size implicit"`. 181* `typeof(:)` and `typeof(n:$)` now return `"implicitlist"` instead of respectively `"constant"` and `"size implicit"`.
182* `linspace(a, b, n<=0)` now returns `[]` instead of b.
182* `strange([])` now returns `%nan` instead of `[]`, as all other functions for statistical dispersion. 183* `strange([])` now returns `%nan` instead of `[]`, as all other functions for statistical dispersion.
183* `stdev(x, dir>ndims(x))` now yields an error instead of returning `zeros(x)`. 184* `stdev(x, dir>ndims(x))` now yields an error instead of returning `zeros(x)`.
184* `write`: Writing string or string matrix in a file does not add blank space before each value. 185* `write`: Writing string or string matrix in a file does not add blank space before each value.
@@ -318,6 +319,7 @@ Bug Fixes
318--------- 319---------
319 320
320### Bugs fixed in 6.0.0: 321### Bugs fixed in 6.0.0:
322* [#592](http://bugzilla.scilab.org/show_bug.cgi?id=592): `linspace(a, b, n<=0)` returned `b` instead of `[]`
321* [#2919](http://bugzilla.scilab.org/show_bug.cgi?id=2919): The `fchamp` example and demo were unclear and badly rendered 323* [#2919](http://bugzilla.scilab.org/show_bug.cgi?id=2919): The `fchamp` example and demo were unclear and badly rendered
322* [#4327](http://bugzilla.scilab.org/show_bug.cgi?id=4327): Overloading did not support custom types names longer than 8 characters 324* [#4327](http://bugzilla.scilab.org/show_bug.cgi?id=4327): Overloading did not support custom types names longer than 8 characters
323* [#5723](http://bugzilla.scilab.org/show_bug.cgi?id=5723): Cross-references were missing between axis_properties and axes_properties help pages 325* [#5723](http://bugzilla.scilab.org/show_bug.cgi?id=5723): Cross-references were missing between axis_properties and axes_properties help pages
diff --git a/scilab/modules/core/tests/nonreg_tests/bug_8086.dia.ref b/scilab/modules/core/tests/nonreg_tests/bug_8086.dia.ref
index abb2c5c..652ac11 100644
--- a/scilab/modules/core/tests/nonreg_tests/bug_8086.dia.ref
+++ b/scilab/modules/core/tests/nonreg_tests/bug_8086.dia.ref
@@ -76,7 +76,6 @@ macros_error_type_2 = ["base2dec"; ..
76"bitand"; .. 76"bitand"; ..
77"ind2sub"; .. 77"ind2sub"; ..
78"intersect"; .. 78"intersect"; ..
79"linspace"; ..
80"modulo"; .. 79"modulo"; ..
81"permute"; .. 80"permute"; ..
82"pmodulo"; .. 81"pmodulo"; ..
@@ -106,7 +105,7 @@ for i=1:size(macros_error_type_6, "*")
106 assert_checkerror (macros_error_type_6(i) + "()" , msg_error_ref_6 , [] , macros_error_type_6(i), 1); 105 assert_checkerror (macros_error_type_6(i) + "()" , msg_error_ref_6 , [] , macros_error_type_6(i), 1);
107end 106end
108// ============================================================================= 107// =============================================================================
109macros_error_type_5 = ["flipdim"]; 108macros_error_type_5 = ["flipdim"; "linspace"];
110msg_error_ref_5 = _("%s: Wrong number of input argument(s): %d to %d expected.\n"); 109msg_error_ref_5 = _("%s: Wrong number of input argument(s): %d to %d expected.\n");
111for i=1:size(macros_error_type_5, "*") 110for i=1:size(macros_error_type_5, "*")
112 assert_checkerror (macros_error_type_5(i) + "()" , msg_error_ref_5 , [] , macros_error_type_5(i) , 2, 3); 111 assert_checkerror (macros_error_type_5(i) + "()" , msg_error_ref_5 , [] , macros_error_type_5(i) , 2, 3);
diff --git a/scilab/modules/core/tests/nonreg_tests/bug_8086.tst b/scilab/modules/core/tests/nonreg_tests/bug_8086.tst
index abb2c5c..652ac11 100644
--- a/scilab/modules/core/tests/nonreg_tests/bug_8086.tst
+++ b/scilab/modules/core/tests/nonreg_tests/bug_8086.tst
@@ -76,7 +76,6 @@ macros_error_type_2 = ["base2dec"; ..
76"bitand"; .. 76"bitand"; ..
77"ind2sub"; .. 77"ind2sub"; ..
78"intersect"; .. 78"intersect"; ..
79"linspace"; ..
80"modulo"; .. 79"modulo"; ..
81"permute"; .. 80"permute"; ..
82"pmodulo"; .. 81"pmodulo"; ..
@@ -106,7 +105,7 @@ for i=1:size(macros_error_type_6, "*")
106 assert_checkerror (macros_error_type_6(i) + "()" , msg_error_ref_6 , [] , macros_error_type_6(i), 1); 105 assert_checkerror (macros_error_type_6(i) + "()" , msg_error_ref_6 , [] , macros_error_type_6(i), 1);
107end 106end
108// ============================================================================= 107// =============================================================================
109macros_error_type_5 = ["flipdim"]; 108macros_error_type_5 = ["flipdim"; "linspace"];
110msg_error_ref_5 = _("%s: Wrong number of input argument(s): %d to %d expected.\n"); 109msg_error_ref_5 = _("%s: Wrong number of input argument(s): %d to %d expected.\n");
111for i=1:size(macros_error_type_5, "*") 110for i=1:size(macros_error_type_5, "*")
112 assert_checkerror (macros_error_type_5(i) + "()" , msg_error_ref_5 , [] , macros_error_type_5(i) , 2, 3); 111 assert_checkerror (macros_error_type_5(i) + "()" , msg_error_ref_5 , [] , macros_error_type_5(i) , 2, 3);
diff --git a/scilab/modules/elementary_functions/help/en_US/elementarymatrices/linspace.xml b/scilab/modules/elementary_functions/help/en_US/elementarymatrices/linspace.xml
index 032026e..5a9ab0c 100644
--- a/scilab/modules/elementary_functions/help/en_US/elementarymatrices/linspace.xml
+++ b/scilab/modules/elementary_functions/help/en_US/elementarymatrices/linspace.xml
@@ -2,6 +2,7 @@
2<!-- 2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA 4 * Copyright (C) 2008 - INRIA
5 * Copyright (C) 2016 - Samuel GOUGEON
5 * 6 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises 7 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 * 8 *
@@ -13,34 +14,66 @@
13 * along with this program. 14 * along with this program.
14 * 15 *
15 --> 16 -->
16<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="linspace" xml:lang="en"> 17<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
18 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
19 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
20 xmlns:scilab="http://www.scilab.org" xml:id="linspace" xml:lang="en">
17 <refnamediv> 21 <refnamediv>
18 <refname>linspace</refname> 22 <refname>linspace</refname>
19 <refpurpose>linearly spaced vector</refpurpose> 23 <refpurpose>generates linearly spaced numbers between 2 reached bounds</refpurpose>
20 </refnamediv> 24 </refnamediv>
21 <refsynopsisdiv> 25 <refsynopsisdiv>
22 <title>Syntax</title> 26 <title>Syntax</title>
23 <synopsis>[v]=linspace(x1,x2 [,n])</synopsis> 27 <synopsis>
28 row = linspace(x1, x2)
29 row = linspace(x1, x2, n)
30 Matrix = linspace(Col1, Col2)
31 Matrix = linspace(Col1, Col2, n)
32 </synopsis>
24 </refsynopsisdiv> 33 </refsynopsisdiv>
25 <refsection> 34 <refsection>
26 <title>Arguments</title> 35 <title>Arguments</title>
27 <variablelist> 36 <variablelist>
28 <varlistentry> 37 <varlistentry>
29 <term>x1,x2</term> 38 <term>x1, x2</term>
30 <listitem> 39 <listitem>
31 <para>real or complex scalars or column vectors</para> 40 <para>
41 Real or complex scalars:
42 Bounds between which values must be generated.
43 </para>
44 </listitem>
45 </varlistentry>
46 <varlistentry>
47 <term>Col1, Col2</term>
48 <listitem>
49 <para>
50 Column vectors of same heights of real or complex numbers.
51 </para>
32 </listitem> 52 </listitem>
33 </varlistentry> 53 </varlistentry>
34 <varlistentry> 54 <varlistentry>
35 <term>n</term> 55 <term>n</term>
36 <listitem> 56 <listitem>
37 <para>integer: number of requested values. It must be greater or equal to 2 (default value = 100)</para> 57 <para>
58 integer number of requested values or columns.
59 Default value: 100
60 </para>
61 </listitem>
62 </varlistentry>
63 <varlistentry>
64 <term>row</term>
65 <listitem>
66 <para>
67 row vector of <literal>n</literal> numbers.
68 </para>
38 </listitem> 69 </listitem>
39 </varlistentry> 70 </varlistentry>
40 <varlistentry> 71 <varlistentry>
41 <term>v</term> 72 <term>Matrix</term>
42 <listitem> 73 <listitem>
43 <para>real or complex row vector</para> 74 <para>
75 Matrix with <literal>n</literal> columns of numbers.
76 </para>
44 </listitem> 77 </listitem>
45 </varlistentry> 78 </varlistentry>
46 </variablelist> 79 </variablelist>
@@ -48,30 +81,92 @@
48 <refsection> 81 <refsection>
49 <title>Description</title> 82 <title>Description</title>
50 <para> 83 <para>
51 Linearly spaced vector. <literal>linspace(x1, x2)</literal> 84 <literal>linspace(x1, x2)</literal>
52 generates a row vector of n (default value=100) linearly equally spaced 85 generates a row vector of <literal>n</literal> equally spaced
53 points between <literal>x1</literal> and <literal>x2</literal>. If 86 values ranging exactly from <literal>x1</literal> to <literal>x2</literal>.
54 <literal>x1</literal> or <literal>x2</literal> are complex then 87 </para>
55 <literal>linspace(x1,x2)</literal> returns a row vector of n complexes, 88 <note>
56 the real (resp. imaginary) parts of the n complexes are linearly equally 89 <para>
57 spaced between the real (resp. imaginary) parts of <literal>x1</literal> 90 The syntax <literal>y1:y2</literal> or <literal>y1:step:y2</literal>
58 and <literal>x2.</literal> 91 like <literal>1:0.1:%pi</literal> does the same but fixes the
92 starting bound <literal>y1</literal> and
93 <emphasis role="bold">the step</emphasis>. The <literal>y2</literal>
94 is used as stopping bound to not be overstepped. The last value
95 actually generated may not reach it.
96 <literal>y2</literal> is then not included in the result.
97 </para>
98 <para>
99 Instead of fixing the step to a given value, <literal>linspace</literal>
100 fixes the final bound <literal>x2</literal> to be exactly
101 <emphasis role="bold">reached</emphasis>, and computes the step
102 accordingly.
103 </para>
104 </note>
105 <para>
106 If <literal>x1</literal> or <literal>x2</literal> are complex numbers,
107 then <literal>linspace(x1,x2)</literal> interpolates separately the real and
108 the imaginary parts of <literal>x1</literal> and <literal>x2</literal>.
109 </para>
110 <para>
111 If some column vectors <literal>Col1</literal> and <literal>Col2</literal>
112 are provided, <literal>linspace</literal> works in a row-wise way:
113 the resulting <literal>Matrix</literal> has the same number of rows,
114 and <literal>n</literal> columns. We get
115 <literal>Matrix(i,:) = linspace(Col1(i), Col2(i), n)</literal>.
59 </para> 116 </para>
60 </refsection> 117 </refsection>
61 <refsection> 118 <refsection>
62 <title>Examples</title> 119 <title>Examples</title>
63 <programlisting role="example"><![CDATA[ 120 <programlisting role="example"><![CDATA[
64linspace(1,2,10) 121linspace(1, %pi, 0) // n = 0
65linspace([1:4]',[5:8]',10) 122linspace(1, 2, 10) // x2 > x1 : increasing values
66linspace(1+%i,2+2*%i,10) 123linspace(2, 1, 10) // x2 < x1 : decreasing values
124linspace(1+%i, 2-2*%i, 5) // with complex numbers
125linspace([1:4]', [5:8]', 10) // with input columns
67 ]]></programlisting> 126 ]]></programlisting>
127 <screen><![CDATA[--> linspace(1, %pi, 0) // n = 0
128 ans =
129 []
130
131--> linspace(1, 2, 10) // x2 > x1 : increasing values
132
133 ans =
134 1. 1.111 1.222 1.333 1.444 1.556 1.667 1.778 1.889 2.
135
136
137--> linspace(2, 1, 10) // x2 < x1 : decreasing values
138
139 ans =
140 2. 1.889 1.778 1.667 1.556 1.444 1.333 1.222 1.111 1.
141
142
143--> linspace(1+%i, 2-2*%i, 5) // with complex numbers
144
145 ans =
146 1. +i 1.25 +0.25i 1.5 -0.5i 1.75 -1.25i 2. -2.i
147
148
149--> linspace([1:4]', [5:8]', 10) // with input columns
150
151 ans =
152 1. 1.444 1.889 2.333 2.778 3.222 3.667 4.111 4.556 5.
153 2. 2.444 2.889 3.333 3.778 4.222 4.667 5.111 5.556 6.
154 3. 3.444 3.889 4.333 4.778 5.222 5.667 6.111 6.556 7.
155 4. 4.444 4.889 5.333 5.778 6.222 6.667 7.111 7.556 8.
156]]></screen>
68 </refsection> 157 </refsection>
69 <refsection role="see also"> 158 <refsection role="see also">
70 <title>See also</title> 159 <title>See also</title>
71 <simplelist type="inline"> 160 <simplelist type="inline">
72 <member> 161 <member>
162 <link linkend="colon">colon</link>
163 </member>
164 <member>
73 <link linkend="logspace">logspace</link> 165 <link linkend="logspace">logspace</link>
74 </member> 166 </member>
167 <member>
168 <link linkend="grand">grand</link>
169 </member>
75 </simplelist> 170 </simplelist>
76 </refsection> 171 </refsection>
77 <refsection> 172 <refsection>
@@ -81,13 +176,24 @@ linspace(1+%i,2+2*%i,10)
81 <revnumber>5.4.0</revnumber> 176 <revnumber>5.4.0</revnumber>
82 <revremark> 177 <revremark>
83 <itemizedlist> 178 <itemizedlist>
84 <listitem>The linspace function accepts column vectors as input argument for the two first input arguments. Thanks to Guillaume AZEMA for the implementation. 179 <listitem>Column vectors can now be provided.
85 </listitem> 180 </listitem>
86 <listitem>The third input argument (n) must be an integer value. 181 <listitem>The third input argument (n) must be an integer value.
87 </listitem> 182 </listitem>
88 </itemizedlist> 183 </itemizedlist>
89 </revremark> 184 </revremark>
90 </revision> 185 </revision>
186 <revision>
187 <revnumber>6.0</revnumber>
188 <revremark>
189 <itemizedlist>
190 <listitem>linspace(a, b, n&lt;=0) now returns [] instead of b.
191 </listitem>
192 <listitem>bounds are now checked against %inf or %nan values.
193 </listitem>
194 </itemizedlist>
195 </revremark>
196 </revision>
91 </revhistory> 197 </revhistory>
92 </refsection> 198 </refsection>
93</refentry> 199</refentry>
diff --git a/scilab/modules/elementary_functions/help/fr_FR/elementarymatrices/linspace.xml b/scilab/modules/elementary_functions/help/fr_FR/elementarymatrices/linspace.xml
index 17023b9..69ff411 100644
--- a/scilab/modules/elementary_functions/help/fr_FR/elementarymatrices/linspace.xml
+++ b/scilab/modules/elementary_functions/help/fr_FR/elementarymatrices/linspace.xml
@@ -1,32 +1,80 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<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="linspace" xml:lang="fr"> 2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA
5 * Copyright (C) 2016 - Samuel GOUGEON
6 *
7 * Copyright (C) 2012 - 2016 - Scilab Enterprises
8 *
9 * This file is hereby licensed under the terms of the GNU GPL v2.0,
10 * pursuant to article 5.3.4 of the CeCILL v.2.1.
11 * This file was originally licensed under the terms of the CeCILL v2.1,
12 * and continues to be available under such terms.
13 * For more information, see the COPYING file which you should have received
14 * along with this program.
15 *
16 -->
17<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
18 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
19 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
20 xmlns:scilab="http://www.scilab.org" xml:id="linspace" xml:lang="fr">
3 <refnamediv> 21 <refnamediv>
4 <refname>linspace</refname> 22 <refname>linspace</refname>
5 <refpurpose>vecteur de valeurs équidistantes</refpurpose> 23 <refpurpose>suite de nombres équidistants entre 2 bornes atteintes</refpurpose>
6 </refnamediv> 24 </refnamediv>
7 <refsynopsisdiv> 25 <refsynopsisdiv>
8 <title>Séquence d'appel</title> 26 <title>Syntaxe</title>
9 <synopsis>[v]=linspace(x1,x2 [,n])</synopsis> 27 <synopsis>
28 row = linspace(x1, x2)
29 row = linspace(x1, x2, n)
30 Matrix = linspace(Col1, Col2)
31 Matrix = linspace(Col1, Col2, n)
32 </synopsis>
10 </refsynopsisdiv> 33 </refsynopsisdiv>
11 <refsection> 34 <refsection>
12 <title>Paramètres</title> 35 <title>Arguments</title>
13 <variablelist> 36 <variablelist>
14 <varlistentry> 37 <varlistentry>
15 <term>x1,x2</term> 38 <term>x1, x2</term>
16 <listitem> 39 <listitem>
17 <para>scalaire réel ou complexe ou vecteur colonne</para> 40 <para>
41 Nombres réels ou complexes scalaires : bornes entre
42 lesquelles les valeurs doivent être générées.
43 </para>
44 </listitem>
45 </varlistentry>
46 <varlistentry>
47 <term>Col1, Col2</term>
48 <listitem>
49 <para>
50 Vecteurs colonne de nombres réels ou complexes de même
51 taille.
52 </para>
18 </listitem> 53 </listitem>
19 </varlistentry> 54 </varlistentry>
20 <varlistentry> 55 <varlistentry>
21 <term>n</term> 56 <term>n</term>
22 <listitem> 57 <listitem>
23 <para>entier (nombre de valeurs, 100 par défaut)</para> 58 <para>
59 Nombre entier. Il précise le nombre de valeurs ou de colonnes à générer entre les deux extrémités (extrémités comprises).
60 100 par défaut.
61 </para>
24 </listitem> 62 </listitem>
25 </varlistentry> 63 </varlistentry>
26 <varlistentry> 64 <varlistentry>
27 <term>v</term> 65 <term>row</term>
28 <listitem> 66 <listitem>
29 <para>vecteur ligne réel ou complexe</para> 67 <para>
68 Vecteur ligne de <literal>n</literal> nombres.
69 </para>
70 </listitem>
71 </varlistentry>
72 <varlistentry>
73 <term>Matrix</term>
74 <listitem>
75 <para>
76 Matrice à <literal>n</literal> colonnes de nombres.
77 </para>
30 </listitem> 78 </listitem>
31 </varlistentry> 79 </varlistentry>
32 </variablelist> 80 </variablelist>
@@ -34,28 +82,96 @@
34 <refsection> 82 <refsection>
35 <title>Description</title> 83 <title>Description</title>
36 <para> 84 <para>
37 <literal>linspace(x1, x2)</literal> renvoie un vecteur ligne de n 85 <literal>linspace(x1, x2)</literal>
38 valeurs régulièrement espacées entre <literal>x1</literal> et 86 génère un vecteur ligne de <literal>n</literal> valeurs allant
39 <literal>x2</literal>. Si <literal>x1</literal> ou <literal>x2</literal> 87 exactement de <literal>x1</literal> à <literal>x2</literal> à
40 sont complexes alors <literal>linspace(x1,x2)</literal> renvoie un vecteur 88 pas constant.
41 ligne de n valeurs complexes dont les partie réels (resp. imaginaires) 89 </para>
42 sont regulierement espacées entre les partie réels (resp. imaginaires) de 90 <note>
43 x1 et x2. 91 <para>
92 La syntaxe <literal>y1:y2</literal> ou <literal>y1:step:y2</literal>
93 comme <literal>1:0.1:%pi</literal> produit une suite similaire,
94 mais fixe la valeur de départ <literal>y1</literal> et
95 <emphasis role="bold">le pas/incrément</emphasis>.
96 <literal>y2</literal> sert de valeur d'arrêt à ne pas dépasser.
97 La dernière valeur générée peut elle être inférieure,
98 <literal>y2</literal> ne figurant alors pas parmi les valeurs
99 générées.
100 </para>
101 <para>
102 Au lieu de fixer le pas/incrément, <literal>linspace</literal>
103 fixe la seconde borne <literal>x2</literal> à exactement
104 <emphasis role="bold">atteindre</emphasis>, et calcule le pas
105 en conséquence.
106 </para>
107 </note>
108 <para>
109 Si <literal>x1</literal> ou <literal>x2</literal> sont des nombres
110 complexes, <literal>linspace(x1,x2)</literal> interpole alors
111 séparément la partie réelle de <literal>x1</literal> et <literal>x2</literal>,
112 et d'autre part leur partie imaginaire.
113 </para>
114 <para>
115 Si des vecteurs colonnes <literal>Col1</literal> et <literal>Col2</literal>
116 sont fournis, <literal>linspace</literal> est alors appliquée
117 ligne par ligne :
118 La <literal>Matrix</literal> résultante à le même nombre de lignes,
119 et <literal>n</literal> colonnes, avec
120 <literal>Matrix(i,:) = linspace(Col1(i), Col2(i), n)</literal>.
44 </para> 121 </para>
45 </refsection> 122 </refsection>
46 <refsection> 123 <refsection>
47 <title>Exemples</title> 124 <title>Exemples</title>
48 <programlisting role="example"><![CDATA[ 125 <programlisting role="example"><![CDATA[
49linspace(1,2,10) 126linspace(1, %pi, 0) // n = 0
50linspace(1+1*%i,2+2*%i,10) 127linspace(1, 2, 10) // x2 > x1 : suite croissante
128linspace(2, 1, 10) // x2 < x1 : suite décroissante
129linspace(1+%i, 2-2*%i, 5) // avec des nombres complexes
130linspace([1:4]', [5:8]', 10) // avec des colonnes de bornes
51 ]]></programlisting> 131 ]]></programlisting>
132 <screen><![CDATA[--> linspace(1, %pi, 0) // n = 0
133 ans =
134 []
135
136--> linspace(1, 2, 10) // x2 > x1 : suite croissante
137
138 ans =
139 1. 1.111 1.222 1.333 1.444 1.556 1.667 1.778 1.889 2.
140
141
142--> linspace(2, 1, 10) // x2 < x1 : suite décroissante
143
144 ans =
145 2. 1.889 1.778 1.667 1.556 1.444 1.333 1.222 1.111 1.
146
147
148--> linspace(1+%i, 2-2*%i, 5) // avec des nombres complexes
149
150 ans =
151 1. +i 1.25 +0.25i 1.5 -0.5i 1.75 -1.25i 2. -2.i
152
153
154--> linspace([1:4]', [5:8]', 10) // avec des colonnes de bornes
155
156 ans =
157 1. 1.444 1.889 2.333 2.778 3.222 3.667 4.111 4.556 5.
158 2. 2.444 2.889 3.333 3.778 4.222 4.667 5.111 5.556 6.
159 3. 3.444 3.889 4.333 4.778 5.222 5.667 6.111 6.556 7.
160 4. 4.444 4.889 5.333 5.778 6.222 6.667 7.111 7.556 8.
161]]></screen>
52 </refsection> 162 </refsection>
53 <refsection role="see also"> 163 <refsection role="see also">
54 <title>Voir aussi</title> 164 <title>Voir aussi</title>
55 <simplelist type="inline"> 165 <simplelist type="inline">
56 <member> 166 <member>
167 <link linkend="colon">colon</link>
168 </member>
169 <member>
57 <link linkend="logspace">logspace</link> 170 <link linkend="logspace">logspace</link>
58 </member> 171 </member>
172 <member>
173 <link linkend="grand">grand</link>
174 </member>
59 </simplelist> 175 </simplelist>
60 </refsection> 176 </refsection>
61 <refsection> 177 <refsection>
@@ -65,8 +181,21 @@ linspace(1+1*%i,2+2*%i,10)
65 <revnumber>5.4.0</revnumber> 181 <revnumber>5.4.0</revnumber>
66 <revremark> 182 <revremark>
67 <itemizedlist> 183 <itemizedlist>
68 <listitem>La fonction linspace accepte les vecteurs colonnes pour les deux premiers arguments d'entrée. Merci à Guillaume AZEMA pour l'implémentation.</listitem> 184 <listitem>Des vecteurs colonne de bornes peuvent être utilisées.
69 <listitem>Le troisième argument d'entrée (n) doit être une valeur entière. 185 </listitem>
186 <listitem>Le nombre de colonnes générées doit
187 être obligatoirement un entier.
188 </listitem>
189 </itemizedlist>
190 </revremark>
191 </revision>
192 <revision>
193 <revnumber>6.0</revnumber>
194 <revremark>
195 <itemizedlist>
196 <listitem>linspace(a, b, n&lt;=0) produit [] au lieu de b.
197 </listitem>
198 <listitem>Toute borne %inf ou %nan est détectée et rejetée.
70 </listitem> 199 </listitem>
71 </itemizedlist> 200 </itemizedlist>
72 </revremark> 201 </revremark>
diff --git a/scilab/modules/elementary_functions/help/ja_JP/elementarymatrices/linspace.xml b/scilab/modules/elementary_functions/help/ja_JP/elementarymatrices/linspace.xml
deleted file mode 100644
index d1795bc..0000000
--- a/scilab/modules/elementary_functions/help/ja_JP/elementarymatrices/linspace.xml
+++ /dev/null
@@ -1,95 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 *
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
14 *
15 -->
16<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="linspace" xml:lang="ja">
17 <refnamediv>
18 <refname>linspace</refname>
19 <refpurpose>線形に配置されたベクトル</refpurpose>
20 </refnamediv>
21 <refsynopsisdiv>
22 <title>呼び出し手順</title>
23 <synopsis>[v]=linspace(x1,x2 [,n])</synopsis>
24 </refsynopsisdiv>
25 <refsection>
26 <title>引数</title>
27 <variablelist>
28 <varlistentry>
29 <term>x1,x2</term>
30 <listitem>
31 <para>実数または複素数のスカラーまたは列ベクトル</para>
32 </listitem>
33 </varlistentry>
34 <varlistentry>
35 <term>n</term>
36 <listitem>
37 <para>整数: 要求された値の数. 2以上とする必要があります (デフォルト値= 100)</para>
38 </listitem>
39 </varlistentry>
40 <varlistentry>
41 <term>v</term>
42 <listitem>
43 <para>実数または複素数の行ベクトル</para>
44 </listitem>
45 </varlistentry>
46 </variablelist>
47 </refsection>
48 <refsection>
49 <title>説明</title>
50 <para>
51 線形に間隔をとったベクトル. <literal>linspace(x1, x2)</literal>
52 は<literal>x1</literal> と <literal>x2</literal>の間に線形に等間隔をとった
53 n(デフォルト値=100)要素の行ベクトルとなります.
54 <literal>x1</literal> または <literal>x2</literal> が複素数の場合,
55 <literal>linspace(x1,x2)</literal>はn個の複素数からなる行ベクトル
56 を返します.
57 n個の複素数の実部は,<literal>x1</literal>と<literal>x2.</literal>
58 の実部の間に線形に等間隔に配置されます.
59 </para>
60 </refsection>
61 <refsection>
62 <title>例</title>
63 <programlisting role="example"><![CDATA[
64linspace(1,2,10)
65linspace([1:4]',[5:8]',10)
66linspace(1+%i,2+2*%i,10)
67 ]]></programlisting>
68 </refsection>
69 <refsection role="see also">
70 <title>参照</title>
71 <simplelist type="inline">
72 <member>
73 <link linkend="logspace">logspace</link>
74 </member>
75 </simplelist>
76 </refsection>
77 <refsection>
78 <title>履歴</title>
79 <revhistory>
80 <revision>
81 <revnumber>5.4.0</revnumber>
82 <revremark>
83 <itemizedlist>
84 <listitem>
85 linspace関数は最初の2つの入力引数に列ベクトルを指定できるようになりました.
86 実装したGuillaume AZEMAに感謝します.
87 </listitem>
88 <listitem>3番目の引数は整数値とする必要があります.
89 </listitem>
90 </itemizedlist>
91 </revremark>
92 </revision>
93 </revhistory>
94 </refsection>
95</refentry>
diff --git a/scilab/modules/elementary_functions/help/pt_BR/elementarymatrices/linspace.xml b/scilab/modules/elementary_functions/help/pt_BR/elementarymatrices/linspace.xml
deleted file mode 100644
index 9e290c8..0000000
--- a/scilab/modules/elementary_functions/help/pt_BR/elementarymatrices/linspace.xml
+++ /dev/null
@@ -1,77 +0,0 @@
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 *
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
14 *
15 -->
16<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="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="linspace" xml:lang="pt">
17 <refnamediv>
18 <refname>linspace</refname>
19 <refpurpose>vetor linearmente espaado</refpurpose>
20 </refnamediv>
21 <refsynopsisdiv>
22 <title>Seqncia de Chamamento</title>
23 <synopsis>[v]=linspace(x1,x2 [,n])</synopsis>
24 </refsynopsisdiv>
25 <refsection>
26 <title>Parmetros</title>
27 <variablelist>
28 <varlistentry>
29 <term>x1,x2</term>
30 <listitem>
31 <para>escalares reais ou complexos </para>
32 </listitem>
33 </varlistentry>
34 <varlistentry>
35 <term>n</term>
36 <listitem>
37 <para>inteiro (nmero de valores). O valor padro 100 </para>
38 </listitem>
39 </varlistentry>
40 <varlistentry>
41 <term>v</term>
42 <listitem>
43 <para>vetor linha de reais ou complexos</para>
44 </listitem>
45 </varlistentry>
46 </variablelist>
47 </refsection>
48 <refsection>
49 <title>Descrio</title>
50 <para>
51 Vetor linearmente espaado. <literal>linspace(x1, x2)</literal> era
52 um vetor linha de n (valor padro = 100) pontos linearmente espaados de
53 modo igual entre <literal>x1</literal> e <literal>x2</literal>. Se
54 <literal>x1</literal> ou <literal>x2</literal> so complexos, ento
55 <literal>linspace(x1,x2)</literal> retorna um vetor-linha de n complexos
56 cujas partes reais (e respectivamente as imaginrias) dos n complexos so
57 linearmente espaadas de modo igual entre a partes reais (e
58 respectivamente as imaginrias) de <literal>x1</literal> e
59 <literal>x2</literal>
60 </para>
61 </refsection>
62 <refsection>
63 <title>Exemplos </title>
64 <programlisting role="example"><![CDATA[
65linspace(1,2,10)
66linspace(1+%i,2+2*%i,10)
67 ]]></programlisting>
68 </refsection>
69 <refsection role="see also">
70 <title>Ver Tambm</title>
71 <simplelist type="inline">
72 <member>
73 <link linkend="logspace">logspace</link>
74 </member>
75 </simplelist>
76 </refsection>
77</refentry>
diff --git a/scilab/modules/elementary_functions/help/ru_RU/elementarymatrices/linspace.xml b/scilab/modules/elementary_functions/help/ru_RU/elementarymatrices/linspace.xml
index eea1830..60c2df2 100644
--- a/scilab/modules/elementary_functions/help/ru_RU/elementarymatrices/linspace.xml
+++ b/scilab/modules/elementary_functions/help/ru_RU/elementarymatrices/linspace.xml
@@ -2,6 +2,7 @@
2<!-- 2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2008 - INRIA 4 * Copyright (C) 2008 - INRIA
5 * Copyright (C) 2016 - Samuel GOUGEON
5 * 6 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises 7 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 * 8 *
@@ -13,36 +14,66 @@
13 * along with this program. 14 * along with this program.
14 * 15 *
15 --> 16 -->
16<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="linspace" xml:lang="ru"> 17<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
18 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
19 xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
20 xmlns:scilab="http://www.scilab.org" xml:id="linspace" xml:lang="ru">
17 <refnamediv> 21 <refnamediv>
18 <refname>linspace</refname> 22 <refname>linspace</refname>
19 <refpurpose>вектор с равномерными интервалами между элементами</refpurpose> 23 <refpurpose>генерирует линейно распределённые числа между двумя достижимыми границами</refpurpose>
20 </refnamediv> 24 </refnamediv>
21 <refsynopsisdiv> 25 <refsynopsisdiv>
22 <title>Синтаксис</title> 26 <title>Синтаксис</title>
23 <synopsis>[v]=linspace(x1,x2 [,n])</synopsis> 27 <synopsis>
28 row = linspace(x1, x2)
29 row = linspace(x1, x2, n)
30 Matrix = linspace(Col1, Col2)
31 Matrix = linspace(Col1, Col2, n)
32 </synopsis>
24 </refsynopsisdiv> 33 </refsynopsisdiv>
25 <refsection> 34 <refsection>
26 <title>Аргументы</title> 35 <title>Аргументы</title>
27 <variablelist> 36 <variablelist>
28 <varlistentry> 37 <varlistentry>
29 <term>x1,x2</term> 38 <term>x1, x2</term>
30 <listitem> 39 <listitem>
31 <para>вещественные или комплексные скаляры или векторы-столбцы</para> 40 <para>
41 Вещественные или комплексные скаляры:
42 границы между которыми должны быть сгенерированы значения.
43 </para>
44 </listitem>
45 </varlistentry>
46 <varlistentry>
47 <term>Col1, Col2</term>
48 <listitem>
49 <para>
50 Вектор-столбцы одинаковой высоты, состоящие из вещественных или комплексных чисел.
51 </para>
32 </listitem> 52 </listitem>
33 </varlistentry> 53 </varlistentry>
34 <varlistentry> 54 <varlistentry>
35 <term>n</term> 55 <term>n</term>
36 <listitem> 56 <listitem>
37 <para> 57 <para>
38 целое число: количество запрашиваемых значений. Оно должно быть больше либо равно двум (по умолчанию оно равно 100) 58 целое количество запрошенных значений или столбцов.
59 Значение по умолчанию: 100.
60 </para>
61 </listitem>
62 </varlistentry>
63 <varlistentry>
64 <term>row</term>
65 <listitem>
66 <para>
67 вектор-строка из <varname>n</varname> чисел.
39 </para> 68 </para>
40 </listitem> 69 </listitem>
41 </varlistentry> 70 </varlistentry>
42 <varlistentry> 71 <varlistentry>
43 <term>v</term> 72 <term>Matrix</term>
44 <listitem> 73 <listitem>
45 <para>вещественный или комплексный вектор-строка</para> 74 <para>
75 Матрица, в которой <varname>n</varname> столбцов чисел.
76 </para>
46 </listitem> 77 </listitem>
47 </varlistentry> 78 </varlistentry>
48 </variablelist> 79 </variablelist>
@@ -50,23 +81,92 @@
50 <refsection> 81 <refsection>
51 <title>Описание</title> 82 <title>Описание</title>
52 <para> 83 <para>
53 Вектор с равномерными интервалами между элементами. <literal>linspace(x1, x2)</literal> формирует вектор-строку из <literal>n</literal> (по умолчанию <literal>n=100</literal>) равномерно распределённых точек между <literal>x1</literal> и <literal>x2</literal>. Если <literal>x1</literal> или <literal>x2</literal> комплексные, то <literal>linspace(x1,x2)</literal> возвращает вектор-строку из <literal>n</literal> комплексных значений. Реальная часть (и, соответственно, мнимая часть) этих <literal>n</literal> комплексных значений равномерно распределена между реальными частями (и, соответственно, мнимыми частями) <literal>x1</literal> и <literal>x2</literal>. 84 <code>linspace(x1, x2)</code> генерирует вектор-строку из
85 <varname>n</varname> равномерно распределённых значений в диапазоне
86 точно от <varname>x1</varname> до <varname>x2</varname>.
87 </para>
88 <note>
89 <para>
90 Синтаксис <code>y1:y2</code> или <code>y1:step:y2</code>
91 наподобие <code>1:0.1:%pi</code> делает то же самое, но фиксирует
92 начальную границу <varname>y1</varname> и
93 <emphasis role="bold">шаг</emphasis> <varname>step</varname>.
94 Переменная <varname>y2</varname> используется в качестве границы
95 остановки, через которую нельзя переступить. Последнее значение,
96 которое фактически будет сгенерировано, может не достичь её. В
97 этом случае <varname>y2</varname> не включено в результат.
98 </para>
99 <para>
100 Вместо фиксированного шага указанным значением, функция
101 <function>linspace</function> фиксирует конечную границу
102 <varname>x2</varname>, которая точно <emphasis role="bold">будет достигнута</emphasis>
103 и вычисляет соответствующий шаг.
104 </para>
105 </note>
106 <para>
107 Если <varname>x1</varname> или <varname>x2</varname> являются комплексными
108 числами, то <code>linspace(x1,x2)</code> интерполирует отдельно вещественную
109 и мнимую части <varname>x1</varname> и <varname>x2</varname>.
110 </para>
111 <para>
112 Если указаны вектор-столбцы <varname>Col1</varname> и <varname>Col2</varname>,
113 то функция <function>linspace</function> работает по строкам: результирующая
114 матрица <varname>Matrix</varname> имеет то же количество строк и
115 <varname>n</varname> столбцов, которое мы получим <code>Matrix(i,:) = linspace(Col1(i), Col2(i), n)</code>.
54 </para> 116 </para>
55 </refsection> 117 </refsection>
56 <refsection> 118 <refsection>
57 <title>Примеры</title> 119 <title>Примеры</title>
58 <programlisting role="example"><![CDATA[ 120 <programlisting role="example"><![CDATA[
59linspace(1,2,10) 121linspace(1, %pi, 0) // n = 0
60linspace([1:4]',[5:8]',10) 122linspace(1, 2, 10) // x2 > x1 : значения увеличиваются
61linspace(1+%i,2+2*%i,10) 123linspace(2, 1, 10) // x2 < x1 : значения уменьшаются
124linspace(1+%i, 2-2*%i, 5) // с комплексными числами
125linspace([1:4]', [5:8]', 10) // со столбцами на входе
62 ]]></programlisting> 126 ]]></programlisting>
127 <screen><![CDATA[--> linspace(1, %pi, 0) // n = 0
128 ans =
129 []
130
131--> linspace(1, 2, 10) // x2 > x1 : значения увеличиваются
132
133 ans =
134 1. 1.111 1.222 1.333 1.444 1.556 1.667 1.778 1.889 2.
135
136
137--> linspace(2, 1, 10) // x2 < x1 : значения уменьшаются
138
139 ans =
140 2. 1.889 1.778 1.667 1.556 1.444 1.333 1.222 1.111 1.
141
142
143--> linspace(1+%i, 2-2*%i, 5) // с комплексными числами
144
145 ans =
146 1. +i 1.25 +0.25i 1.5 -0.5i 1.75 -1.25i 2. -2.i
147
148
149--> linspace([1:4]', [5:8]', 10) // со столбцами на входе
150
151 ans =
152 1. 1.444 1.889 2.333 2.778 3.222 3.667 4.111 4.556 5.
153 2. 2.444 2.889 3.333 3.778 4.222 4.667 5.111 5.556 6.
154 3. 3.444 3.889 4.333 4.778 5.222 5.667 6.111 6.556 7.
155 4. 4.444 4.889 5.333 5.778 6.222 6.667 7.111 7.556 8.
156]]></screen>
63 </refsection> 157 </refsection>
64 <refsection role="see also"> 158 <refsection role="see also">
65 <title>Смотрите также</title> 159 <title>Смотрите также</title>
66 <simplelist type="inline"> 160 <simplelist type="inline">
67 <member> 161 <member>
162 <link linkend="colon">colon</link>
163 </member>
164 <member>
68 <link linkend="logspace">logspace</link> 165 <link linkend="logspace">logspace</link>
69 </member> 166 </member>
167 <member>
168 <link linkend="grand">grand</link>
169 </member>
70 </simplelist> 170 </simplelist>
71 </refsection> 171 </refsection>
72 <refsection> 172 <refsection>
@@ -75,7 +175,23 @@ linspace(1+%i,2+2*%i,10)
75 <revision> 175 <revision>
76 <revnumber>5.4.0</revnumber> 176 <revnumber>5.4.0</revnumber>
77 <revremark> 177 <revremark>
78 Функция linspace принимает векторы-столбцы в качестве двух первых входных аргументов. Благодарим Guillaume AZEMA за эту реализацию. 178 <itemizedlist>
179 <listitem>Могут быть указаны вектор-столбцы.
180 </listitem>
181 <listitem>Третьим входным аргументом (n) должно быть целое значение.
182 </listitem>
183 </itemizedlist>
184 </revremark>
185 </revision>
186 <revision>
187 <revnumber>6.0</revnumber>
188 <revremark>
189 <itemizedlist>
190 <listitem>linspace(a, b, n&lt;=0) теперь возвращает [] вместо b.
191 </listitem>
192 <listitem>Границы теперь проверяются на значения %inf или %nan.
193 </listitem>
194 </itemizedlist>
79 </revremark> 195 </revremark>
80 </revision> 196 </revision>
81 </revhistory> 197 </revhistory>
diff --git a/scilab/modules/elementary_functions/macros/linspace.sci b/scilab/modules/elementary_functions/macros/linspace.sci
index 1ecc64b..d0d4915 100644
--- a/scilab/modules/elementary_functions/macros/linspace.sci
+++ b/scilab/modules/elementary_functions/macros/linspace.sci
@@ -1,6 +1,8 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) INRIA 2// Copyright (C) INRIA
3// Copyright (C) DIGITEO - 2011 - Allan CORNET 3// Copyright (C) DIGITEO - 2011 - Allan CORNET
4// Copyright (C) CNES - 2011 - Guillaume AZEMA
5// Copyright (C) 2016 - Samuel GOUGEON
4// 6//
5// Copyright (C) 2012 - 2016 - Scilab Enterprises 7// Copyright (C) 2012 - 2016 - Scilab Enterprises
6// 8//
@@ -17,38 +19,56 @@ function y = linspace(d1, d2, n)
17 // equally spaced points between x1 and x2. 19 // equally spaced points between x1 and x2.
18 // linspace(x1, x2, n) generates n points between x1 and x2. 20 // linspace(x1, x2, n) generates n points between x1 and x2.
19 21
22 // CHECKING ARGUMENTS
23 // ------------------
20 rhs = argn(2); 24 rhs = argn(2);
21 if rhs < 2 then 25 if rhs < 2 then
22 error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"linspace", 2)); 26 msg = gettext("%s: Wrong number of input argument(s): %d to %d expected.\n")
27 error(msprintf(msg, "linspace", 2, 3));
23 end 28 end
24 if size(d1,2)<>1 then 29 if size(d1,2)<>1 then
25 error(msprintf(gettext("%s: Wrong size for input argument #%d: A column vector expected.\n"),"linspace",1)); 30 msg = gettext("%s: Argument #%d: Column expected.\n")
31 error(msprintf(msg, "linspace", 1));
26 end 32 end
27 if ~and(size(d1) == size(d2)) then 33 if ~and(size(d1) == size(d2)) then
28 error(msprintf(gettext("%s: Incompatible input arguments #%d and #%d: Same sizes expected.\n"),"linspace",1,2)); 34 msg = gettext("%s: Arguments #%d and #%d: Same sizes expected.\n")
35 error(msprintf(msg, "linspace", 1, 2));
36 end
37 msg = gettext("%s: Argument #%d: Number(s) expected.\n")
38 if ~or(type(d1)==[1 5 8]) then
39 error(msprintf(msg, "linspace", 1));
40 end
41 if ~or(type(d2)==[1 5 8]) then
42 error(msprintf(msg, "linspace", 2));
43 end
44 msg = gettext("%s: Argument #%d: %%nan and %%inf values are forbidden.\n")
45 if or(isinf(d1)) | or(isnan(d1)) then
46 error(msprintf(msg, "linspace", 1));
47 end
48 if or(isinf(d2)) | or(isnan(d2)) then
49 error(msprintf(msg, "linspace", 2));
29 end 50 end
30
31 51
32 if rhs == 2 then 52 if rhs == 2 then
33 n = 100; 53 n = 100;
34 else 54 else
35 if and(type(n)<>[1 8]) | size(n,"*")<>1 then 55 if and(type(n)<>[1 8]) | size(n,"*")<>1 | int(n)<>n then
36 error(msprintf(gettext("%s: Wrong type for input argument #%d: An integer value expected.\n"),"linspace",3)); 56 msg = gettext("%s: Argument #%d: An integer value expected.\n")
37 end 57 error(msprintf(msg, "linspace",3));
38
39 if type(n) == 1 & int(n) <> n then
40 error(msprintf(gettext("%s: Wrong value for input argument #%d: An integer value expected.\n"),"linspace",3));
41 elseif type(n) == 8 then
42 n = double(n); // Convert for the operations to come
43 end 58 end
59 n = double(n); // Convert for the operations to come
44 end 60 end
45 61
46 if (n - 1) <= 0 then 62 // PROCESSING
47 y = d2; 63 // ----------
48 else 64 if n>1
49 y = ((d2-d1) * (0:n-1)) / (n-1) + d1 * ones(1,n); 65 y = ((d2-d1) * (0:n-1)) / (n-1) + d1 * ones(1,n);
50 66 // Forces the last value to be exactly the given d2:
51 // forces the last value to be in the interval 67 // http://bugzilla.scilab.org/10966
52 y(:,$) = d2; 68 y(:,$) = d2;
69 elseif n==1
70 y = d2
71 else
72 y = []
53 end 73 end
54endfunction 74endfunction
diff --git a/scilab/modules/elementary_functions/macros/logspace.sci b/scilab/modules/elementary_functions/macros/logspace.sci
index 1f41594..6659c5a 100644
--- a/scilab/modules/elementary_functions/macros/logspace.sci
+++ b/scilab/modules/elementary_functions/macros/logspace.sci
@@ -36,11 +36,19 @@ function y=logspace(d1, d2, n)
36 error(msprintf(gettext("%s: Wrong type for input argument #%d: An integer value expected.\n"),"logspace",3)); 36 error(msprintf(gettext("%s: Wrong type for input argument #%d: An integer value expected.\n"),"logspace",3));
37 end 37 end
38 if int(n) <> n then 38 if int(n) <> n then
39 warning(msprintf("%s: Using a non integer value for input argument #%d is deprecated and will produce an error in version 5.4.1.\n","logspace",3)); 39 msg = gettext("%s: Argument #%d: An integer value expected.\n")
40 error(msprintf(msg, "logspace",3))
40 end 41 end
41 end 42 end
43
42 if d2==%pi then 44 if d2==%pi then
43 d2 = log10(%pi); 45 d2 = log10(%pi);
44 end 46 end
45 y=10 .^( d1*ones(1,n) + [(d2-d1)*(0:n-2)/(floor(n)-1),d2-d1]); 47 if n>1
48 y = 10 .^( d1*ones(1,n) + [(d2-d1)*(0:n-2)/(floor(n)-1),d2-d1]);
49 elseif n==1
50 y = 10.^d2
51 else
52 y = []
53 end
46endfunction 54endfunction
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12913.dia.ref b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12913.dia.ref
index 358afc6..3ef7f45 100644
--- a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12913.dia.ref
+++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12913.dia.ref
@@ -17,5 +17,5 @@
17y = linspace(0, 5.5, uint32(5.2)); 17y = linspace(0, 5.5, uint32(5.2));
18refY = [0 1.375 2.75 4.125 5.5]; 18refY = [0 1.375 2.75 4.125 5.5];
19assert_checkequal(y, refY); 19assert_checkequal(y, refY);
20refMsg = msprintf(_("%s: Wrong value for input argument #%d: An integer value expected.\n"), "linspace", 3); 20refMsg = msprintf(_("%s: Argument #%d: An integer value expected.\n"), "linspace", 3);
21assert_checkerror("linspace(0, 5.5, 5.2);", refMsg); 21assert_checkerror("linspace(0, 5.5, 5.2);", refMsg);
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12913.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12913.tst
index a65d749..688878c 100644
--- a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12913.tst
+++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_12913.tst
@@ -19,5 +19,5 @@ y = linspace(0, 5.5, uint32(5.2));
19refY = [0 1.375 2.75 4.125 5.5]; 19refY = [0 1.375 2.75 4.125 5.5];
20assert_checkequal(y, refY); 20assert_checkequal(y, refY);
21 21
22refMsg = msprintf(_("%s: Wrong value for input argument #%d: An integer value expected.\n"), "linspace", 3); 22refMsg = msprintf(_("%s: Argument #%d: An integer value expected.\n"), "linspace", 3);
23assert_checkerror("linspace(0, 5.5, 5.2);", refMsg); 23assert_checkerror("linspace(0, 5.5, 5.2);", refMsg);
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_592.dia.ref b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_592.dia.ref
new file mode 100644
index 0000000..4bdf50e
--- /dev/null
+++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_592.dia.ref
@@ -0,0 +1,21 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Samuel GOUGEON
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- CLI SHELL MODE -->
8// <-- Non-regression test for bug #592 -->
9//
10// <-- Bugzilla URL -->
11// http://bugzilla.scilab.org/592
12//
13// <-- Short Description -->
14// linspace(a, b, n<=0) returned b instead of []. Same problem with logspage
15// function.
16assert_checkequal(linspace(1, 2, 0), []);
17assert_checkequal(linspace(1, 2, -3), []);
18assert_checkequal(linspace([1:3]', [4:6]', 0), []);
19assert_checkequal(logspace(1, 2, 0), []);
20assert_checkequal(logspace(1, 2, -3), []);
21assert_checkequal(logspace([1:3]', [4:6]', 0), []);
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_592.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_592.tst
new file mode 100644
index 0000000..b14637a
--- /dev/null
+++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_592.tst
@@ -0,0 +1,25 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Samuel GOUGEON
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7
8// <-- CLI SHELL MODE -->
9
10// <-- Non-regression test for bug #592 -->
11//
12// <-- Bugzilla URL -->
13// http://bugzilla.scilab.org/592
14//
15// <-- Short Description -->
16// linspace(a, b, n<=0) returned b instead of []. Same problem with logspage
17// function.
18
19assert_checkequal(linspace(1, 2, 0), []);
20assert_checkequal(linspace(1, 2, -3), []);
21assert_checkequal(linspace([1:3]', [4:6]', 0), []);
22
23assert_checkequal(logspace(1, 2, 0), []);
24assert_checkequal(logspace(1, 2, -3), []);
25assert_checkequal(logspace([1:3]', [4:6]', 0), []);
diff --git a/scilab/modules/elementary_functions/tests/unit_tests/linspace.dia.ref b/scilab/modules/elementary_functions/tests/unit_tests/linspace.dia.ref
index 6ba4306..bcbd57c1 100644
--- a/scilab/modules/elementary_functions/tests/unit_tests/linspace.dia.ref
+++ b/scilab/modules/elementary_functions/tests/unit_tests/linspace.dia.ref
@@ -2,25 +2,39 @@
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2008 - INRIA - Michael Baudin 3// Copyright (C) 2008 - INRIA - Michael Baudin
4// Copyright (C) 2012 - Scilab Enterprises - Sylvestre Ledru 4// Copyright (C) 2012 - Scilab Enterprises - Sylvestre Ledru
5// Copyright (C) 2016 - Samuel GOUGEON
5// 6//
6// This file is distributed under the same license as the Scilab package. 7// This file is distributed under the same license as the Scilab package.
7// ============================================================================= 8// =============================================================================
9
8// <-- CLI SHELL MODE --> 10// <-- CLI SHELL MODE -->
11
9// Basic use 12// Basic use
10computed=linspace(0,1,11); 13assert_checkequal(linspace(1,2,-1),[]);
11expected=[0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.]; 14assert_checkequal(linspace(1,2,0),[]);
15assert_checkequal(linspace(1,2,1),2);
16assert_checkequal(linspace(1,2,2),[1,2]);
17assert_checkequal(linspace(0,100,101),0:100);
18computed = linspace(0,1,11);
19expected = [0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.];
12assert_checkalmostequal(computed,expected); 20assert_checkalmostequal(computed,expected);
21
13// Basic use with 12 and 14 which also test scaling 22// Basic use with 12 and 14 which also test scaling
14computed=linspace(12,14,11); 23computed = linspace(12,14,11);
15expected=[12. 12.2 12.4 12.6 12.8 13. 13.2 13.4 13.6 13.8 14.]; 24expected = [12. 12.2 12.4 12.6 12.8 13. 13.2 13.4 13.6 13.8 14.];
16assert_checkalmostequal(computed,expected); 25assert_checkalmostequal(computed,expected);
17// Vector input 26
27// Column inputs
18assert_checkequal(size(linspace([0;2],[2;5],5)),[2,5]); 28assert_checkequal(size(linspace([0;2],[2;5],5)),[2,5]);
19assert_checkequal(size(linspace([0;2],[2;5],2)),[2,2]); 29assert_checkequal(size(linspace([0;2],[2;5],2)),[2,2]);
20assert_checkequal(linspace([0;2],[2;5],2),[0,2;2,5]); 30assert_checkequal(linspace([0;2],[2;5],2),[0,2;2,5]);
21assert_checkalmostequal(linspace([-1;2],[2;6],6), [-1,-0.4,0.2,0.8,1.4,2; 2,2.8,3.6,4.4,5.2,6]); 31assert_checkalmostequal(linspace([-1;2],[2;6],6), [-1,-0.4,0.2,0.8,1.4,2; 2,2.8,3.6,4.4,5.2,6]);
32
33// With complex bounds
34assert_checkequal(linspace(0,3-3*%i,4), (0:3)*(1-%i));
35assert_checkequal(linspace(3-3*%i,0,7), (3:-0.5:0)*(1-%i));
36expected = complex([1;1]*(1:-0.25:0), [0:0.5:2 ; 2:0.5:4]);
37assert_checkequal(linspace(1+%i*[0;2],[2;4]*%i,5),expected);
38
22// Perform a check on the size of the input arguments 39// Perform a check on the size of the input arguments
23assert_checktrue(execstr('linspace(2,[2,2])','errcatch')<>0); 40assert_checktrue(execstr('linspace(2,[2,2])','errcatch')<>0);
24assert_checkequal(linspace(1,2,0),2);
25assert_checkequal(linspace(1,2,1),2);
26assert_checkequal(linspace(1,2,2),[1,2]);
diff --git a/scilab/modules/elementary_functions/tests/unit_tests/linspace.tst b/scilab/modules/elementary_functions/tests/unit_tests/linspace.tst
index 182c746..bcbd57c1 100644
--- a/scilab/modules/elementary_functions/tests/unit_tests/linspace.tst
+++ b/scilab/modules/elementary_functions/tests/unit_tests/linspace.tst
@@ -2,6 +2,7 @@
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2008 - INRIA - Michael Baudin 3// Copyright (C) 2008 - INRIA - Michael Baudin
4// Copyright (C) 2012 - Scilab Enterprises - Sylvestre Ledru 4// Copyright (C) 2012 - Scilab Enterprises - Sylvestre Ledru
5// Copyright (C) 2016 - Samuel GOUGEON
5// 6//
6// This file is distributed under the same license as the Scilab package. 7// This file is distributed under the same license as the Scilab package.
7// ============================================================================= 8// =============================================================================
@@ -9,27 +10,31 @@
9// <-- CLI SHELL MODE --> 10// <-- CLI SHELL MODE -->
10 11
11// Basic use 12// Basic use
12computed=linspace(0,1,11); 13assert_checkequal(linspace(1,2,-1),[]);
13expected=[0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.]; 14assert_checkequal(linspace(1,2,0),[]);
15assert_checkequal(linspace(1,2,1),2);
16assert_checkequal(linspace(1,2,2),[1,2]);
17assert_checkequal(linspace(0,100,101),0:100);
18computed = linspace(0,1,11);
19expected = [0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.];
14assert_checkalmostequal(computed,expected); 20assert_checkalmostequal(computed,expected);
21
15// Basic use with 12 and 14 which also test scaling 22// Basic use with 12 and 14 which also test scaling
16computed=linspace(12,14,11); 23computed = linspace(12,14,11);
17expected=[12. 12.2 12.4 12.6 12.8 13. 13.2 13.4 13.6 13.8 14.]; 24expected = [12. 12.2 12.4 12.6 12.8 13. 13.2 13.4 13.6 13.8 14.];
18assert_checkalmostequal(computed,expected); 25assert_checkalmostequal(computed,expected);
19 26
20 27// Column inputs
21// Vector input
22assert_checkequal(size(linspace([0;2],[2;5],5)),[2,5]); 28assert_checkequal(size(linspace([0;2],[2;5],5)),[2,5]);
23assert_checkequal(size(linspace([0;2],[2;5],2)),[2,2]); 29assert_checkequal(size(linspace([0;2],[2;5],2)),[2,2]);
24assert_checkequal(linspace([0;2],[2;5],2),[0,2;2,5]); 30assert_checkequal(linspace([0;2],[2;5],2),[0,2;2,5]);
25assert_checkalmostequal(linspace([-1;2],[2;6],6), [-1,-0.4,0.2,0.8,1.4,2; 2,2.8,3.6,4.4,5.2,6]); 31assert_checkalmostequal(linspace([-1;2],[2;6],6), [-1,-0.4,0.2,0.8,1.4,2; 2,2.8,3.6,4.4,5.2,6]);
26 32
33// With complex bounds
34assert_checkequal(linspace(0,3-3*%i,4), (0:3)*(1-%i));
35assert_checkequal(linspace(3-3*%i,0,7), (3:-0.5:0)*(1-%i));
36expected = complex([1;1]*(1:-0.25:0), [0:0.5:2 ; 2:0.5:4]);
37assert_checkequal(linspace(1+%i*[0;2],[2;4]*%i,5),expected);
38
27// Perform a check on the size of the input arguments 39// Perform a check on the size of the input arguments
28assert_checktrue(execstr('linspace(2,[2,2])','errcatch')<>0); 40assert_checktrue(execstr('linspace(2,[2,2])','errcatch')<>0);
29
30
31assert_checkequal(linspace(1,2,0),2);
32assert_checkequal(linspace(1,2,1),2);
33assert_checkequal(linspace(1,2,2),[1,2]);
34
35
diff --git a/scilab/modules/elementary_functions/tests/unit_tests/logspace.dia.ref b/scilab/modules/elementary_functions/tests/unit_tests/logspace.dia.ref
index 6879349..bb878be 100644
--- a/scilab/modules/elementary_functions/tests/unit_tests/logspace.dia.ref
+++ b/scilab/modules/elementary_functions/tests/unit_tests/logspace.dia.ref
@@ -9,6 +9,8 @@
9computed=logspace(0,10,11); 9computed=logspace(0,10,11);
10expected=10.0.^(0:10) ; 10expected=10.0.^(0:10) ;
11assert_checkalmostequal(computed,expected); 11assert_checkalmostequal(computed,expected);
12assert_checkequal(logspace(1,2,-1),[]);
13assert_checkequal(logspace(1,2,0),[]);
12// Vector input 14// Vector input
13assert_checkequal(size(logspace([0;2],[2;5],5)),[2,5]); 15assert_checkequal(size(logspace([0;2],[2;5],5)),[2,5]);
14assert_checkequal(size(logspace([0;2],[2;5],2)),[2,2]); 16assert_checkequal(size(logspace([0;2],[2;5],2)),[2,2]);
diff --git a/scilab/modules/elementary_functions/tests/unit_tests/logspace.tst b/scilab/modules/elementary_functions/tests/unit_tests/logspace.tst
index f435f18..3b110e3 100644
--- a/scilab/modules/elementary_functions/tests/unit_tests/logspace.tst
+++ b/scilab/modules/elementary_functions/tests/unit_tests/logspace.tst
@@ -12,6 +12,9 @@ computed=logspace(0,10,11);
12expected=10.0.^(0:10) ; 12expected=10.0.^(0:10) ;
13assert_checkalmostequal(computed,expected); 13assert_checkalmostequal(computed,expected);
14 14
15assert_checkequal(logspace(1,2,-1),[]);
16assert_checkequal(logspace(1,2,0),[]);
17
15// Vector input 18// Vector input
16assert_checkequal(size(logspace([0;2],[2;5],5)),[2,5]); 19assert_checkequal(size(logspace([0;2],[2;5],5)),[2,5]);
17assert_checkequal(size(logspace([0;2],[2;5],2)),[2,2]); 20assert_checkequal(size(logspace([0;2],[2;5],2)),[2,2]);