summaryrefslogtreecommitdiffstats
path: root/scilab/modules/elementary_functions
diff options
context:
space:
mode:
authorAllan CORNET <allan.cornet@scilab.org>2010-02-08 13:58:53 +0100
committerAllan CORNET <allan.cornet@scilab.org>2010-02-08 13:58:53 +0100
commit9c342c45d5f90236473f5b41aa5ac2d72ac5da08 (patch)
tree592cf57caa5f95d6a68133781e9b420e129c237b /scilab/modules/elementary_functions
parente64c9bdacbdb83a1325a5b3216131de651b1d66e (diff)
downloadscilab-9c342c45d5f90236473f5b41aa5ac2d72ac5da08.zip
scilab-9c342c45d5f90236473f5b41aa5ac2d72ac5da08.tar.gz
remove obsolete function sort
Diffstat (limited to 'scilab/modules/elementary_functions')
-rw-r--r--scilab/modules/elementary_functions/Makefile.am2
-rw-r--r--scilab/modules/elementary_functions/help/en_US/sort.xml141
-rw-r--r--scilab/modules/elementary_functions/help/fr_FR/sort.xml128
-rw-r--r--scilab/modules/elementary_functions/help/pt_BR/sort.xml143
-rw-r--r--scilab/modules/elementary_functions/includes/elementary_functions.h1
-rw-r--r--scilab/modules/elementary_functions/includes/gw_elementary_functions.h1
-rw-r--r--scilab/modules/elementary_functions/macros/%_sort.sci31
-rw-r--r--scilab/modules/elementary_functions/sci_gateway/c/gw_elementary_functions.c3
-rw-r--r--scilab/modules/elementary_functions/sci_gateway/c/sci_sort.c68
-rw-r--r--scilab/modules/elementary_functions/sci_gateway/elementary_functions_gateway.xml1
-rw-r--r--scilab/modules/elementary_functions/sci_gateway/fortran/sci_f_sort.f310
-rw-r--r--scilab/modules/elementary_functions/src/c/elementary_functions.vcproj4
-rw-r--r--scilab/modules/elementary_functions/src/fortran/elementary_functions_f.vfproj6
-rw-r--r--scilab/modules/elementary_functions/src/fortran/elementary_functions_f2c.vcproj16
-rw-r--r--scilab/modules/elementary_functions/src/fortran/wsort.f190
-rw-r--r--scilab/modules/elementary_functions/tests/nonreg_tests/bug_3159.dia.ref2
-rw-r--r--scilab/modules/elementary_functions/tests/nonreg_tests/bug_3159.tst2
-rw-r--r--scilab/modules/elementary_functions/tests/nonreg_tests/bug_3567.dia.ref2
-rw-r--r--scilab/modules/elementary_functions/tests/nonreg_tests/bug_3567.tst2
-rw-r--r--scilab/modules/elementary_functions/tests/unit_tests/sort.dia.ref72
-rw-r--r--scilab/modules/elementary_functions/tests/unit_tests/sort.tst73
21 files changed, 7 insertions, 1191 deletions
diff --git a/scilab/modules/elementary_functions/Makefile.am b/scilab/modules/elementary_functions/Makefile.am
index bf61a55..fcb40f6 100644
--- a/scilab/modules/elementary_functions/Makefile.am
+++ b/scilab/modules/elementary_functions/Makefile.am
@@ -261,7 +261,6 @@ src/fortran/ortran.f \
261src/fortran/bdiag.f \ 261src/fortran/bdiag.f \
262src/fortran/wvmul.f \ 262src/fortran/wvmul.f \
263src/fortran/dmmul.f \ 263src/fortran/dmmul.f \
264src/fortran/wsort.f \
265src/fortran/wsqrt.f \ 264src/fortran/wsqrt.f \
266src/fortran/rat.f \ 265src/fortran/rat.f \
267src/fortran/ribesl.f \ 266src/fortran/ribesl.f \
@@ -318,7 +317,6 @@ sci_gateway/c/sci_imult.c \
318sci_gateway/c/sci_exp.c \ 317sci_gateway/c/sci_exp.c \
319sci_gateway/c/sci_maxi.c \ 318sci_gateway/c/sci_maxi.c \
320sci_gateway/c/sci_gsort.c \ 319sci_gateway/c/sci_gsort.c \
321sci_gateway/c/sci_sort.c \
322sci_gateway/c/sci_isequalbitwise.c 320sci_gateway/c/sci_isequalbitwise.c
323 321
324GATEWAY_FORTRAN_SOURCES = sci_gateway/fortran/sci_f_isequal.f \ 322GATEWAY_FORTRAN_SOURCES = sci_gateway/fortran/sci_f_isequal.f \
diff --git a/scilab/modules/elementary_functions/help/en_US/sort.xml b/scilab/modules/elementary_functions/help/en_US/sort.xml
deleted file mode 100644
index 25379a7..0000000
--- a/scilab/modules/elementary_functions/help/en_US/sort.xml
+++ /dev/null
@@ -1,141 +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 * This file must be used under the terms of the CeCILL.
7 * This source file is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at
10 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11 *
12 -->
13<refentry version="5.0-subset Scilab" xml:id="sort" xml:lang="en"
14 xmlns="http://docbook.org/ns/docbook"
15 xmlns:xlink="http://www.w3.org/1999/xlink"
16 xmlns:svg="http://www.w3.org/2000/svg"
17 xmlns:ns5="http://www.w3.org/1999/xhtml"
18 xmlns:mml="http://www.w3.org/1998/Math/MathML"
19 xmlns:db="http://docbook.org/ns/docbook">
20 <info>
21 <pubdate>$LastChangedDate: 2008-04-10 16:45:48 +0200 (jeu., 10 avr. 2008)
22 $</pubdate>
23 </info>
24
25 <refnamediv>
26 <refname>sort</refname>
27
28 <refpurpose>stable sorting by "quick sort" algorithm (DEPRECATED see gsort)</refpurpose>
29 </refnamediv>
30
31 <refsynopsisdiv>
32 <title>Calling Sequence</title>
33
34 <synopsis>
35 [s, [k]]=sort(v)
36 [s, [k]]=sort(v,'r')
37 [s, [k]]=sort(v,'c')</synopsis>
38 </refsynopsisdiv>
39
40 <refsection>
41 <title>Parameters</title>
42
43 <variablelist>
44 <varlistentry>
45 <term>v</term>
46
47 <listitem>
48 <para>real or complex vector/matrix; sparse vector; character string
49 vector/matrix</para>
50 </listitem>
51 </varlistentry>
52
53 <varlistentry>
54 <term>s</term>
55
56 <listitem>
57 <para>real or complex vector or matrix; sparse vector; character
58 string vector/matrix</para>
59 </listitem>
60 </varlistentry>
61
62 <varlistentry>
63 <term>k</term>
64
65 <listitem>
66 <para>vector or matrix of integers</para>
67 </listitem>
68 </varlistentry>
69 </variablelist>
70 </refsection>
71
72 <refsection>
73 <title>Description</title>
74
75 <para>the <literal>sort</literal> implements a "bubble sort algorithm".
76 </para>
77
78 <para> sort will be removed in Scilab 5.3. see gsort </para>
79
80 <para><literal>s=sort(v)</literal> sorts <literal>v</literal> in
81 decreasing order. If <literal>v</literal> is a matrix, sorting is done
82 columnwise, <literal>v</literal> being seen as the stacked vector
83 <literal>v(:)</literal>. If <literal>v</literal> is a string, sort is
84 increasing order. <literal>[s,k]=sort(v)</literal> gives in addition the
85 indices of entries of <literal>s</literal> in <literal>v</literal>, i.e.
86 <literal>v(k(:)) </literal> is the vector <literal>s</literal>.</para>
87
88 <para><literal>s=sort(v,'r')</literal> sorts the rows of
89 <literal>v</literal> in decreasing order i.e. each column of
90 <literal>s</literal> is obtained from each column of <literal>v</literal>
91 by reordering it in decreasing order. <literal>[s,k]=sort(v,'r')</literal>
92 returns in addition in each column of <literal>k</literal> the indices
93 such that <literal>v(k(:,i),i)=s(:,i)</literal> for each column index
94 <literal>i</literal>.</para>
95
96 <para><literal>s=sort(v,'c')</literal> sorts the columns of
97 <literal>v</literal> in decreasing order i.e. each row of
98 <literal>s</literal> is obtained from each row of <literal>v</literal> by
99 reordering it in decreasing order. <literal>[s,k]=sort(v,'c')</literal>
100 returns in addition in each row of <literal>k</literal> the indices such
101 that <literal>v(i,k(i,:))=s(i,:)</literal> for each row index
102 <literal>i</literal>.</para>
103
104 <para>Complex matrix or vectors are sorted by their magnitude. Column/row
105 sorting is not implemented for complex matrices.</para>
106
107 <para><literal>y=sort(A)</literal> is valid when <literal>A</literal> is a
108 sparse vector. Column/row sorting is not implemented for sparse
109 matrix.</para>
110
111 <para><emphasis role="bold">Remark</emphasis> : <literal>sort </literal>is
112 now obsolete it may be replaced by<emphasis role="bold"> <link
113 linkend="gsort">gsort</link> .</emphasis></para>
114 </refsection>
115
116 <refsection>
117 <title>Examples</title>
118
119 <programlisting role="example"><![CDATA[
120[s,p]=sort(rand(1,10));
121//p is a random permutation of 1:10
122A=[1,2,5;3,4,2];
123[Asorted,q]=sort(A);A(q(:))-Asorted(:)
124v=1:10;
125sort(v)
126sort(v')
127sort(v,'r') //Does nothing for row vectors
128sort(v,'c')
129 ]]></programlisting>
130 </refsection>
131
132 <refsection>
133 <title>See Also</title>
134
135 <simplelist type="inline">
136 <member><link linkend="find">find</link></member>
137
138 <member><link linkend="gsort">gsort</link></member>
139 </simplelist>
140 </refsection>
141</refentry>
diff --git a/scilab/modules/elementary_functions/help/fr_FR/sort.xml b/scilab/modules/elementary_functions/help/fr_FR/sort.xml
deleted file mode 100644
index 501aee6..0000000
--- a/scilab/modules/elementary_functions/help/fr_FR/sort.xml
+++ /dev/null
@@ -1,128 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<refentry version="5.0-subset Scilab" xml:id="sort" xml:lang="fr"
3 xmlns="http://docbook.org/ns/docbook"
4 xmlns:xlink="http://www.w3.org/1999/xlink"
5 xmlns:svg="http://www.w3.org/2000/svg"
6 xmlns:ns5="http://www.w3.org/1999/xhtml"
7 xmlns:mml="http://www.w3.org/1998/Math/MathML"
8 xmlns:db="http://docbook.org/ns/docbook">
9 <info>
10 <pubdate>$LastChangedDate: 2008-04-10 16:44:37 +0200 (jeu., 10 avr. 2008)
11 $</pubdate>
12 </info>
13
14 <refnamediv>
15 <refname>sort</refname>
16
17 <refpurpose>tri stable par l'agorithme "quick sort" (Déprécié voir gsort)</refpurpose>
18 </refnamediv>
19
20 <refsynopsisdiv>
21 <title>Séquence d'appel</title>
22
23 <synopsis>[s, [k]]=sort(v)
24[s, [k]]=sort(v,'r')
25[s, [k]]=sort(v,'c')</synopsis>
26 </refsynopsisdiv>
27
28 <refsection>
29 <title>Paramètres</title>
30
31 <variablelist>
32 <varlistentry>
33 <term>v,s</term>
34
35 <listitem>
36 <para>vecteur (plein ou creux) ou matrice de nombres réels ou de
37 chaînes de caractères.</para>
38 </listitem>
39 </varlistentry>
40
41 <varlistentry>
42 <term>k</term>
43
44 <listitem>
45 <para>vecteur ou matrice de nombres entiers.</para>
46 </listitem>
47 </varlistentry>
48 </variablelist>
49 </refsection>
50
51 <refsection>
52 <title>Description</title>
53
54 <para> sort sera replacé par gsort dans Scilab 5.3. </para>
55
56 <para>la fonction <literal>sort</literal> est désormais obsolete elle peut
57 être remplacée par la fonction <link linkend="gsort">gsort</link>.</para>
58
59 <para><literal>s=sort(v)</literal> trie <literal>v</literal> par ordre
60 décroissant. Si <literal>v</literal> est une matrice, cette instruction
61 produit un tri de la matrice <literal>v</literal> vue comme un vecteur
62 <literal>v(:)</literal> (les colonnes sont empilées).
63 <literal>[s,k]=sort(v)</literal> donne de plus les indices des termes de
64 <literal>s</literal> dans <literal>v</literal>, c'est à dire que
65 <literal>v(k(:)) </literal> est le vecteur <literal>s</literal>.</para>
66
67 <para><literal>s=sort(v,'r')</literal> effectue le tri par ordre
68 décroissant de <literal>v</literal> suivant l'indice de ligne : chaque
69 colonne de <literal>s</literal> est obtenue à partir de la colonne de
70 <literal>v</literal> correspondante triée par ordre décroissant.
71 <literal>[s,k]=sort(v,'r')</literal> renvoie de plus dans chaque colonne
72 de <literal>k</literal> les indices tels que
73 <literal>v(k(:,i),i)=s(:,i)</literal> pour chaque indice de colonne
74 <literal>i</literal>.</para>
75
76 <para><literal>s=sort(v,'c')</literal> effectue le tri par ordre
77 décroissant de <literal>v</literal> suivant l'indice de colonne : chaque
78 ligne de <literal>s</literal> est obtenue à partir de la ligne de
79 <literal>v</literal> correspondante triée par ordre décroissant.</para>
80
81 <para><literal>[s,k]=sort(v,'c')</literal> renvoie de plus dans chaque
82 ligne de <literal>k</literal> les indices tels que
83 <literal>v(i,k(i,:))=s(i,:)</literal> pour chaque indice de ligne
84 <literal>i</literal>.</para>
85
86 <para>Les matrices ou vecteurs complexes sont triés par rapport au module
87 complexe. le tri suivant les lignes ou les colonnes n'est pas implémenté
88 pour les matrices complexes.</para>
89
90 <para>Limitation : Si la matrice contient des %nan , la matrice ne sera
91 pas triée. Dans ce cas , utilisez <link
92 linkend="gsort">gsort</link>.</para>
93
94 <para><literal>y=sort(A)</literal> est valide quand <literal>A</literal>
95 est un vecteur creux. le tri suivant les lignes ou les colonnes n'est pas
96 implémenté pour les matrices creuses.</para>
97
98 <para><emphasis role="bold">Remarque: </emphasis>Cette fonction est
99 obsolete et peut être remplacée par <link
100 linkend="gsort">gsort</link>.</para>
101 </refsection>
102
103 <refsection>
104 <title>Exemples</title>
105
106 <programlisting role="example"><![CDATA[
107[s,p]=sort(rand(1,10));
108// p est une permutation aléatoire de 1:10
109A=[1,2,5;3,4,2];
110[A_trie,q]=sort(A);A(q(:))-A_trie(:)
111v=1:10;
112sort(v)
113sort(v')
114sort(v,'r') // ne fait rien pour les vecteurs lignes
115sort(v,'c')
116 ]]></programlisting>
117 </refsection>
118
119 <refsection>
120 <title>Voir Aussi</title>
121
122 <simplelist type="inline">
123 <member><link linkend="find">find</link></member>
124
125 <member><link linkend="gsort">gsort</link></member>
126 </simplelist>
127 </refsection>
128</refentry>
diff --git a/scilab/modules/elementary_functions/help/pt_BR/sort.xml b/scilab/modules/elementary_functions/help/pt_BR/sort.xml
deleted file mode 100644
index 2b48594..0000000
--- a/scilab/modules/elementary_functions/help/pt_BR/sort.xml
+++ /dev/null
@@ -1,143 +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 * This file must be used under the terms of the CeCILL.
7 * This source file is licensed as described in the file COPYING, which
8 * you should have received as part of this distribution. The terms
9 * are also available at
10 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11 *
12 -->
13<refentry version="5.0-subset Scilab" xml:id="sort" xml:lang="en"
14 xmlns="http://docbook.org/ns/docbook"
15 xmlns:xlink="http://www.w3.org/1999/xlink"
16 xmlns:svg="http://www.w3.org/2000/svg"
17 xmlns:ns5="http://www.w3.org/1999/xhtml"
18 xmlns:mml="http://www.w3.org/1998/Math/MathML"
19 xmlns:db="http://docbook.org/ns/docbook">
20 <info>
21 <pubdate>$LastChangedDate: 2008-04-10 16:45:48 +0200 (jeu., 10 avr. 2008)
22 $</pubdate>
23 </info>
24
25 <refnamediv>
26 <refname>sort</refname>
27
28 <refpurpose>ordenamento decrescente (DEPRECATED see gsort)</refpurpose>
29 </refnamediv>
30
31 <refsynopsisdiv>
32 <title>Seqüência de Chamamento</title>
33
34 <synopsis>
35 [s, [k]]=sort(v)
36 [s, [k]]=sort(v,'r')
37 [s, [k]]=sort(v,'c')
38</synopsis>
39 </refsynopsisdiv>
40
41 <refsection>
42 <title>Parâmetros</title>
43
44 <variablelist>
45 <varlistentry>
46 <term>v</term>
47
48 <listitem>
49 <para>vetor esparso; vetor ou matriz de reais, complexos ou
50 "strings" </para>
51 </listitem>
52 </varlistentry>
53
54 <varlistentry>
55 <term>s</term>
56
57 <listitem>
58 <para>vetor esparso; vetor ou matriz de reais, complexos ou
59 "strings" </para>
60 </listitem>
61 </varlistentry>
62
63 <varlistentry>
64 <term>k</term>
65
66 <listitem>
67 <para>vetor ou matriz de inteiros</para>
68 </listitem>
69 </varlistentry>
70 </variablelist>
71 </refsection>
72
73 <refsection>
74 <title>Descrição</title>
75
76 <para> sort will be removed in Scilab 5.3. see gsort </para>
77
78 <para>A função <literal>sort</literal> está obsoleta. Ela pode ser
79 substituída por <link linkend="gsort">gsort</link>.</para>
80
81 <para><literal>s=sort(v)</literal> põe <literal>v</literal> em ordem
82 decrescente. Se <literal>v</literal> é uma matriz, a ordenação é feita
83 coluna a coluna, <literal>v</literal> sendo visto como o vetor empilhado
84 <literal>v(:)</literal>. Se <literal>v</literal> é um string, a ordenação
85 é crescente. <literal>[s,k]=sort(v)</literal> retorna ainda os índices de
86 entradas de <literal>s</literal> em <literal>v</literal>, i.e.
87 <literal>v(k(:)) </literal> é o vetor <literal>s</literal>.</para>
88
89 <para><literal>s=sort(v,'r')</literal> põe as linhas de
90 <literal>v</literal> em ordem decrescente i.e. cada coluna de
91 <literal>s</literal> é obtida de cada coluna de <literal>v</literal> por
92 reordenação decrescente. <literal>[s,k]=sort(v,'r')</literal> retorna
93 ainda em cada coluna de <literal>k</literal> os índices tais que
94 <literal>v(k(:,i),i)=s(:,i)</literal> para cada índice de coluna
95 <literal>i</literal>.</para>
96
97 <para><literal>s=sort(v,'c')</literal> põe as colunas de
98 <literal>v</literal> em ordem decrescente i.e. cada linha de
99 <literal>s</literal> é obtida de cada linha de <literal>v</literal> por
100 reordenação decrescente. <literal>[s,k]=sort(v,'c')</literal> retorna
101 ainda em cada linha de <literal>k</literal> os índices tais que
102 <literal>v(i,k(i,:))=s(i,:)</literal> para cada índice de linha
103 <literal>i</literal>.</para>
104
105 <para>Matrizes ou vetores de complexos são ordenados de acordo com suas
106 magnitudes. Ordenação por colunas/linhas não é implementada para matrizes
107 complexas.</para>
108
109 <para><literal>y=sort(A)</literal> é válido quando <literal>A</literal> é
110 um vetor esparso. Ordenação de linhas/colunas não é implementado para
111 matrizes esparsas.</para>
112
113 <para>Limitação : se <literal>v</literal> inclui elementos %nan, a matriz
114 não será ordenada. Por favor, use <link linkend="gsort">gsort</link> neste
115 caso.</para>
116 </refsection>
117
118 <refsection>
119 <title>Exemplos</title>
120
121 <programlisting role="example"><![CDATA[
122[s,p]=sort(rand(1,10));
123//p é uma permutação aleatória de 1:10
124A=[1,2,5;3,4,2];
125[Asorted,q]=sort(A);A(q(:))-Asorted(:)
126v=1:10;
127sort(v)
128sort(v')
129sort(v,'r') //Não faz nada para vetores-linha
130sort(v,'c')
131 ]]></programlisting>
132 </refsection>
133
134 <refsection>
135 <title>Ver Também</title>
136
137 <simplelist type="inline">
138 <member><link linkend="find">find</link></member>
139
140 <member><link linkend="gsort">gsort</link></member>
141 </simplelist>
142 </refsection>
143</refentry>
diff --git a/scilab/modules/elementary_functions/includes/elementary_functions.h b/scilab/modules/elementary_functions/includes/elementary_functions.h
index 59fff0c..4e7f9da 100644
--- a/scilab/modules/elementary_functions/includes/elementary_functions.h
+++ b/scilab/modules/elementary_functions/includes/elementary_functions.h
@@ -19,7 +19,6 @@ typedef int(*I_fp)();
19 19
20int C2F(vfinite)(int *n, double *v); 20int C2F(vfinite)(int *n, double *v);
21 21
22extern int C2F(wsort)(double *countr, double *counti, int *n, int *index, I_fp test);
23 22
24extern int C2F(rcsort)(I_fp test, int *isz, int *iptr, int *iv, int *n, int *index); 23extern int C2F(rcsort)(I_fp test, int *isz, int *iptr, int *iv, int *n, int *index);
25 24
diff --git a/scilab/modules/elementary_functions/includes/gw_elementary_functions.h b/scilab/modules/elementary_functions/includes/gw_elementary_functions.h
index 9e796e3..0580e95 100644
--- a/scilab/modules/elementary_functions/includes/gw_elementary_functions.h
+++ b/scilab/modules/elementary_functions/includes/gw_elementary_functions.h
@@ -66,7 +66,6 @@ int C2F(sci_isequal)(char *fname,unsigned long fname_len);
66int C2F(sci_spones)(char *fname,unsigned long fname_len); 66int C2F(sci_spones)(char *fname,unsigned long fname_len);
67int C2F(sci_gsort)(char *fname, unsigned long fname_len); 67int C2F(sci_gsort)(char *fname, unsigned long fname_len);
68int C2F(sci_isequalbitwise)(char *fname, unsigned long fname_len); 68int C2F(sci_isequalbitwise)(char *fname, unsigned long fname_len);
69int C2F(sci_sort)(char *fname, unsigned long fname_len);
70#endif /* __GW_ELEMENTARIES_FUNCTIONS__ */ 69#endif /* __GW_ELEMENTARIES_FUNCTIONS__ */
71/*--------------------------------------------------------------------------*/ 70/*--------------------------------------------------------------------------*/
72 71
diff --git a/scilab/modules/elementary_functions/macros/%_sort.sci b/scilab/modules/elementary_functions/macros/%_sort.sci
deleted file mode 100644
index 0f1e40c..0000000
--- a/scilab/modules/elementary_functions/macros/%_sort.sci
+++ /dev/null
@@ -1,31 +0,0 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) DIGITEO - 2009 - Allan CORNET
3//
4// This file must be used under the terms of the CeCILL.
5// This source file is licensed as described in the file COPYING, which
6// you should have received as part of this distribution. The terms
7// are also available at
8// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9
10function [matrix_sorted, origin_indices] = %_sort(matrix_to_sort, sort_type)
11
12 if ~isdef('matrix_to_sort') then
13 matrix_to_sort = [];
14 return
15 end
16
17 if ~isdef('sort_type') then
18 sort_type = 'g';
19 end
20
21 if ~or(sort_type == ['g' 'r' 'c']) then
22 error(999,msprintf(_("%s: Wrong value for input argument #%d: [''g'' ''r'' ''c''] expected.\n"),'gsort',2));
23 end
24
25 // sort default direction is 'd'
26 sort_direction = 'd';
27
28 [matrix_sorted, origin_indices] = %_gsort(matrix_to_sort, sort_type, sort_direction);
29
30endfunction
31 \ No newline at end of file
diff --git a/scilab/modules/elementary_functions/sci_gateway/c/gw_elementary_functions.c b/scilab/modules/elementary_functions/sci_gateway/c/gw_elementary_functions.c
index 32c7b4b..4b07b5e 100644
--- a/scilab/modules/elementary_functions/sci_gateway/c/gw_elementary_functions.c
+++ b/scilab/modules/elementary_functions/sci_gateway/c/gw_elementary_functions.c
@@ -65,8 +65,7 @@ static gw_generic_table Tab[] =
65 {C2F(sci_isequal),"isequal"}, 65 {C2F(sci_isequal),"isequal"},
66 {C2F(sci_spones),"spones"}, 66 {C2F(sci_spones),"spones"},
67 {C2F(sci_gsort),"gsort"}, 67 {C2F(sci_gsort),"gsort"},
68 {C2F(sci_isequalbitwise),"isequalbitwise"}, 68 {C2F(sci_isequalbitwise),"isequalbitwise"}
69 {C2F(sci_sort),"sort"}
70}; 69};
71/*--------------------------------------------------------------------------*/ 70/*--------------------------------------------------------------------------*/
72int gw_elementary_functions(void) 71int gw_elementary_functions(void)
diff --git a/scilab/modules/elementary_functions/sci_gateway/c/sci_sort.c b/scilab/modules/elementary_functions/sci_gateway/c/sci_sort.c
deleted file mode 100644
index b3dbce2..0000000
--- a/scilab/modules/elementary_functions/sci_gateway/c/sci_sort.c
+++ /dev/null
@@ -1,68 +0,0 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2008 - DIGITEO - Allan CORNET
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 *
11 */
12/*-----------------------------------------------------------------------------------*/
13#include <string.h>
14#include "gw_elementary_functions.h"
15#include "stack-c.h"
16#include "warningmode.h"
17#include "sciprint.h"
18#include "localization.h"
19/*-----------------------------------------------------------------------------------*/
20extern int C2F(intsort) (int *id);
21extern int C2F(intssort) (int *id);
22/*-----------------------------------------------------------------------------------*/
23int C2F(sci_sort) (char *fname,unsigned long fname_len)
24{
25 /* TO DO : rewrite sort and merge with gsort */
26 /* compatibility with scilab 4.x */
27
28 static int id[6];
29
30 CheckRhs(1,2);
31 CheckLhs(1,2);
32
33 if (getWarningMode())
34 {
35 sciprint(_("WARNING: Function %s is obsolete.\n"), fname);
36 sciprint(_("WARNING: Please use %s instead.\n"), "gsort");
37 sciprint(_("WARNING: This function will be permanently removed in Scilab %s.\n"), "5.3");
38 }
39
40 if ( VarType(1) == sci_strings )
41 {
42 C2F(intssort)(id);
43 }
44 else
45 {
46 /* bug 3567 : previous version of scilab didn't sort correctly complex */
47 /* we use same algorithm than gsort with complex case */
48 #define COMPLEX 1
49 int *header = NULL;
50 int Cmplx = 0; /* real */
51 header = (int *) GetData(1);
52 Cmplx = header[3];
53
54 if (Cmplx == COMPLEX)
55 {
56 int lw = 0;
57 C2F(overload)(&lw, "sort", (unsigned long)strlen("sort"));
58 return 0;
59 }
60 else
61 {
62 C2F(intsort)(id);
63 }
64 }
65 return 0;
66}
67/*-----------------------------------------------------------------------------------*/
68
diff --git a/scilab/modules/elementary_functions/sci_gateway/elementary_functions_gateway.xml b/scilab/modules/elementary_functions/sci_gateway/elementary_functions_gateway.xml
index 43d52c5..045b310 100644
--- a/scilab/modules/elementary_functions/sci_gateway/elementary_functions_gateway.xml
+++ b/scilab/modules/elementary_functions/sci_gateway/elementary_functions_gateway.xml
@@ -85,5 +85,4 @@
85<PRIMITIVE gatewayId="6" primitiveId="49" primitiveName="spones" /> 85<PRIMITIVE gatewayId="6" primitiveId="49" primitiveName="spones" />
86<PRIMITIVE gatewayId="6" primitiveId="50" primitiveName="gsort" /> 86<PRIMITIVE gatewayId="6" primitiveId="50" primitiveName="gsort" />
87<PRIMITIVE gatewayId="6" primitiveId="51" primitiveName="isequalbitwise" /> 87<PRIMITIVE gatewayId="6" primitiveId="51" primitiveName="isequalbitwise" />
88<PRIMITIVE gatewayId="6" primitiveId="52" primitiveName="sort" />
89</GATEWAY> 88</GATEWAY>
diff --git a/scilab/modules/elementary_functions/sci_gateway/fortran/sci_f_sort.f b/scilab/modules/elementary_functions/sci_gateway/fortran/sci_f_sort.f
deleted file mode 100644
index f3c478c..0000000
--- a/scilab/modules/elementary_functions/sci_gateway/fortran/sci_f_sort.f
+++ /dev/null
@@ -1,310 +0,0 @@
1c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2c Copyright (C) INRIA
3c
4c This file must be used under the terms of the CeCILL.
5c This source file is licensed as described in the file COPYING, which
6c you should have received as part of this distribution. The terms
7c are also available at
8c http://www.cecill.info/licences/Licence_CeCILL_V2-en.txtc
9
10c =========================================
11 subroutine intsort(id)
12 INCLUDE 'stack.h'
13 integer id(nsiz)
14
15 integer tops,sel
16 integer iadr,sadr
17 integer modtest
18 external modtest
19c
20 iadr(l)=l+l-1
21 sadr(l)=(l/2)+1
22c
23 tops=top
24c
25 il=iadr(lstk(top+1-rhs))
26 if(istk(il).lt.0) il=iadr(istk(il+1))
27 if(istk(il).ne.1) then
28 call funnam(ids(1,pt+1),'sort',il)
29 fun=-1
30 return
31 endif
32
33c select type of sort to perform
34 sel=0
35 if(rhs.eq.2) then
36 call getorient(top,sel)
37 if(err.gt.0) return
38 top=top-1
39 endif
40
41 if(sel.eq.2) then
42c sort(a,'c') <=> sort(a,2) The lazy way...
43 top=tops
44 call funnam(ids(1,pt+1),'sort',il)
45 fun=-1
46 return
47 endif
48
49 il0=iadr(lstk(top))
50 if(istk(il0).lt.0) then
51c array is passed by reference copy it on the top of the stack
52 k=istk(il0+2)
53 err=lstk(top)+lstk(k+1)-lstk(k)-lstk(bot)
54 if(err.gt.0) then
55 call error(17)
56 return
57 endif
58 call unsfdcopy(lstk(k+1)-lstk(k),stk(lstk(k)),1
59 $ ,stk(lstk(top)),1)
60 lstk(top+1)=lstk(top)+lstk(k+1)-lstk(k)
61 endif
62
63 m=istk(il0+1)
64 n=istk(il0+2)
65 it=istk(il0+3)
66 mn=m*n
67c
68 if(mn.eq.0) then
69 if(lhs.eq.1) return
70 top=top+1
71 il=iadr(lstk(top))
72 istk(il)=1
73 istk(il+1)=0
74 istk(il+2)=0
75 istk(il+3)=0
76 lstk(top+1)=sadr(il+4)
77 return
78 endif
79c
80 lw=iadr(lstk(top+1))
81 err=sadr(lw+mn)-lstk(bot)
82 if(err.gt.0) then
83 call error(17)
84 return
85 endif
86c
87 if(sel.eq.0) then
88c sort(a) <=> sort(a,'*')
89 istk(il0)=1
90 istk(il0+1)=m
91 istk(il0+2)=n
92 istk(il0+3)=it
93 l1=sadr(il0+4)
94 if(it.eq.0) then
95 call dsort(stk(l1),mn,istk(lw))
96 else
97 call wsort(stk(l1),stk(l1+mn),mn,istk(lw),modtest)
98 endif
99 lstk(top+1)=l1+mn*(it+1)
100 if(lhs.eq.1) return
101 top=top+1
102 il=lw
103 l1=sadr(il+4)+mn
104 l2=lw+mn
105 err=l1-lstk(bot)
106 if(err.gt.0) then
107 call error(17)
108 return
109 endif
110 lstk(top+1)=l1
111 do 106 i=1,mn
112 stk(l1-i)=dble(istk(l2-i))
113 106 continue
114 istk(il)=1
115 istk(il+1)=m
116 istk(il+2)=n
117 istk(il+3)=0
118 elseif(sel.eq.1) then
119c sort(a,'r') <=> sort(a,1)
120 istk(il0)=1
121 istk(il0+1)=m
122 istk(il0+2)=n
123 istk(il0+3)=it
124 l1=sadr(il0+4)
125 lw1=lw
126 if(it.eq.0) then
127 do 107 k=0,n-1
128 call dsort(stk(l1+k*m),m,istk(lw1))
129 lw1=lw1+m
130 107 continue
131 else
132 do 108 k=0,n-1
133 call wsort(stk(l1+k*m),stk(l1+mn+k*m),mn,istk(lw1),
134 $ modtest)
135 lw1=lw1+m
136 108 continue
137 endif
138 lstk(top+1)=l1+mn*(it+1)
139c cccccccccccc
140 if(lhs.eq.1) return
141 top=top+1
142 il=lw
143 l1=sadr(il+4)+mn
144 l2=lw+mn
145 err=l1-lstk(bot)
146 if(err.gt.0) then
147 call error(17)
148 return
149 endif
150 lstk(top+1)=l1
151 do 109 i=1,mn
152 stk(l1-i)=dble(istk(l2-i))
153 109 continue
154 istk(il)=1
155 istk(il+1)=m
156 istk(il+2)=n
157 istk(il+3)=0
158 elseif(sel.eq.2) then
159c implemented by a call to a function see above
160 endif
161 return
162 end
163
164c =========================================
165
166 subroutine intssort(id)
167 INCLUDE 'stack.h'
168c
169 integer id(nsiz),tops,vol,sel
170 external strord
171 integer strord
172 integer iadr,sadr
173c
174 iadr(l)=l+l-1
175 sadr(l)=(l/2)+1
176
177 tops=top
178
179c select type of sort to perform
180 sel=0
181 if(rhs.eq.2) then
182 call getorient(top,sel)
183 if(err.gt.0) return
184 top=top-1
185 endif
186
187 if(rhs.eq.2) rhs=rhs-1
188 call ref2val
189c
190 il1=iadr(lstk(top))
191 ilr=il1
192
193 m=istk(il1+1)
194 n=istk(il1+2)
195 mn=m*n
196 id1=il1+4
197 l1=id1+mn+1
198 vol=istk(id1+mn)-1
199c
200 id1r=id1
201 ls=iadr(lstk(top+1))
202 lsz=ls+vol
203
204 lind=lsz+mn
205 lw=lind+mn
206 err=sadr(lw)-lstk(bot)
207 if(err.gt.0) then
208 call error(17)
209 return
210 endif
211
212 call icopy(vol,istk(l1),1,istk(ls),1)
213
214 do 91 i=0,mn-1
215 istk(lsz+i)=istk(id1+i+1)-istk(id1+i)
216 91 continue
217
218c
219 if(sel.eq.0) then
220c sort(a) <=> sort(a,'*')
221 call rcsort(strord,istk(lsz),istk(id1),istk(ls),mn,istk(lind))
222 elseif(sel.eq.1) then
223c sort(a,'r') <=> sort(a,1)
224 lszi=lsz
225 idi=id1
226 lindi=lind
227 do 95 i=0,n-1
228 call rcsort(strord,istk(lszi),istk(idi),istk(ls),m,
229 $ istk(lindi))
230 lszi=lszi+m
231 idi=idi+m
232 lindi=lindi+m
233 95 continue
234 endif
235
236 l2=ilr+4+mn+1
237 do 93 i=0,mn-1
238 call icopy(istk(lsz+i),istk(ls-1+istk(id1+i)),1,istk(l2),1)
239 l2=l2+istk(lsz+i)
240 93 continue
241 lstk(top+1)=sadr(l2)
242
243 istk(id1)=1
244 do 94 i=0,mn-1
245 istk(id1+i+1)=istk(id1+i)+istk(lsz+i)
246 94 continue
247 if(lhs.eq.1) goto 999
248 top=top+1
249 il=iadr(lstk(top))
250
251 l=sadr(il+4)
252 inc=-1
253 if(sadr(lind).gt.l) inc=1
254 call int2db(mn,istk(lind),inc,stk(l),inc)
255 istk(il)=1
256 istk(il+1)=m
257 istk(il+2)=n
258 istk(il+3)=0
259 lstk(top+1)=l+mn
260
261 go to 999
262 999 return
263 end
264c =========================================
265 integer function strord(r1,l1,r2,l2)
266 integer r1(*),r2(*),c1,c2
267 integer blank
268 data blank/40/
269c
270 iord=0
271 if(l1.eq.0) then
272 if(l2.gt.0) then
273 strord=-1
274 return
275 else
276 strord=0
277 return
278 endif
279 else
280 if(l2.eq.0) then
281 strord=1
282 return
283 endif
284 endif
285 ll=min(l1,l2)
286 do 10 i=1,max(l1,l2)
287 if(i.le.l1) then
288 c1=r1(i)
289 else
290 c1=blank
291 endif
292 if(i.le.l2) then
293 c2=r2(i)
294 else
295 c2=blank
296 endif
297 if(c1.ge.0) c1=256-c1
298 if(c2.ge.0) c2=256-c2
299 if(c1.gt.c2) then
300 strord=1
301 return
302 elseif(c1.lt.c2) then
303 strord=-1
304 return
305 endif
306 10 continue
307 strord=0
308 return
309 end
310c =========================================
diff --git a/scilab/modules/elementary_functions/src/c/elementary_functions.vcproj b/scilab/modules/elementary_functions/src/c/elementary_functions.vcproj
index 201b700..352b9e4 100644
--- a/scilab/modules/elementary_functions/src/c/elementary_functions.vcproj
+++ b/scilab/modules/elementary_functions/src/c/elementary_functions.vcproj
@@ -557,10 +557,6 @@
557 > 557 >
558 </File> 558 </File>
559 <File 559 <File
560 RelativePath="..\..\sci_gateway\c\sci_sort.c"
561 >
562 </File>
563 <File
564 RelativePath="..\..\sci_gateway\c\sci_spones.c" 560 RelativePath="..\..\sci_gateway\c\sci_spones.c"
565 > 561 >
566 </File> 562 </File>
diff --git a/scilab/modules/elementary_functions/src/fortran/elementary_functions_f.vfproj b/scilab/modules/elementary_functions/src/fortran/elementary_functions_f.vfproj
index 0ec96f7..5d20880 100644
--- a/scilab/modules/elementary_functions/src/fortran/elementary_functions_f.vfproj
+++ b/scilab/modules/elementary_functions/src/fortran/elementary_functions_f.vfproj
@@ -5,7 +5,7 @@
5 <Platform Name="x64"/></Platforms> 5 <Platform Name="x64"/></Platforms>
6 <Configurations> 6 <Configurations>
7 <Configuration Name="Debug|Win32" OutputDirectory="$(InputDir)$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.lib;$(TargetPath)" ConfigurationType="typeStaticLibrary"> 7 <Configuration Name="Debug|Win32" OutputDirectory="$(InputDir)$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.lib;$(TargetPath)" ConfigurationType="typeStaticLibrary">
8 <Tool Name="VFFortranCompilerTool" AdditionalOptions="" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" AdditionalIncludeDirectories="../../includes;../../../core/includes;" AlternateParameterSyntax="false" F77RuntimeCompatibility="true" FPS4Libs="false" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" RuntimeLibrary="rtMultiThreadedDebugDLL"/> 8 <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" AdditionalIncludeDirectories="../../includes;../../../core/includes;" AlternateParameterSyntax="false" F77RuntimeCompatibility="true" FPS4Libs="false" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" RuntimeLibrary="rtMultiThreadedDebugDLL"/>
9 <Tool Name="VFLibrarianTool" OutputFile="../../../../libs/elementary_functions_f.lib"/> 9 <Tool Name="VFLibrarianTool" OutputFile="../../../../libs/elementary_functions_f.lib"/>
10 <Tool Name="VFResourceCompilerTool"/> 10 <Tool Name="VFResourceCompilerTool"/>
11 <Tool Name="VFMidlTool" SuppressStartupBanner="true" TypeLibraryName="$(IntDir)/$(InputName).tlb"/> 11 <Tool Name="VFMidlTool" SuppressStartupBanner="true" TypeLibraryName="$(IntDir)/$(InputName).tlb"/>
@@ -20,7 +20,7 @@ del *.def &gt;nul
20cd .."/> 20cd .."/>
21 <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration> 21 <Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
22 <Configuration Name="Release|Win32" OutputDirectory="$(InputDir)$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.lib;$(TargetPath)" ConfigurationType="typeStaticLibrary"> 22 <Configuration Name="Release|Win32" OutputDirectory="$(InputDir)$(ConfigurationName)" DeleteExtensionsOnClean="*.obj;*.mod;*.pdb;*.asm;*.map;*.dyn;*.dpi;*.tmp;*.log;*.lib;$(TargetPath)" ConfigurationType="typeStaticLibrary">
23 <Tool Name="VFFortranCompilerTool" AdditionalOptions="" SuppressStartupBanner="true" AdditionalIncludeDirectories="../../includes;../../../core/includes;" PreprocessorDefinitions="WIN32" AlternateParameterSyntax="false" F77RuntimeCompatibility="true" FPS4Libs="false" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" RuntimeLibrary="rtMultiThreadedDLL" ImproveFloatingPointConsistency="true"/> 23 <Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" AdditionalIncludeDirectories="../../includes;../../../core/includes;" PreprocessorDefinitions="WIN32" AlternateParameterSyntax="false" F77RuntimeCompatibility="true" FPS4Libs="false" CallingConvention="callConventionCRef" ExternalNameUnderscore="true" ModulePath="$(INTDIR)/" ObjectFile="$(INTDIR)/" RuntimeLibrary="rtMultiThreadedDLL" ImproveFloatingPointConsistency="true"/>
24 <Tool Name="VFLinkerTool" OutputFile="$(OutDir)/$(ProjectName)" SuppressStartupBanner="true"/> 24 <Tool Name="VFLinkerTool" OutputFile="$(OutDir)/$(ProjectName)" SuppressStartupBanner="true"/>
25 <Tool Name="VFLibrarianTool" OutputFile="../../../../libs/elementary_functions_f.lib"/> 25 <Tool Name="VFLibrarianTool" OutputFile="../../../../libs/elementary_functions_f.lib"/>
26 <Tool Name="VFResourceCompilerTool"/> 26 <Tool Name="VFResourceCompilerTool"/>
@@ -190,7 +190,6 @@ cd .."/></Configuration></Configurations>
190 <File RelativePath="..\..\sci_gateway\fortran\sci_f_sign.f"/> 190 <File RelativePath="..\..\sci_gateway\fortran\sci_f_sign.f"/>
191 <File RelativePath="..\..\sci_gateway\fortran\sci_f_sin.f"/> 191 <File RelativePath="..\..\sci_gateway\fortran\sci_f_sin.f"/>
192 <File RelativePath="..\..\sci_gateway\fortran\sci_f_size.f"/> 192 <File RelativePath="..\..\sci_gateway\fortran\sci_f_size.f"/>
193 <File RelativePath="..\..\sci_gateway\fortran\sci_f_sort.f"/>
194 <File RelativePath="..\..\sci_gateway\fortran\sci_f_spones.f"/> 193 <File RelativePath="..\..\sci_gateway\fortran\sci_f_spones.f"/>
195 <File RelativePath="..\..\sci_gateway\fortran\sci_f_sqrt.f"/> 194 <File RelativePath="..\..\sci_gateway\fortran\sci_f_sqrt.f"/>
196 <File RelativePath="..\..\sci_gateway\fortran\sci_f_sum.f"/> 195 <File RelativePath="..\..\sci_gateway\fortran\sci_f_sum.f"/>
@@ -233,7 +232,6 @@ cd .."/></Configuration></Configurations>
233 <File RelativePath="wscal.f"/> 232 <File RelativePath="wscal.f"/>
234 <File RelativePath="wshrsl.f"/> 233 <File RelativePath="wshrsl.f"/>
235 <File RelativePath="wsign.f"/> 234 <File RelativePath="wsign.f"/>
236 <File RelativePath="wsort.f"/>
237 <File RelativePath="wsqrt.f"/> 235 <File RelativePath="wsqrt.f"/>
238 <File RelativePath="wswap.f"/> 236 <File RelativePath="wswap.f"/>
239 <File RelativePath="wtan.f"/> 237 <File RelativePath="wtan.f"/>
diff --git a/scilab/modules/elementary_functions/src/fortran/elementary_functions_f2c.vcproj b/scilab/modules/elementary_functions/src/fortran/elementary_functions_f2c.vcproj
index 56a941b..22662d0 100644
--- a/scilab/modules/elementary_functions/src/fortran/elementary_functions_f2c.vcproj
+++ b/scilab/modules/elementary_functions/src/fortran/elementary_functions_f2c.vcproj
@@ -824,10 +824,6 @@
824 > 824 >
825 </File> 825 </File>
826 <File 826 <File
827 RelativePath="..\..\sci_gateway\fortran\sci_f_sort.c"
828 >
829 </File>
830 <File
831 RelativePath="..\..\sci_gateway\fortran\sci_f_spones.c" 827 RelativePath="..\..\sci_gateway\fortran\sci_f_spones.c"
832 > 828 >
833 </File> 829 </File>
@@ -996,10 +992,6 @@
996 > 992 >
997 </File> 993 </File>
998 <File 994 <File
999 RelativePath=".\wsort.c"
1000 >
1001 </File>
1002 <File
1003 RelativePath=".\wsqrt.c" 995 RelativePath=".\wsqrt.c"
1004 > 996 >
1005 </File> 997 </File>
@@ -1560,10 +1552,6 @@
1560 > 1552 >
1561 </File> 1553 </File>
1562 <File 1554 <File
1563 RelativePath="..\..\sci_gateway\fortran\sci_f_sort.f"
1564 >
1565 </File>
1566 <File
1567 RelativePath="..\..\sci_gateway\fortran\sci_f_spones.f" 1555 RelativePath="..\..\sci_gateway\fortran\sci_f_spones.f"
1568 > 1556 >
1569 </File> 1557 </File>
@@ -1732,10 +1720,6 @@
1732 > 1720 >
1733 </File> 1721 </File>
1734 <File 1722 <File
1735 RelativePath=".\wsort.f"
1736 >
1737 </File>
1738 <File
1739 RelativePath=".\wsqrt.f" 1723 RelativePath=".\wsqrt.f"
1740 > 1724 >
1741 </File> 1725 </File>
diff --git a/scilab/modules/elementary_functions/src/fortran/wsort.f b/scilab/modules/elementary_functions/src/fortran/wsort.f
deleted file mode 100644
index 15f33b1..0000000
--- a/scilab/modules/elementary_functions/src/fortran/wsort.f
+++ /dev/null
@@ -1,190 +0,0 @@
1c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2c Copyright (C) INRIA
3c
4c This file must be used under the terms of the CeCILL.
5c This source file is licensed as described in the file COPYING, which
6c you should have received as part of this distribution. The terms
7c are also available at
8c http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9c
10 subroutine wsort(countr,counti,n,index,test)
11c
12c!purpose
13c wsort sort double precision array according to rule specified by
14c external test
15c maintaining an index array
16c
17c!calling sequence
18c subroutine wsort(countr,counti,n,index,test)
19c integer n,index(n)
20c double precision count(n)
21c integer test
22c external test
23c
24c count(r,i) : array to be sorted
25c n :size of count and index
26c index : array containing on return index of sorted array
27c test : external integer function which define formal order for
28c records
29c test(r1,i1,r2,i2)
30c where
31c r1,i1 are real and imag part of first complex number
32c r2,i2 are real and imag part of second complex number
33c returns
34c 1 :if 1 is greater than 2
35c -1 :if 1 is less than 2
36c 0 :if 1 is equal to 2
37c
38c!method
39c quick sort metjod is used
40c!restriction
41c n must be less than 2**(50/2) ! due to lengh of work space mark
42c
43 dimension mark(50),index(n)
44 double precision countr(n),counti(n),avr,avi,xr,xi
45 integer test
46 external test
47c
48c set index array to original order .
49 do 10 i=1,n
50 index(i)=i
51 10 continue
52c check that a trivial case has not been entered .
53 if(n.eq.1)goto 200
54 if(n.ge.1)go to 30
55 goto 200
56c 'm' is the length of segment which is short enough to enter
57c the final sorting routine. it may be easily changed.
58 30 m=12
59c set up initial values.
60 la=2
61 is=1
62 if=n
63 do 190 mloop=1,n
64c if segment is short enough sort with final sorting routine .
65 ifka=if-is
66 if((ifka+1).gt.m)goto 70
67c********* final sorting ***
68c ( a simple bubble sort )
69 is1=is+1
70 do 60 j=is1,if
71 i=j
72 40 it=test(countr(i-1),counti(i-1),countr(i),counti(i))
73 if(it.eq.1) goto 60
74 if(it.eq.-1) goto 50
75 if(index(i-1).lt.index(i))goto 60
76 50 avr=countr(i-1)
77 avi=counti(i-1)
78 countr(i-1)=countr(i)
79 counti(i-1)=counti(i)
80 countr(i)=avr
81 counti(i)=avi
82 int=index(i-1)
83 index(i-1)=index(i)
84 index(i)=int
85 i=i-1
86 if(i.gt.is)goto 40
87 60 continue
88 la=la-2
89 goto 170
90c ******* quicksort ********
91c select the number in the central position in the segment as
92c the test number.replace it with the number from the segment's
93c highest address.
94 70 iy=(is+if)/2
95 xr=countr(iy)
96 xi=counti(iy)
97 intest=index(iy)
98 countr(iy)=countr(if)
99 counti(iy)=counti(if)
100 index(iy)=index(if)
101c the markers 'i' and 'ifk' are used for the beginning and end
102c of the section not so far tested against the present value
103c of x .
104 k=1
105 ifk=if
106c we alternate between the outer loop that increases i and the
107c inner loop that reduces ifk, moving numbers and indices as
108c necessary, until they meet .
109 do 110 i=is,if
110 it=test(xr,xi,countr(i),counti(i))
111 if(it.lt.0) goto 110
112 if(it.gt.0) goto 80
113 if(intest.gt.index(i))goto 110
114 80 if(i.ge.ifk)goto 120
115 countr(ifk)=countr(i)
116 counti(ifk)=counti(i)
117 index(ifk)=index(i)
118 k1=k
119 do 100 k=k1,ifka
120 ifk=if-k
121 it=test(countr(ifk),counti(ifk),xr,xi)
122 if(it.lt.0) goto 100
123 if(it.gt.0) goto 90
124 if(intest.le.index(ifk))goto 100
125 90 if(i.ge.ifk)goto 130
126 countr(i)=countr(ifk)
127 counti(i)=counti(ifk)
128 index(i)=index(ifk)
129 go to 110
130 100 continue
131 goto 120
132 110 continue
133c return the test number to the position marked by the marker
134c which did not move last. it divides the initial segment into
135c 2 parts. any element in the first part is less than or equal
136c to any element in the second part, and they may now be sorted
137c independently .
138 120 countr(ifk)=xr
139 counti(ifk)=xi
140 index(ifk)=intest
141 ip=ifk
142 goto 140
143 130 countr(i)=xr
144 counti(i)=xi
145 index(i)=intest
146 ip=i
147c store the longer subdivision in workspace.
148 140 if((ip-is).gt.(if-ip))goto 150
149 mark(la)=if
150 mark(la-1)=ip+1
151 if=ip-1
152 goto 160
153 150 mark(la)=ip-1
154 mark(la-1)=is
155 is=ip+1
156c find the length of the shorter subdivision.
157 160 lngth=if-is
158 if(lngth.le.0)goto 180
159c if it contains more than one element supply it with workspace .
160 la=la+2
161 goto 190
162 170 if(la.le.0)goto 200
163c obtain the address of the shortest segment awaiting quicksort
164 180 if=mark(la)
165 is=mark(la-1)
166 190 continue
167 200 return
168 end
169 integer function rptest(r1,i1,r2,i2)
170 double precision r1,i1,r2,i2
171 if(r1.gt.r2) then
172 rptest=1
173 elseif(r1.lt.r2) then
174 rptest=-1
175 else
176 rptest=0
177 endif
178 end
179 integer function modtest(r1,i1,r2,i2)
180 double precision r1,i1,r2,i2,a1,a2
181 a1=r1**2+i1**2
182 a2=r2**2+i2**2
183 if(a1.gt.a2) then
184 modtest=1
185 elseif(a1.lt.a2) then
186 modtest=-1
187 else
188 modtest=0
189 endif
190 end
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3159.dia.ref b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3159.dia.ref
index 951209c..a0a5674 100644
--- a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3159.dia.ref
+++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3159.dia.ref
@@ -17,7 +17,7 @@ refsx_sort = [ 5. 4. 3. 3. 2. 2. 2. 1. ];
17refsi_sort = [ 7. 8. 3. 6. 2. 4. 5. 1. ]; 17refsi_sort = [ 7. 8. 3. 6. 2. 4. 5. 1. ];
18refsx_gsort = [ 5. 4. 3. 3. 2. 2. 2. 1. ]; 18refsx_gsort = [ 5. 4. 3. 3. 2. 2. 2. 1. ];
19refsi_gsort = [ 7. 8. 3. 6. 2. 4. 5. 1. ]; 19refsi_gsort = [ 7. 8. 3. 6. 2. 4. 5. 1. ];
20[sx_sort, si_sort] = sort(x); 20[sx_sort, si_sort] = gsort(x);
21[sx_gsort, si_gsort] = gsort(x); 21[sx_gsort, si_gsort] = gsort(x);
22if or(refsx_sort<>sx_sort) then bugmes();quit;end 22if or(refsx_sort<>sx_sort) then bugmes();quit;end
23if or(refsi_sort<>si_sort) then bugmes();quit;end 23if or(refsi_sort<>si_sort) then bugmes();quit;end
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3159.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3159.tst
index 06dc3e6..b6d5eba 100644
--- a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3159.tst
+++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3159.tst
@@ -20,7 +20,7 @@ refsi_sort = [ 7. 8. 3. 6. 2. 4. 5. 1. ];
20refsx_gsort = [ 5. 4. 3. 3. 2. 2. 2. 1. ]; 20refsx_gsort = [ 5. 4. 3. 3. 2. 2. 2. 1. ];
21refsi_gsort = [ 7. 8. 3. 6. 2. 4. 5. 1. ]; 21refsi_gsort = [ 7. 8. 3. 6. 2. 4. 5. 1. ];
22 22
23[sx_sort, si_sort] = sort(x); 23[sx_sort, si_sort] = gsort(x);
24[sx_gsort, si_gsort] = gsort(x); 24[sx_gsort, si_gsort] = gsort(x);
25 25
26if or(refsx_sort<>sx_sort) then pause,end 26if or(refsx_sort<>sx_sort) then pause,end
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3567.dia.ref b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3567.dia.ref
index d5619e0..d67fa5b 100644
--- a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3567.dia.ref
+++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3567.dia.ref
@@ -52,7 +52,7 @@ if or(ref_indices_3 <> indices_3) then bugmes();quit;end
52if or(ref_values <> values_4) then bugmes();quit;end 52if or(ref_values <> values_4) then bugmes();quit;end
53if or(ref_indices <> indices_4) then bugmes();quit;end 53if or(ref_indices <> indices_4) then bugmes();quit;end
54[values_gsort,indices_gsort] = gsort(c); 54[values_gsort,indices_gsort] = gsort(c);
55[values_sort,indices_sort] = sort(c); 55[values_sort,indices_sort] = gsort(c);
56if or(values_gsort <> values_sort) then bugmes();quit;end 56if or(values_gsort <> values_sort) then bugmes();quit;end
57if or(indices_gsort <> indices_sort) then bugmes();quit;end 57if or(indices_gsort <> indices_sort) then bugmes();quit;end
58x = [3,1,5]; 58x = [3,1,5];
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3567.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3567.tst
index f39d146..4c68497 100644
--- a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3567.tst
+++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_3567.tst
@@ -66,7 +66,7 @@ if or(ref_values <> values_4) then pause,end
66if or(ref_indices <> indices_4) then pause,end 66if or(ref_indices <> indices_4) then pause,end
67 67
68[values_gsort,indices_gsort] = gsort(c); 68[values_gsort,indices_gsort] = gsort(c);
69[values_sort,indices_sort] = sort(c); 69[values_sort,indices_sort] = gsort(c);
70if or(values_gsort <> values_sort) then pause,end 70if or(values_gsort <> values_sort) then pause,end
71if or(indices_gsort <> indices_sort) then pause,end 71if or(indices_gsort <> indices_sort) then pause,end
72 72
diff --git a/scilab/modules/elementary_functions/tests/unit_tests/sort.dia.ref b/scilab/modules/elementary_functions/tests/unit_tests/sort.dia.ref
deleted file mode 100644
index d2a98b2..0000000
--- a/scilab/modules/elementary_functions/tests/unit_tests/sort.dia.ref
+++ /dev/null
@@ -1,72 +0,0 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) ????-2008 - INRIA
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- JVM NOT MANDATORY -->
8warning('off')
9//================================
10a=[5 1 3 2 4];
11if or(sort(a)<>[5 4 3 2 1]) then bugmes();quit;end
12if or(sort(a+0)<>[5 4 3 2 1]) then bugmes();quit;end
13[s,k]=sort(a);
14if or(k<>[1 5 3 4 2]) then bugmes();quit;end
15if or(s<>[5 4 3 2 1]) then bugmes();quit;end
16[s,k]=sort(a+0);
17if or(k<>[1 5 3 4 2]) then bugmes();quit;end
18if or(s<>[5 4 3 2 1]) then bugmes();quit;end
19//================================
20a=string([5 1 3 2 4]);
21if or(sort(a)<>string(1:5)) then bugmes();quit;end
22if or(sort(string([5 1 3 2 4]))<>string(1:5)) then bugmes();quit;end
23[s,k]=sort(a);
24if or(k<>[2 4 3 5 1]) then bugmes();quit;end
25if or(s<>string(1:5)) then bugmes();quit;end
26[s,k]=sort(string([5 1 3 2 4]));
27if or(k<>[2 4 3 5 1]) then bugmes();quit;end
28if or(s<>string(1:5)) then bugmes();quit;end
29//================================
30a=[];
31if sort(a)<>[] then bugmes();quit;end
32[s,k]=sort(a);if s<>[]|k<>[] then bugmes();quit;end
33//================================
34if sort([])<>[] then bugmes();quit;end
35[s,k]=sort([]);
36if s<>[]|k<>[] then bugmes();quit;end
37//================================
38//sort string
39[s]=sort(['abc','abd','aa','bxe']);
40if or(s<>['aa','abc','abd','bxe']) then bugmes();quit;end
41[s,k]=sort(['abc','abd','aa','bxe']);
42if or(s<>['aa','abc','abd','bxe']) then bugmes();quit;end
43if or(k<>[3 1 2 4]) then bugmes();quit;end
44if (sort('abc')<>'abc') then bugmes();quit;end
45if (sort([]) <> []) then bugmes();quit;end
46//================================
47// sort matrix
48A=[1,2,5;3,4,2];
49[A_trie,indices]=sort(A);
50if (indices <> [5,2,6;4,3,1]) then bugmes();quit;end
51if (A_trie <> [5,3,2;4,2,1]) then bugmes();quit;end
52//================================
53// sort sparse matrix
54pos = [1,8;1,12;1,4];
55vals = [1,4,5];
56sp = sparse(pos,vals);
57[s] = sort(sp);
58if ( size(s) <> size(sp) ) then bugmes();quit;end
59[out1,out2,out3] = spget(s);
60if ( out1 <> gsort(pos,'r','i') ) then bugmes();quit;end
61if ( out2 <> sort(vals)' ) then bugmes();quit;end
62if ( out3 <> size(sp) ) then bugmes();quit;end
63//================================
64// sort complex matrix
65A = [18 21 10 7 5];
66B = [1 3 22 8 4];
67y = complex(A,B);
68[a,b] = sort(y);
69if or( b <> [3 2 1 4 5] ) then bugmes();quit;end
70if ( y(b) <> a ) then bugmes();quit;end
71//================================
72warning('on') \ No newline at end of file
diff --git a/scilab/modules/elementary_functions/tests/unit_tests/sort.tst b/scilab/modules/elementary_functions/tests/unit_tests/sort.tst
deleted file mode 100644
index 91685d3..0000000
--- a/scilab/modules/elementary_functions/tests/unit_tests/sort.tst
+++ /dev/null
@@ -1,73 +0,0 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) ????-2008 - INRIA
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7
8// <-- JVM NOT MANDATORY -->
9warning('off')
10//================================
11a=[5 1 3 2 4];
12if or(sort(a)<>[5 4 3 2 1]) then pause,end
13if or(sort(a+0)<>[5 4 3 2 1]) then pause,end
14[s,k]=sort(a);
15if or(k<>[1 5 3 4 2]) then pause,end
16if or(s<>[5 4 3 2 1]) then pause,end
17[s,k]=sort(a+0);
18if or(k<>[1 5 3 4 2]) then pause,end
19if or(s<>[5 4 3 2 1]) then pause,end
20//================================
21a=string([5 1 3 2 4]);
22if or(sort(a)<>string(1:5)) then pause,end
23if or(sort(string([5 1 3 2 4]))<>string(1:5)) then pause,end
24[s,k]=sort(a);
25if or(k<>[2 4 3 5 1]) then pause,end
26if or(s<>string(1:5)) then pause,end
27[s,k]=sort(string([5 1 3 2 4]));
28if or(k<>[2 4 3 5 1]) then pause,end
29if or(s<>string(1:5)) then pause,end
30//================================
31a=[];
32if sort(a)<>[] then pause,end
33[s,k]=sort(a);if s<>[]|k<>[] then pause,end
34//================================
35if sort([])<>[] then pause,end
36[s,k]=sort([]);
37if s<>[]|k<>[] then pause,end
38//================================
39//sort string
40[s]=sort(['abc','abd','aa','bxe']);
41if or(s<>['aa','abc','abd','bxe']) then pause,end
42[s,k]=sort(['abc','abd','aa','bxe']);
43if or(s<>['aa','abc','abd','bxe']) then pause,end
44if or(k<>[3 1 2 4]) then pause,end
45if (sort('abc')<>'abc') then pause,end
46if (sort([]) <> []) then pause,end
47//================================
48// sort matrix
49A=[1,2,5;3,4,2];
50[A_trie,indices]=sort(A);
51if (indices <> [5,2,6;4,3,1]) then pause,end
52if (A_trie <> [5,3,2;4,2,1]) then pause,end
53//================================
54// sort sparse matrix
55pos = [1,8;1,12;1,4];
56vals = [1,4,5];
57sp = sparse(pos,vals);
58[s] = sort(sp);
59if ( size(s) <> size(sp) ) then pause,end
60[out1,out2,out3] = spget(s);
61if ( out1 <> gsort(pos,'r','i') ) then pause,end
62if ( out2 <> sort(vals)' ) then pause,end
63if ( out3 <> size(sp) ) then pause,end
64//================================
65// sort complex matrix
66A = [18 21 10 7 5];
67B = [1 3 22 8 4];
68y = complex(A,B);
69[a,b] = sort(y);
70if or( b <> [3 2 1 4 5] ) then pause,end
71if ( y(b) <> a ) then pause,end
72//================================
73warning('on') \ No newline at end of file