gdsl  1.8
gdsl_perm.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of the Generic Data Structures Library (GDSL).
00003  * Copyright (C) 1998-2018 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 
00019 /*
00020  * GDSL - Generic Data Structures Library
00021  * $RCSfile: gdsl_perm.h,v $
00022  * $Revision: 1.23 $
00023  * $Date: 2015/02/17 12:22:57 $
00024  */
00025 
00026 
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 
00051 typedef struct gdsl_perm* gdsl_perm_t;
00052 
00056 typedef enum
00057 {
00059     GDSL_PERM_POSITION_FIRST = 1,
00060 
00062     GDSL_PERM_POSITION_LAST = 2
00063 
00064 } gdsl_perm_position_t;
00065 
00074 typedef void (* gdsl_perm_write_func_t) 
00075     (ulong E,
00076      FILE* OUTPUT_FILE,
00077      gdsl_location_t POSITION,
00078      void* USER_DATA
00079      );
00080 
00081 typedef struct gdsl_perm_data* gdsl_perm_data_t;
00082 
00083 /******************************************************************************/
00084 /* Management functions of permutations                                       */
00085 /******************************************************************************/
00086 
00103 extern gdsl_perm_t
00104 gdsl_perm_alloc (const char* NAME,
00105          const ulong N
00106          );
00107 
00119 extern void
00120 gdsl_perm_free (gdsl_perm_t P
00121         );
00122 
00137 extern gdsl_perm_t
00138 gdsl_perm_copy (const gdsl_perm_t P
00139         );
00140 
00141 /******************************************************************************/
00142 /* Consultation functions of permutations                                     */
00143 /******************************************************************************/
00144 
00154 extern const char*
00155 gdsl_perm_get_name (const gdsl_perm_t P
00156             );
00157 
00167 extern ulong
00168 gdsl_perm_get_size (const gdsl_perm_t P
00169             );
00170 
00181 extern ulong
00182 gdsl_perm_get_element (const gdsl_perm_t P,
00183                const ulong INDIX
00184                );
00185 
00195 extern ulong*
00196 gdsl_perm_get_elements_array (const gdsl_perm_t P
00197                   );
00198 
00206 extern ulong
00207 gdsl_perm_linear_inversions_count (const gdsl_perm_t P
00208                    );
00209 
00218 extern ulong
00219 gdsl_perm_linear_cycles_count (const gdsl_perm_t P
00220                    );
00221 
00230 extern ulong
00231 gdsl_perm_canonical_cycles_count (const gdsl_perm_t P
00232                   );
00233 
00234 /******************************************************************************/
00235 /* Modification functions of permutations                                     */
00236 /******************************************************************************/
00237 
00251 extern gdsl_perm_t
00252 gdsl_perm_set_name (gdsl_perm_t P,
00253             const char* NEW_NAME
00254             );
00255 
00268 extern gdsl_perm_t
00269 gdsl_perm_linear_next (gdsl_perm_t P
00270                );
00271 
00284 extern gdsl_perm_t
00285 gdsl_perm_linear_prev (gdsl_perm_t P
00286                );
00287 
00303 extern gdsl_perm_t
00304 gdsl_perm_set_elements_array (gdsl_perm_t P,
00305                   const ulong* ARRAY
00306                   );
00307 
00308 /******************************************************************************/
00309 /* Operations functions of permutations                                       */
00310 /******************************************************************************/
00311 
00326 extern gdsl_perm_t
00327 gdsl_perm_multiply (gdsl_perm_t RESULT,
00328             const gdsl_perm_t ALPHA,
00329             const gdsl_perm_t BETA
00330             );
00331   
00345 extern gdsl_perm_t
00346 gdsl_perm_linear_to_canonical (gdsl_perm_t Q,
00347                    const gdsl_perm_t P
00348                    );
00349 
00363 extern gdsl_perm_t
00364 gdsl_perm_canonical_to_linear (gdsl_perm_t Q,
00365                    const gdsl_perm_t P
00366                    );
00367 
00377 extern gdsl_perm_t
00378 gdsl_perm_inverse (gdsl_perm_t P
00379            );
00380 
00389 extern gdsl_perm_t
00390 gdsl_perm_reverse (gdsl_perm_t P
00391            );
00392 
00404 extern gdsl_perm_t
00405 gdsl_perm_randomize (gdsl_perm_t P
00406              );
00407 
00418 extern gdsl_element_t*
00419 gdsl_perm_apply_on_array (gdsl_element_t* V,
00420               const gdsl_perm_t P
00421               );
00422 
00423 /******************************************************************************/
00424 /* Input/output functions of permutations                                     */
00425 /******************************************************************************/
00426 
00443 extern void
00444 gdsl_perm_write (const gdsl_perm_t P,
00445          const gdsl_write_func_t WRITE_F,
00446          FILE* OUTPUT_FILE,
00447          void* USER_DATA
00448          );
00449 
00468 extern void
00469 gdsl_perm_write_xml (const gdsl_perm_t P,
00470              const gdsl_write_func_t WRITE_F,
00471              FILE* OUTPUT_FILE,
00472              void* USER_DATA
00473              );
00474 
00492 extern void
00493 gdsl_perm_dump (const gdsl_perm_t P,
00494         const gdsl_write_func_t WRITE_F,
00495         FILE* OUTPUT_FILE,
00496         void* USER_DATA
00497         );
00498 
00504 #ifdef __cplusplus
00505 }
00506 #endif /* __cplusplus */
00507 
00508 
00509 #endif /* _GDSL_PERM_H_ */
00510 
00511