INGOR
Loading...
Searching...
No Matches
ytCombo.h
1/*
2 Combo.{h,c} : Combination functions.
3 Copyright (C) 2016, Yoshinori Tamada <tamada A T ytlab.jp>
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12
13 * Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in
15 the documentation and/or other materials provided with the
16 distribution.
17
18 * Neither the name of The University of Tokyo nor the names of its
19 contributors may be used to endorse or promote products derived
20 from this software without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 POSSIBILITY OF SUCH DAMAGE.
34*/
35#ifndef __YTLIB_COMBO_H
36#define __YTLIB_COMBO_H
37#include <stdint.h>
38#include <stdio.h>
39
40uint64_t ytCombo_choose(int n, int k);
41int ytCombo_generate(int n, int k, int * ar);
42void ytCombo_indexTable(int n, uint64_t * table);
43uint64_t ytCombo_chooseTable(int n, int k, const uint64_t * table, int tn);
44uint64_t ytCombo_index(int n, int c, const int * ar, const uint64_t * table, int tn);
45uint64_t ytCombo_index2(int n, int c, const int * ar, const int * a, const uint64_t * table, int tn);
46uint64_t ytCombo_index3(int n, int c, const int * ar, const int * a, const int * b, const uint64_t * table, int tn);
47void ytCombo_combination(int n, int c, uint64_t index, int * ar,
48 const uint64_t * table, int tn);
49void ytCombo_combination2(int n, int k, uint64_t index, int * ar, const int * a,
50 const uint64_t *table, int tn);
51void ytCombo_combination3(int n, int k, uint64_t index, int * ar,
52 const int * a, const int * b,
53 const uint64_t * table, int tn);
54
55void ytCombo_print(FILE * fp, size_t n, const int * A);
56void ytCombo_print2(FILE * fp, size_t n, const int * A, const int * B);
57
58void ytCombo_bitNext(uint64_t * bit);
59void ytCombo_bit(int n, int k, uint64_t index, uint64_t * bit,
60 const uint64_t * table, int tn);
61
62void ytCombo_bitCombo2(int n, int k, uint64_t index,
63 uint64_t * bit, int * A, const int * a,
64 const uint64_t * table, int tn);
65
66void ytCombo_printBitCombo(FILE * fp, uint64_t bit, int n);
67
68
69void ytCombo_test(FILE * fp);
70
71#endif /* __YTLIB_COMBO_H */
72/* End of file. */