gdsl
1.8
|
00001 /* 00002 * This file is part of the Generic Data Structures Library (GDSL). 00003 * Copyright (C) 1998-2015 Nicolas Darnis <ndarnis@free.fr>. 00004 * 00005 * The GDSL library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License as 00007 * published by the Free Software Foundation; either version 2 of 00008 * the License, or (at your option) any later version. 00009 * 00010 * The GDSL library 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 the GDSL library; see the file COPYING. 00017 * If not, write to the Free Software Foundation, Inc., 00018 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 00019 * 00020 * $RCSfile: gdsl_perm.h,v $ 00021 * $Revision: 1.23 $ 00022 * $Date: 2015/02/17 12:22:57 $ 00023 */ 00024 00029 #ifndef _GDSL_PERM_H_ 00030 #define _GDSL_PERM_H_ 00031 00032 00033 #include "gdsl_types.h" 00034 00035 00036 #ifdef __cplusplus 00037 extern "C" 00038 { 00039 #endif /* __cplusplus */ 00040 00041 00053 typedef struct gdsl_perm* gdsl_perm_t; 00054 00058 typedef enum 00059 { 00061 GDSL_PERM_POSITION_FIRST = 1, 00062 00064 GDSL_PERM_POSITION_LAST = 2 00065 00066 } gdsl_perm_position_t; 00067 00076 typedef void (* gdsl_perm_write_func_t) 00077 (ulong E, 00078 FILE* OUTPUT_FILE, 00079 gdsl_location_t POSITION, 00080 void* USER_DATA 00081 ); 00082 00083 typedef struct gdsl_perm_data* gdsl_perm_data_t; 00084 00085 /******************************************************************************/ 00086 /* Management functions of permutations */ 00087 /******************************************************************************/ 00088 00105 extern gdsl_perm_t 00106 gdsl_perm_alloc (const char* NAME, 00107 const ulong N 00108 ); 00109 00121 extern void 00122 gdsl_perm_free (gdsl_perm_t P 00123 ); 00124 00139 extern gdsl_perm_t 00140 gdsl_perm_copy (const gdsl_perm_t P 00141 ); 00142 00143 /******************************************************************************/ 00144 /* Consultation functions of permutations */ 00145 /******************************************************************************/ 00146 00156 extern const char* 00157 gdsl_perm_get_name (const gdsl_perm_t P 00158 ); 00159 00169 extern ulong 00170 gdsl_perm_get_size (const gdsl_perm_t P 00171 ); 00172 00183 extern ulong 00184 gdsl_perm_get_element (const gdsl_perm_t P, 00185 const ulong INDIX 00186 ); 00187 00197 extern ulong* 00198 gdsl_perm_get_elements_array (const gdsl_perm_t P 00199 ); 00200 00208 extern ulong 00209 gdsl_perm_linear_inversions_count (const gdsl_perm_t P 00210 ); 00211 00220 extern ulong 00221 gdsl_perm_linear_cycles_count (const gdsl_perm_t P 00222 ); 00223 00232 extern ulong 00233 gdsl_perm_canonical_cycles_count (const gdsl_perm_t P 00234 ); 00235 00236 /******************************************************************************/ 00237 /* Modification functions of permutations */ 00238 /******************************************************************************/ 00239 00253 extern gdsl_perm_t 00254 gdsl_perm_set_name (gdsl_perm_t P, 00255 const char* NEW_NAME 00256 ); 00257 00270 extern gdsl_perm_t 00271 gdsl_perm_linear_next (gdsl_perm_t P 00272 ); 00273 00286 extern gdsl_perm_t 00287 gdsl_perm_linear_prev (gdsl_perm_t P 00288 ); 00289 00305 extern gdsl_perm_t 00306 gdsl_perm_set_elements_array (gdsl_perm_t P, 00307 const ulong* ARRAY 00308 ); 00309 00310 /******************************************************************************/ 00311 /* Operations functions of permutations */ 00312 /******************************************************************************/ 00313 00328 extern gdsl_perm_t 00329 gdsl_perm_multiply (gdsl_perm_t RESULT, 00330 const gdsl_perm_t ALPHA, 00331 const gdsl_perm_t BETA 00332 ); 00333 00347 extern gdsl_perm_t 00348 gdsl_perm_linear_to_canonical (gdsl_perm_t Q, 00349 const gdsl_perm_t P 00350 ); 00351 00365 extern gdsl_perm_t 00366 gdsl_perm_canonical_to_linear (gdsl_perm_t Q, 00367 const gdsl_perm_t P 00368 ); 00369 00379 extern gdsl_perm_t 00380 gdsl_perm_inverse (gdsl_perm_t P 00381 ); 00382 00391 extern gdsl_perm_t 00392 gdsl_perm_reverse (gdsl_perm_t P 00393 ); 00394 00406 extern gdsl_perm_t 00407 gdsl_perm_randomize (gdsl_perm_t P 00408 ); 00409 00420 extern gdsl_element_t* 00421 gdsl_perm_apply_on_array (gdsl_element_t* V, 00422 const gdsl_perm_t P 00423 ); 00424 00425 /******************************************************************************/ 00426 /* Input/output functions of permutations */ 00427 /******************************************************************************/ 00428 00445 extern void 00446 gdsl_perm_write (const gdsl_perm_t P, 00447 const gdsl_write_func_t WRITE_F, 00448 FILE* OUTPUT_FILE, 00449 void* USER_DATA 00450 ); 00451 00470 extern void 00471 gdsl_perm_write_xml (const gdsl_perm_t P, 00472 const gdsl_write_func_t WRITE_F, 00473 FILE* OUTPUT_FILE, 00474 void* USER_DATA 00475 ); 00476 00494 extern void 00495 gdsl_perm_dump (const gdsl_perm_t P, 00496 const gdsl_write_func_t WRITE_F, 00497 FILE* OUTPUT_FILE, 00498 void* USER_DATA 00499 ); 00500 00501 /* 00502 * @} 00503 */ 00504 00505 00506 #ifdef __cplusplus 00507 } 00508 #endif /* __cplusplus */ 00509 00510 00511 #endif /* _GDSL_PERM_H_ */ 00512 00513