
Заготовки по С / Динамические структуры / GDSL / Документация
.pdf
4.12 Permutation manipulation module |
|
|
137 |
|||||
ˆ ulong gdsl_perm |
_inversions_ oun |
( onst gdsl_perm_t |
||||||
|
P) |
Count the y les numberlinear to linear permutatiermutation. |
. |
|
||||
|
|
|
inversions |
umber into a linear p |
|
|
||
|
|
|
gdsl_perm |
_ y les_ oun ( |
st gdsl_perm_t P) |
|||
ˆ ulong gdsl_perm |
y les oun |
( onst gdsl_perm_t |
||||||
|
P) |
Count the y les numbanoniintoal anoni al permutation. |
|
|
||||
ˆ gdsl perm t gdsl |
perm_set name (gdsl |
perm_t P, onst har |
||||||
ˆ |
|
|
|
heNAME)namepreviousnexttpofermutationgdslgdslpermutationpermutationpermpermfromfromlinear.set elementsarlinearprevnextermutationermutation((gdslarray. perm. (gdsltt_P)perm_t |
||||
|
|
permthe |
|
|
|
|
||
|
|
onst |
|
|
|
|
|
|
|
gdslNEWGetSet |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ˆˆ P,onstgdslgdslQ, InitializeMultiplyConvonstgdslpermpermulongrtgdslatwoapermineartpermt ermutationsARRAY)gdslgdslermutationALPHA,permpermP)with._antolinearmultiplyanonionstarrayitsgdsloftoalvaluesalperm(gdslformanoni. ._permtalBETA)(gdslt _RESULT,perm t
ˆ gdsl |
|
t gdsl perm |
|
to linear (gdsl_perm_t |
||
Q, onst |
|
P) |
|
|
|
|
Conv rt a |
|
al permutation to its linear form. |
||||
|
everse in anoni permutation.everse (gdsl_perm_t P) |
|||||
Inverse in pla e |
|
in erse (gdsl_perm_t P) |
||||
permutation. |
|
|
||||
ˆ gdsl_perm_t gdsl perm |
randomize (gdsl_perm_t P) |
|||||
Randomize pla ermutation. |
|
|
|
|||
Generated on Thu Jun 22 |
11:15:30 2006 for gdsl by Doxygen |
|

138 |
gdsl Module Do umentation |
ˆ elementgdsl elementermutationonst |
gdsl_perm_apply_on_array (gdsl_- |
ˆvoidfunApplygdslriteWRITEa ppermV, __F,writeFILEongdslto( onstapvermgdsltor. t P)perm_t P, onst gdsl_write_-
ˆvoidwriteWgdslfunthepermelementsWRITEwriteof a permutationF,xmlOUTPUTFILE(onstto_gdslaFILE,le. permvoid _USERt P, onstDATA)gdsl
ˆDATA)voidfunWgdslrite WRITEtheperm__F,dumpofFILEa permutation( onst gdsltoOUTPUTperma le into_P,XMLFILE,onst. voidgdsl writeUSER__--
4..12.1.1.1DumpTfunypedefthetionsinternalstruDotstruumentationgdsltureOUTPUTpermof a permutationFILE, voida le.USER_DATA)
GDSLThisDebut4.12nitionby.1ype.the2ermisatypedefvoluntatiline50tarofvoid(ypeopaquethis.legdslmodule.Variablesperm. .h. ofgdslthis_kindpermould'ntt be dire tly used,
gdsl_perm_write fun _t)(ulong E, FILEOUTPUT_FILE, gdsl_lo ation_t POSITION, void
Parameters:GDSLPOSITIONOUTPUTE permutationTheindipermutationUSERate FILEwhereiswriteanDATA)orETheelemenfun-isedlotionleomatedwheretobinatitypewrite.tonthewriteofgdslE_perm_positionmapped.t values to USER_DATA User's dat s
De nition line 74 of le gdsl_perm.h.
4.12De nition.1.3 atypedefline 80 ofstruGeneratedletgdslgdslpermonpermThu.h.Jundata22 11:15:30gdsl2006permfor gdsldataby Doxygent

. |
Permutation manipulation module |
|
|
|
|
|
139 |
||||
|
. |
.2 |
Enumeration Ty |
e Do umentation |
|
|
|
|
|||
4.12.2.1 |
enum gdsl |
perm |
position_t |
|
|
|
|
|
|
||
|
This |
ype is for gdsl perm write_fun t. |
|
|
|
|
|
|
|||
Enumerator: |
|
FIRST |
When |
|
t is |
rst |
posi- |
||||
|
|
GDSL PERM_POSITION_LAST |
When |
element is |
at last |
||||||
|
|
|
tion |
|
|
|
|
|
|
|
|
|
De nition at li e 55 of le gdsl_perm.h. |
|
|
|
|
|
|
||||
. |
.3 |
Fun tion |
Do umentation |
|
|
|
|
|
|
||
|
4.12NAMEComplexity:.ate3.a1anew.newgdslonstpermpermO(permulongutationN ) N. )gdsldata_strupermturealloof size( Nonstwi h namehar |
isNAMEset to a, opy |
|||||||||
Note:ofAlloCreate |
|
|
|
|
|
|
|
|
|
re ondition: Returns:Parameters:NtheNULLAME>Thenewly0innumberThealloasenameofatedofinsuelementsidentityoftheientnewpermutationofmemorythepermpermutationutation.initstolineartoreatereateform.in ase of su ess.
See gdslalso:_perm_free()opy()(p(p. .139)140)
4.12.3.2 void gdsl_perm_free (gdsl_perm_t P)
Deallostroyatepermutation.
the permutation P.
Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

140 |
|
|
gdsl Module Do umentation |
|
|
Note: |
|
|
|
|
|
|
alloPgdsln())to(pdestroy.perm139) t |
|
|
|
PComplexitalso:ondition:Theustpermbey:autativalidO( |
|
|
|
|
gdsl |
|
|
Parameters:re |
| | |
|
||
See |
|
|
||
|
4.12.3.3 gdsl |
opy |
40 |
|
|
perm_t gdsl_perm_ opy ( onst gdsl_perm_t P) |
|||
|
opy a perm |
. |
|
|
|
Create and returnutation opy of the permutation P. |
|||
Note: |
|
|
||
Postarameters:re PThePComplexity:ondition:ondiTheust urpermutationbeeda: validO(permutation|Pgdsl| )to permopy.ustt.be deallo ated with gdsl_perm_free. |
||||
Returns: |
|
|
||
|
|
a opy of P in ase of su ess. |
||
|
|
NULL in ase of insu ient memory. |
||
See also: |
allo (p. |
|||
|
|
gdsl_perm_free(p. |
139) |
Note:4.12Get Complexity:the.3.4namePonst)of aO(permutationhar1 Generated) gdsl .permon Thu getJun_22name11:15:30( onst2006 forgdslgdsl permby Doxygent

4.12 Perm |
|
manipulation module |
141 |
|
P ustutationbe valid gdsl_perm_t |
|
|||
re Theondition:ur ed string MUST NOT be freed. |
|
|||
Parameters: |
: |
|
|
|
ost ondi |
utation to get the name from |
|
||
P The |
|
|
||
gdsl_perm_set_name()(p. 143) |
|
|||
Returns: |
|
|
|
|
the name of the permutation P. |
|
|||
See also: |
|
|
|
|
4.12.3.5 ulong gdsl perm_get_size ( onst gdsl_perm_t P) |
||||
Get the size of a permutation. |
|
|||
Note: |
|
|
|
|
Complexity: O( 1 ) |
|
|||
re ondition: |
|
|
||
|
ust be a valid gdsl_perm_t |
|
||
Parameters: |
|
|
|
|
P |
The permutation to get the size from. |
|
||
gdslthealso:.3.6_umberpermulongonstofulonggdslgetelementselementpermINDIXof P get(noted)s()(parray(). elemen141)P )utation.(p. 142)( onst gdsl_perm_t P, |
||||
SeeReturns:4.12 |
|
| | |
|
|
Get the (INDIX+1)-th element from a perm |
. |
|||
Note: |
|
y: O( 1 ) |
|
PreGeneratedComplexitondition:ust beThua Junvalid22gdsl11:15:30perm2006t for& <gdsl= 0byINDIXDoxygen< |P|

142 |
|
|
|
|
|
|
gdsl Module Do umentation |
||
|
Parameters: |
|
|
|
|
|
|
||
|
|
P The permutation to use. |
|
|
|
|
|||
|
|
INDIX The indix of the value to get. |
|
|
|||||
Returns: |
|
|
|
|
|
|
|
||
|
|
the value at the INDIX-th position in the permutation P. |
|||||||
See also: |
|
|
size()(p. 141) |
|
|
||||
|
|
gdsl_perm_get_elements |
array()(p. 142) |
||||||
|
|
PComplexitthe.ondition:3.7arrayustgdslulongbeelementsy:avalidO(permgdsl1 )gdsloftapermPpermutationperm) datasget elements. |
_array ( onst |
||||||
PNote:Get4.re12 |
|
|
|
|
|
|
|
||
|
arameters: |
|
|
|
from. |
|
|
||
|
|
The permutation to get |
|
|
|
||||
Returns: |
|
|
|
|
|
|
|
||
|
|
the values array of the permutation P. |
|
|
|||||
See also: |
|
g |
|
t()(p. 141) |
|
|
|||
|
|
gdsl_perm_set_elements_array()(p. 145) |
|||||||
|
4.12.3.8 ulong gdsl_perm_ |
_inversions_ ount ( onst |
|||||||
|
|
|
gdsl |
perm |
t P) |
|
|
|
|
|
C un the inversions number intolinearlinear permutation. |
||||||||
Note: |
|
|
|
|
|
|
|
||
Parameters:re thePComplexity:ondition:TheustumberlinearbeofvalidO(permutationinversionsPlinear) gdslinto_usetheperm.lineart permutation P. |
|||||||||
Returns: |
|
| | |
|
|
|
|
|
Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen

|
Permutation manipulation module |
143 |
|||
|
4.12.3.9 |
ulong gdsl_perm_linear_ y les_ ount ( onst |
|
||
|
|
gdsl perm_t P) |
|
||
|
Coun the y les number into a linear permutation. |
|
|||
Note: |
|
|
|
|
|
Parameters:rethePComplexitondition:Theustumberlinearbey:ofvalidO(permanoniyPleslinearutation)altogdsltheto_uselinearperm._permutationt P. |
|
||||
Returns: |
|
| |
| |
|
|
See also: |
|
|
_ y les_ ount()(p. 143) |
|
|
|
gdsl_perm_ |
|
|
||
4.12.3.10 |
|
gdsl_perm_ anoni al_ y les_ ount ( onst |
|
||
|
Coun the yulongles umber into a anoni al permutation. |
|
|||
Note: |
gdsl perm_ P) |
|
|||
|
|
|
|
||
Parameters:re thePComplexity:ondition:TheustumberbeanoniofvalidO(alyPpermutalesanoni)into altheiongdsltoanoniuseperm.al_permutationt P. |
|
||||
Returns: |
|
| |
| |
|
|
See also: |
|
|
|
|
|
|
gdsl_perm_linear_ y les_ ount()(p. 143) |
|
|||
4.12.3.11 |
gdsl_perm_ gdsl perm_set_name (gdsl_perm_t P, |
||||
|
|
previoThufnstaJupermnsharname22utation11:15:30ofNEWthe.2006permutationNAMEfor gdsl)byPDoxygento a opy of NEW_NAME. |
|||
|
GeneratedChangeSet the nametheon |
|
|
|
|
|
|
|
|
|
|

144 |
|
|
|
gdsl Module Do umentation |
|
|
Note: |
|
|
|
|
|
re ondition:y: O( 1 ) |
|
|
||
|
|
Complexitust be a valid gdsl_perm_ |
|
||
Parameters: |
|
|
|||
|
|
P The permutation to ha ge the name |
|
||
|
|
NEW NAME The new name of P |
|
||
Returns: |
|
|
|
||
|
|
the modi ed permutation in ase of su ess. |
|||
|
|
NULL in ase of insu ient memory. |
|
||
See also: |
|
|
|
||
|
|
gdsl_perm_get_name()(p. 140) |
|
||
4.12.3.12 |
gdsl perm_t gdsl pe m linear next (gdsl_perm_t P) |
||||
|
Get the next permutation from a linear permutation. |
||||
|
The permutation P is modi ed to be ome the next permutation after P. |
||||
Note: |
|
|
|
||
|
re Complexitondition:ust linearbey:validO(|Plinear| ) gdsl_perm_t & |
|
|||
SeeReturns: |
|
|
| | > |
||
Parameters:NULLthePalso:Thenextif permutationPisalreadypermutationtheafterlasttothemodifypermpermutationP. P. 1 |
|||||
|
|
gdsl_perm_linear_prev()(p. 144) |
|
||
4.12.3.13 |
gdsl_perm_t gdsl_perm_linear prev (gdsl_perm_t P) |
||||
|
Get the previous permutat on from a linear permutation. |
||||
|
The permutation P is modi ed to be ome the previous permutation before P. |
||||
Note: |
|
|
|
||
|
|
Complexity: O( |PGenerated| ) |
on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen |
||
|
|
|
|
|
|

4.12 Permutation manipulation module |
145 |
||
re ondition: |
|
|
|
Parameters:NULLthePalso:ThepreviousustiflinearbePisvalidpealreadypermutationlinearutationthegdslbeforerstto_modifypermutationpermthepermutationt&P. = 2P. |
|||
SeeReturns: |
|
|
| | > |
gdsl_perm_linear_next()(p. 144) |
|
||
4.12.3.14 |
_ |
_ gdsl_perm_set_elements_array |
Note:ARRAYInitializeComplexit.atheIfpermutationARRAY(gdslpermutationy:O(permdoeswithnotPtanwithPdesign,arrayonstthea ofpermvaluesulongv utation,esontained.ARRAYtheninP)theisleftarrayun ofhangedvalues.
re ondition:ust be a valid|Pgdsl| ) _perm_t & V != NULL &
Parameters:NULLtheARRAYP ThemodiinpermutationedaseThepermutatiVarraydoestonotfinitializevaluesdesigninasetoarrainitializeofvalidsupermutationessP. V. == P |
||||||
Returns: |
|
|
|
|
| | |
| | |
See also: |
|
|
|
|
|
|
gdsl_perm_get_elements_ y()(p. 142) |
(gdsl_perm_t |
|||||
4.12.3.15 |
RESULT, |
gdsl perm m |
||||
|
|
gdsl perm_ultiplyALPHA, onst |
||||
|
gdsl perm_onstBETA) |
|
|
|||
Multiply two ermutations. |
|
|
BETA and puts the result |
|||
Compute the prod |
of the permutations ALPHA |
|||||
in RESULT witho |
tmodifying |
ALPHA and BETA. |
|
|
||
Generated on Thu Jun 22 11:15:30 2006 for gdsl by Doxygen |
|

146 |
|
|
|
|
|
|
|
gdsl Module Do umentation |
||||
Note: |
|
|
|
|
|
|
|
|
|
|
|
|
Pre RESULT,Complexity:ondition:ALPHAO(|RESULandBET| )A must be valids gdsl_perm_t & |
||||||||||||
== |
|
|
|
|
|
|
|
|
|
|
|RESULT| |
|
BETALPHAR SULALPHAThetheTheTheseresult==ondresultrstBETApermutationusedinofofthethemultipliprodu tationALPHAtheoftheproduxpermutationsBETAt |
A and B. |
|||||||||||
Returns:Parameters:RESULT,| |
| |
|
| |
| |
|
|
|
|
|
|
|
|
4.12.3.16 |
|
_ |
|
|
gdsl |
perm |
linear to anoni al |
|||||
|
(gdsl perm |
Q, onst gdsl |
perm_t P) |
|
|
|
||||||
Convert thelinearnear permutation P to its anoni al form. The resulted anoni al |
||||||||||||
permutation is |
permuta |
to its anoni al form. |
|
|
|
|||||||
pla ed into Q without modifying P. |
|
|
|
|||||||||
Note: |
|
|
|
|
|
|
|
|
|
|
|
|
arameters:re PComplexity:ondition:& Q ust beO( valids|P| ) |
gdsl_perm_t & |
|
|
|
|
|||||||
P thePQ Thanonilinearanonial formpermutational formQofofthePusedpermutationtoomputePP.==its Qanoni& Pal!=formQ into Q |
||||||||||||
Returns: |
|
|
|
|
|
|
|
| | |
| | |
|
|
|
See also: |
|
|
|
|
|
|
|
|
|
|
|
|
gdsl_perm_ anoni al_to_linear()(p. 146) |
linear |
|||||||||||
4.12.3.17 |
|
_ |
|
|
gdsl |
perm |
anoni al to |
|||||
|
(gdsl_ |
|
Q, onst gdsl |
perm_t P) |
|
|
|
|||||
|
|
|
perm |
|
to its linear form. |
|
|
|
||||
Convert theanononi al |
permutation |
|
P |
its linear form. The resulted linear |
||||||||
permutation is pla ed into Q without mtodifying P. |
|
|
|
|||||||||
|
|
|
|
Generated ionThu Jun 22 11:15:30 2006 for gdsl by Doxygen |
|