gdsl
1.8
|
00001 /* 00002 * This file is part of the Generic Data Structures Library (GDSL). 00003 * Copyright (C) 1998-2017 Nicolas Darnis <ndarnis@free.fr>. 00004 * 00005 * GDSL is free software: you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation, either version 3 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * GDSL is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with GDSL. If not, see <http://www.gnu.org/licenses/>. 00017 * 00018 * $RCSfile: gdsl_perm.h,v $ 00019 * $Revision: 1.23 $ 00020 * $Date: 2015/02/17 12:22:57 $ 00021 */ 00022 00027 #ifndef _GDSL_PERM_H_ 00028 #define _GDSL_PERM_H_ 00029 00030 00031 #include "gdsl_types.h" 00032 00033 00034 #ifdef __cplusplus 00035 extern "C" 00036 { 00037 #endif /* __cplusplus */ 00038 00069 typedef struct gdsl_perm* gdsl_perm_t; 00070 00074 typedef enum 00075 { 00077 GDSL_PERM_POSITION_FIRST = 1, 00078 00080 GDSL_PERM_POSITION_LAST = 2 00081 00082 } gdsl_perm_position_t; 00083 00092 typedef void (* gdsl_perm_write_func_t) 00093 (ulong E, 00094 FILE* OUTPUT_FILE, 00095 gdsl_location_t POSITION, 00096 void* USER_DATA 00097 ); 00098 00099 typedef struct gdsl_perm_data* gdsl_perm_data_t; 00100 00101 /******************************************************************************/ 00102 /* Management functions of permutations */ 00103 /******************************************************************************/ 00104 00121 extern gdsl_perm_t 00122 gdsl_perm_alloc (const char* NAME, 00123 const ulong N 00124 ); 00125 00137 extern void 00138 gdsl_perm_free (gdsl_perm_t P 00139 ); 00140 00155 extern gdsl_perm_t 00156 gdsl_perm_copy (const gdsl_perm_t P 00157 ); 00158 00159 /******************************************************************************/ 00160 /* Consultation functions of permutations */ 00161 /******************************************************************************/ 00162 00172 extern const char* 00173 gdsl_perm_get_name (const gdsl_perm_t P 00174 ); 00175 00185 extern ulong 00186 gdsl_perm_get_size (const gdsl_perm_t P 00187 ); 00188 00199 extern ulong 00200 gdsl_perm_get_element (const gdsl_perm_t P, 00201 const ulong INDIX 00202 ); 00203 00213 extern ulong* 00214 gdsl_perm_get_elements_array (const gdsl_perm_t P 00215 ); 00216 00224 extern ulong 00225 gdsl_perm_linear_inversions_count (const gdsl_perm_t P 00226 ); 00227 00236 extern ulong 00237 gdsl_perm_linear_cycles_count (const gdsl_perm_t P 00238 ); 00239 00248 extern ulong 00249 gdsl_perm_canonical_cycles_count (const gdsl_perm_t P 00250 ); 00251 00252 /******************************************************************************/ 00253 /* Modification functions of permutations */ 00254 /******************************************************************************/ 00255 00269 extern gdsl_perm_t 00270 gdsl_perm_set_name (gdsl_perm_t P, 00271 const char* NEW_NAME 00272 ); 00273 00286 extern gdsl_perm_t 00287 gdsl_perm_linear_next (gdsl_perm_t P 00288 ); 00289 00302 extern gdsl_perm_t 00303 gdsl_perm_linear_prev (gdsl_perm_t P 00304 ); 00305 00321 extern gdsl_perm_t 00322 gdsl_perm_set_elements_array (gdsl_perm_t P, 00323 const ulong* ARRAY 00324 ); 00325 00326 /******************************************************************************/ 00327 /* Operations functions of permutations */ 00328 /******************************************************************************/ 00329 00344 extern gdsl_perm_t 00345 gdsl_perm_multiply (gdsl_perm_t RESULT, 00346 const gdsl_perm_t ALPHA, 00347 const gdsl_perm_t BETA 00348 ); 00349 00363 extern gdsl_perm_t 00364 gdsl_perm_linear_to_canonical (gdsl_perm_t Q, 00365 const gdsl_perm_t P 00366 ); 00367 00381 extern gdsl_perm_t 00382 gdsl_perm_canonical_to_linear (gdsl_perm_t Q, 00383 const gdsl_perm_t P 00384 ); 00385 00395 extern gdsl_perm_t 00396 gdsl_perm_inverse (gdsl_perm_t P 00397 ); 00398 00407 extern gdsl_perm_t 00408 gdsl_perm_reverse (gdsl_perm_t P 00409 ); 00410 00422 extern gdsl_perm_t 00423 gdsl_perm_randomize (gdsl_perm_t P 00424 ); 00425 00436 extern gdsl_element_t* 00437 gdsl_perm_apply_on_array (gdsl_element_t* V, 00438 const gdsl_perm_t P 00439 ); 00440 00441 /******************************************************************************/ 00442 /* Input/output functions of permutations */ 00443 /******************************************************************************/ 00444 00461 extern void 00462 gdsl_perm_write (const gdsl_perm_t P, 00463 const gdsl_write_func_t WRITE_F, 00464 FILE* OUTPUT_FILE, 00465 void* USER_DATA 00466 ); 00467 00486 extern void 00487 gdsl_perm_write_xml (const gdsl_perm_t P, 00488 const gdsl_write_func_t WRITE_F, 00489 FILE* OUTPUT_FILE, 00490 void* USER_DATA 00491 ); 00492 00510 extern void 00511 gdsl_perm_dump (const gdsl_perm_t P, 00512 const gdsl_write_func_t WRITE_F, 00513 FILE* OUTPUT_FILE, 00514 void* USER_DATA 00515 ); 00516 00522 #ifdef __cplusplus 00523 } 00524 #endif /* __cplusplus */ 00525 00526 00527 #endif /* _GDSL_PERM_H_ */ 00528 00529