summaryrefslogtreecommitdiffstats
path: root/scilab/modules
diff options
context:
space:
mode:
authorClément David <clement.david@esi-group.com>2021-04-06 11:14:28 +0200
committerCédric DELAMARRE <cedric.delamarre@esi-group.com>2021-04-26 14:26:00 +0200
commitab128135c7b6f67fb574205f36fc9c13a5d87b88 (patch)
tree9b1a1c4c6fe1a3cdfafe8c188583646f5986494d /scilab/modules
parent72e4c30a48aa2c4b2868b7ac5683210aa3c3359e (diff)
downloadscilab-ab128135c7b6f67fb574205f36fc9c13a5d87b88.zip
scilab-ab128135c7b6f67fb574205f36fc9c13a5d87b88.tar.gz
elementary_functions: fix rand() with a single key letter after 02f1f9cd
Change-Id: I7a57b563875025b366cc5c96df93706356b155a3
Diffstat (limited to 'scilab/modules')
-rw-r--r--scilab/modules/elementary_functions/help/en_US/elementarymatrices/random/rand.xml15
-rw-r--r--scilab/modules/elementary_functions/help/ru_RU/elementarymatrices/random/rand.xml12
-rw-r--r--scilab/modules/elementary_functions/sci_gateway/cpp/sci_rand.cpp14
3 files changed, 33 insertions, 8 deletions
diff --git a/scilab/modules/elementary_functions/help/en_US/elementarymatrices/random/rand.xml b/scilab/modules/elementary_functions/help/en_US/elementarymatrices/random/rand.xml
index 9834aad..25e0851 100644
--- a/scilab/modules/elementary_functions/help/en_US/elementarymatrices/random/rand.xml
+++ b/scilab/modules/elementary_functions/help/en_US/elementarymatrices/random/rand.xml
@@ -54,8 +54,15 @@
54 <listitem> 54 <listitem>
55 <para> 55 <para>
56 a string, the distribution of random numbers (default <literal>key="uniform" </literal>). 56 a string, the distribution of random numbers (default <literal>key="uniform" </literal>).
57 The available values are <literal>"uniform"</literal> and 57 The possible values are:
58 <literal>"normal"</literal>. 58 <itemizedlist>
59 <listitem>
60 <literal>"uniform"</literal> or <literal>"u"</literal>
61 </listitem>
62 <listitem>
63 <literal>"normal"</literal> or <literal>"n"</literal>
64 </listitem>
65 </itemizedlist>
59 </para> 66 </para>
60 </listitem> 67 </listitem>
61 </varlistentry> 68 </varlistentry>
@@ -144,7 +151,7 @@
144 </para> 151 </para>
145 <variablelist> 152 <variablelist>
146 <varlistentry> 153 <varlistentry>
147 <term>rand("uniform")</term> 154 <term>rand("uniform") or rand("u")</term>
148 <listitem> 155 <listitem>
149 <para> 156 <para>
150 sets the generator to a uniform random number 157 sets the generator to a uniform random number
@@ -154,7 +161,7 @@
154 </listitem> 161 </listitem>
155 </varlistentry> 162 </varlistentry>
156 <varlistentry> 163 <varlistentry>
157 <term>rand("normal")</term> 164 <term>rand("normal") or rand("n")</term>
158 <listitem> 165 <listitem>
159 <para> 166 <para>
160 sets the generator to a normal (Gauss-Laplace) random number generator, 167 sets the generator to a normal (Gauss-Laplace) random number generator,
diff --git a/scilab/modules/elementary_functions/help/ru_RU/elementarymatrices/random/rand.xml b/scilab/modules/elementary_functions/help/ru_RU/elementarymatrices/random/rand.xml
index 914d890..05f44bd 100644
--- a/scilab/modules/elementary_functions/help/ru_RU/elementarymatrices/random/rand.xml
+++ b/scilab/modules/elementary_functions/help/ru_RU/elementarymatrices/random/rand.xml
@@ -54,9 +54,15 @@
54 <listitem> 54 <listitem>
55 <para> 55 <para>
56 строка, распределение случайных чисел (по умолчанию 56 строка, распределение случайных чисел (по умолчанию
57 <literal>key="uniform"</literal>). Доступными значениями являются 57 <literal>key="uniform"</literal>). Доступными значениями являются:
58 <literal>"uniform"</literal> (равновероятный) и <literal>"normal"</literal> 58 <itemizedlist>
59 (нормальный). 59 <listitem>
60 <literal>"uniform"</literal> (равновероятный) или <literal>"u"</literal>
61 </listitem>
62 <listitem>
63 <literal>"normal"</literal> (нормальный) или <literal>"n"</literal>
64 </listitem>
65 </itemizedlist>
60 </para> 66 </para>
61 </listitem> 67 </listitem>
62 </varlistentry> 68 </varlistentry>
diff --git a/scilab/modules/elementary_functions/sci_gateway/cpp/sci_rand.cpp b/scilab/modules/elementary_functions/sci_gateway/cpp/sci_rand.cpp
index b4090ad..f554d1f 100644
--- a/scilab/modules/elementary_functions/sci_gateway/cpp/sci_rand.cpp
+++ b/scilab/modules/elementary_functions/sci_gateway/cpp/sci_rand.cpp
@@ -261,10 +261,22 @@ int setRandType(const wchar_t* _wcType)
261 { 261 {
262 return 0; 262 return 0;
263 } 263 }
264 else if (!wcscmp(_wcType,g_pwstTypeNormal)) 264 if (!wcscmp(_wcType,g_pwstTypeNormal))
265 { 265 {
266 return 1; 266 return 1;
267 } 267 }
268
269 // shortcut version
270 if (_wcType[0] == g_pwstTypeUniform[0] && _wcType[1] == L'\0')
271 {
272 return 0;
273 }
274 if (_wcType[0] == g_pwstTypeNormal[0] && _wcType[1] == L'\0')
275 {
276 return 1;
277 }
278
279 // invalid key
268 return -1; 280 return -1;
269} 281}
270/*--------------------------------------------------------------------------*/ 282/*--------------------------------------------------------------------------*/