programmer's documentation
cs_sort.h
Go to the documentation of this file.
1 #ifndef __CS_SORT_H__
2 #define __CS_SORT_H__
3 
4 /*============================================================================
5  * Functions related to in-place sorting of arrays.
6  *===========================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2015 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 #include "cs_defs.h"
31 
32 /*----------------------------------------------------------------------------
33  * Local headers
34  *---------------------------------------------------------------------------*/
35 
36 #include "cs_base.h"
37 
38 /*---------------------------------------------------------------------------*/
39 
41 
42 /*=============================================================================
43  * Macro definitions
44  *===========================================================================*/
45 
46 /*============================================================================
47  * Type definitions
48  *===========================================================================*/
49 
50 /*=============================================================================
51  * Static global variables
52  *===========================================================================*/
53 
54 /*=============================================================================
55  * Public function prototypes
56  *===========================================================================*/
57 
58 /*----------------------------------------------------------------------------
59  * Sort an array "a" between its left bound "l" and its right bound "r"
60  * thanks to a shell sort (Knuth algorithm).
61  * Index location of the sorted array are stored in loc. a is unchanged.
62  *
63  * parameters:
64  * l <-- left bound
65  * r <-- right bound
66  * a <-> array to sort (not modified)
67  * loc <-> position by increasing order (size = r-l)
68  *---------------------------------------------------------------------------*/
69 
70 void
72  cs_lnum_t r,
73  const cs_lnum_t a[],
74  cs_lnum_t loc[]);
75 
76 /*----------------------------------------------------------------------------
77  * Sort an array "a" between its left bound "l" and its right bound "r"
78  * thanks to a shell sort (Knuth algorithm).
79  *
80  * parameters:
81  * l <-- left bound
82  * r <-- right bound
83  * a <-> array to sort
84  *---------------------------------------------------------------------------*/
85 
86 void
88  cs_lnum_t r,
89  cs_lnum_t a[]);
90 
91 /*----------------------------------------------------------------------------
92  * Sort a global array "a" between its left bound "l" and its right bound "r"
93  * thanks to a shell sort (Knuth algorithm).
94  *
95  * parameters:
96  * l <-- left bound
97  * r <-- right bound
98  * a <-> array to sort
99  *---------------------------------------------------------------------------*/
100 
101 void
103  cs_lnum_t r,
104  cs_gnum_t a[]);
105 
106 /*----------------------------------------------------------------------------
107  * Sort an array "a" and apply the sort to its associated array "b" (local
108  * numbering)
109  * Sort is realized thanks to a shell sort (Knuth algorithm).
110  *
111  * parameters:
112  * l --> left bound
113  * r --> right bound
114  * a <-> array to sort
115  * b <-> associated array
116  *---------------------------------------------------------------------------*/
117 
118 void
120  cs_lnum_t r,
121  cs_lnum_t a[],
122  cs_lnum_t b[]);
123 
124 /*----------------------------------------------------------------------------
125  * Sort an array "a" and apply the sort to its associated array "b" (local
126  * numbering)
127  * Sort is realized thanks to a shell sort (Knuth algorithm).
128  *
129  * parameters:
130  * l --> left bound
131  * r --> right bound
132  * a <-> array to sort
133  * b <-> associated array
134  *---------------------------------------------------------------------------*/
135 
136 void
138  int r,
139  int a[],
140  double b[]);
141 
142 /*----------------------------------------------------------------------------
143  * Sort an array "a" and apply the sort to its associated array "b" (local
144  * numbering)
145  * Sort is realized thanks to a shell sort (Knuth algorithm).
146  *
147  * parameters:
148  * l --> left bound
149  * r --> right bound
150  * a <-> array to sort
151  * b <-> associated array
152  *---------------------------------------------------------------------------*/
153 
154 void
156  int r,
157  int a[],
158  short int b[]);
159 
160 /*----------------------------------------------------------------------------
161  * Sort an array "a" and apply the sort to its associated array "b" (local
162  * numbering)
163  * Sort is realized thanks to a shell sort (Knuth algorithm).
164  *
165  * parameters:
166  * l --> left bound
167  * r --> right bound
168  * a <-> array to sort
169  * b <-> associated array
170  *---------------------------------------------------------------------------*/
171 
172 void
174  cs_lnum_t r,
175  cs_gnum_t a[],
176  cs_gnum_t b[]);
177 
178 /*---------------------------------------------------------------------------*/
179 
181 
182 #endif /* __CS_SORT_H__ */
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:280
void cs_sort_sicoupled_shell(int l, int r, int a[], short int b[])
Definition: cs_sort.c:303
void cs_sort_gnum_shell(cs_lnum_t l, cs_lnum_t r, cs_gnum_t a[])
Definition: cs_sort.c:160
void cs_sort_shell(cs_lnum_t l, cs_lnum_t r, cs_lnum_t a[])
Definition: cs_sort.c:124
#define BEGIN_C_DECLS
Definition: cs_defs.h:429
void cs_sort_coupled_gnum_shell(cs_lnum_t l, cs_lnum_t r, cs_gnum_t a[], cs_gnum_t b[])
Definition: cs_sort.c:354
double precision, save a
Definition: cs_fuel_incl.f90:146
void cs_sort_coupled_shell(cs_lnum_t l, cs_lnum_t r, cs_lnum_t a[], cs_lnum_t b[])
Definition: cs_sort.c:202
void cs_sort_shell_inplace(cs_lnum_t l, cs_lnum_t r, const cs_lnum_t a[], cs_lnum_t loc[])
Definition: cs_sort.c:82
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
#define END_C_DECLS
Definition: cs_defs.h:430
void cs_sort_dcoupled_shell(int l, int r, int a[], double b[])
Definition: cs_sort.c:252
double precision, save b
Definition: cs_fuel_incl.f90:146