Debian Codegraph @

dwsys/Permutation.h

raw symbols SCIP
1 #cxx . . $ `<file>/dwsys/Permutation.h`/ifndef _Permutation_h_
2 #define _Permutation_h_cxx . . $ `dwsys/Permutation.h:2:9`!
3 /* Permutation.h
4 *
5 * Copyright (C) 2005-2022, 2025-2026 David Weenink
6 *
7 * This code is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This code is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this work. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "melder.h"cxx . . $ `<file>/melder/melder.h`/
22 #include "Collection.h"cxx . . $ `<file>/sys/Collection.h`/
23 #include "Graphics.h"cxx . . $ `<file>/sys/Graphics.h`/
24 #include "NUMsorting.h"cxx . . $ `<file>/dwsys/NUMsorting.h`/
25
26 #include "Permutation_def.h"cxx . . $ `<file>/dwsys/Permutation_def.h`/
27
28 /*
29 Class invariant: any permutation equals the identity permutation after all its elements are sorted ascendingly.
30 Alternative: a permutation of size n contains all numbers from 1 to n.
31 */
32
33 void Permutation_initcxx . . $ Permutation_init(9641beaa0f6a5f07). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# numberOfElements);
34
35 autoPermutationcxx . . $ autoPermutation# Permutation_createSimplePermutationcxx . . $ Permutation_createSimplePermutation(c5ff149f01fd5712). (constINTVECcxx . . $ constINTVEC# const& numbers);
36
37 void Permutation_tableJump_inlinecxx . . $ Permutation_tableJump_inline(2a83444aef2ae232). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# jumpSize, integercxx . . $ integer# first);
38
39 autoPermutationcxx . . $ autoPermutation# Permutation_createcxx . . $ Permutation_create(50161d5495f26400). (integercxx . . $ integer# numberOfElements, bool identity);
40 /*
41 Create the Permutation data structure and fill
42 with the identical permutation (1,2,..n) if identity is true
43 else create a random permutation
44 */
45
46 autoPermutationcxx . . $ autoPermutation# Permutation_createAsSortingIndexcxx . . $ Permutation_createAsSortingIndex(57823860738f5352). (constSTRVECcxx . . $ constSTRVEC# const& strvec, kStrings_sortingcxx . . $ kStrings_sorting# sorting);
47
48 void Permutation_drawAsLinecxx . . $ Permutation_drawAsLine(dcaec16abebe47af). (Permutationcxx . . $ Permutation# me, Graphicscxx . . $ Graphics# g, bool garnish);
49
50 void Permutation_checkInvariantcxx . . $ Permutation_checkInvariant(94340b06b44406f4). (Permutationcxx . . $ Permutation# me);
51 /* Check that the elements, if sorted ascendingly, are exactly equal to the identity (1,2,...). */
52
53
54 void Permutation_sortcxx . . $ Permutation_sort(94340b06b44406f4). (Permutationcxx . . $ Permutation# me);
55 /* Set p [1..n] = 1,..n */
56
57 integercxx . . $ integer# Permutation_getNumberOfInversionscxx . . $ Permutation_getNumberOfInversions(c3fc5518efe06623). (Permutationcxx . . $ Permutation# me);
58 /*
59 Count the number of times when i < j && p [i] > p [j].
60 E.g. {1,2,3} -> 0 inversions; {3,2,1} -> 3; {1,3,2} -> 1 inversion.
61 */
62
63 autoINTVECcxx . . $ autoINTVEC# Permutation_getRandomInversionIndicescxx . . $ Permutation_getRandomInversionIndices(9636a4cea625e927). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# maxNumberOfRandomInversions);
64 autoINTVECcxx . . $ autoINTVEC# Permutation_getAllInversionIndicescxx . . $ Permutation_getAllInversionIndices(5c80cc59c44900d). (Permutationcxx . . $ Permutation# me);
65
66 autoMATcxx . . $ autoMAT# Permutation_getRandomInversionscxx . . $ Permutation_getRandomInversions(4f4d1163a6afee3e). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# maxNumberOfRandomInversions); /* convenience for interface */
67 autoMATcxx . . $ autoMAT# Permutation_getAllInversionscxx . . $ Permutation_getAllInversions(7b3b6b17ceefd02). (Permutationcxx . . $ Permutation# me); /* convenience for interface */
68
69 void Permutation_permuteRandomly_inplacecxx . . $ Permutation_permuteRandomly_inplace(2a83444aef2ae232). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# from, integercxx . . $ integer# to);
70
71 autoPermutationcxx . . $ autoPermutation# Permutation_permuteRandomlycxx . . $ Permutation_permuteRandomly(47f3653fcdcb92c1). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# from, integercxx . . $ integer# to);
72 /* Generate a new sequence by permuting the elements from..to */
73
74 autoPermutationcxx . . $ autoPermutation# Permutation_rotatecxx . . $ Permutation_rotate(7564b440bd1bf88c). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# from, integercxx . . $ integer# to, integercxx . . $ integer# step);
75
76 void Permutation_swapOneFromRangecxx . . $ Permutation_swapOneFromRange(8f0635e219a5cec6). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# from, integercxx . . $ integer# to, integercxx . . $ integer# pos, bool forbidsame);
77 /* Swap item at pos with one randomly chosen in interval [from,to]. If pos in [from,to]
78 and forbidsame==true then new position may not be equal to pos. */
79
80 void Permutation_swapBlockscxx . . $ Permutation_swapBlocks(b6476263b1fecf20). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# from, integercxx . . $ integer# to, integercxx . . $ integer# blocksize);
81 /* Swap two blocks */
82
83 void Permutation_swapPositionscxx . . $ Permutation_swapPositions(2a83444aef2ae232). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# i1, integercxx . . $ integer# i2);
84
85 void Permutation_swapNumberscxx . . $ Permutation_swapNumbers(2a83444aef2ae232). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# i1, integercxx . . $ integer# i2);
86
87 autoPermutationcxx . . $ autoPermutation# Permutation_interleavecxx . . $ Permutation_interleave(6c7bb2a0c232dafc). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# from, integercxx . . $ integer# to, integercxx . . $ integer# blocksize, integercxx . . $ integer# offset);
88
89 autoPermutationcxx . . $ autoPermutation# Permutation_permuteBlocksRandomlycxx . . $ Permutation_permuteBlocksRandomly(3a00034dc449a46d). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# from, integercxx . . $ integer# to, integercxx . . $ integer# blocksize, bool permuteWithinBlocks, bool noDoublets);
90 /* Permute blocks of size blocksize randomly. If permuteWithinBlocks=true and noDoublets=true forbid that the last
91 number in a block and the first number in the following block are 'equal modulo blocksize'. */
92
93 integercxx . . $ integer# Permutation_getValueAtIndexcxx . . $ Permutation_getValueAtIndex(165de1b32307c4ff). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# i);
94 /* return i > 0 && i < my n ? my p [i] : -1 */
95
96 integercxx . . $ integer# Permutation_getIndexAtValuecxx . . $ Permutation_getIndexAtValue(165de1b32307c4ff). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# value);
97 /* Find i for which p [i] = value */
98
99 autoPermutationcxx . . $ autoPermutation# Permutation_invertcxx . . $ Permutation_invert(183440ac36fdd98b). (Permutationcxx . . $ Permutation# me);
100 void Permutation_invert_intocxx . . $ Permutation_invert_into(7dd67ac94904697a). (Permutationcxx . . $ Permutation# me, mutablePermutationcxx . . $ mutablePermutation# result);
101 /* */
102
103 void Permutation_reverse_inlinecxx . . $ Permutation_reverse_inline(2a83444aef2ae232). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# from, integercxx . . $ integer# to);
104 autoPermutationcxx . . $ autoPermutation# Permutation_reversecxx . . $ Permutation_reverse(47f3653fcdcb92c1). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# from, integercxx . . $ integer# to);
105 /* (n1,n2,...nn) to (nn,...n2,n1) */
106
107 void Permutation_next_inplacecxx . . $ Permutation_next_inplace(94340b06b44406f4). (Permutationcxx . . $ Permutation# me);
108
109 void Permutation_previous_inplacecxx . . $ Permutation_previous_inplace(94340b06b44406f4). (Permutationcxx . . $ Permutation# me);
110
111 autoPermutationcxx . . $ autoPermutation# Permutations_multiply2cxx . . $ Permutations_multiply2(b870e6e946bec713). (Permutationcxx . . $ Permutation# me, Permutationcxx . . $ Permutation# thee);
112 void Permutations_multiply2_intocxx . . $ Permutations_multiply2_into(4e0db9ffa82a60dc). (Permutationcxx . . $ Permutation# me, Permutationcxx . . $ Permutation# thee, mutablePermutationcxx . . $ mutablePermutation# result);
113
114 autoPermutationcxx . . $ autoPermutation# Permutations_multiplycxx . . $ Permutations_multiply(b4a03a92d984a386). (OrderedOfcxx . . $ OrderedOf#<structPermutationcxx . . $ structPermutation#>* me);
115
116 autoPermutationcxx . . $ autoPermutation# Permutation_permutePartByOthercxx . . $ Permutation_permutePartByOther(3462e598b4b4acda). (Permutationcxx . . $ Permutation# me, integercxx . . $ integer# startPosition, Permutationcxx . . $ Permutation# other);
117
118 void Permutation_permuteSubsetByOther_inoutcxx . . $ Permutation_permuteSubsetByOther_inout(ae60a1e6ab6aae04). (Permutationcxx . . $ Permutation# me, constINTVECcxx . . $ constINTVEC# const& subsetPositions, Permutationcxx . . $ Permutation# other);
119
120 void Permutation_permuteVEC_inoutcxx . . $ Permutation_permuteVEC_inout(29794ae64c452942). (Permutationcxx . . $ Permutation# me, VECcxx . . $ VEC# vec);
121 void Permutation_permuteINTVEC_inoutcxx . . $ Permutation_permuteINTVEC_inout(b77340f3818a0a0e). (Permutationcxx . . $ Permutation# me, INTVECcxx . . $ INTVEC# vec);
122
123 void Permutation_permuteSTRVEC_inoutcxx . . $ Permutation_permuteSTRVEC_inout(bb7c6c2f7dc43e79). (Permutationcxx . . $ Permutation# me, autoSTRVECcxx . . $ autoSTRVEC# & vec); // special
124
125 autoPermutationcxx . . $ autoPermutation# Permutation_moveElementsToTheFrontcxx . . $ Permutation_moveElementsToTheFront(88ed3dbb4090f6e). (Permutationcxx . . $ Permutation# me, constINTVECcxx . . $ constINTVEC# const& subsetPositions);
126
127 void Permutations_swapcxx . . $ Permutations_swap(7dd67ac94904697a). (Permutationcxx . . $ Permutation# me, Permutationcxx . . $ Permutation# thee);
128
129 #endif /* _Permutation_h_ */