CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418384
1
/*
2
* Normaliz
3
* Copyright (C) 2007-2014 Winfried Bruns, Bogdan Ichim, Christof Soeger
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*
17
* As an exception, when this program is distributed through (i) the App Store
18
* by Apple Inc.; (ii) the Mac App Store by Apple Inc.; or (iii) Google Play
19
* by Google Inc., then that store may impose any digital rights management,
20
* device limits and/or redistribution restrictions that are required by its
21
* terms of service.
22
*/
23
24
#ifdef NMZ_MIC_OFFLOAD
25
#pragma offload_attribute (push, target(mic))
26
#endif
27
28
#include "libQnormaliz/Qcone_helper.h"
29
#include <vector>
30
31
namespace libQnormaliz {
32
using std::vector;
33
34
//---------------------------------------------------------------------------
35
36
// determines the maximal subsets in a vector of subsets given by their indicator vectors
37
// result returned in is_max_subset -- must be initialized outside
38
// only set to false in this routine
39
// if a set occurs more than once, only the last instance is recognized as maximal
40
void maximal_subsets(const vector<vector<bool> >& ind, vector<bool>& is_max_subset) {
41
42
if(ind.size()==0)
43
return;
44
45
size_t nr_sets=ind.size();
46
size_t card=ind[0].size();
47
vector<key_t> elem(card);
48
49
for (size_t i = 0; i <nr_sets; i++) {
50
if(!is_max_subset[i]) // already known to be non-maximal
51
continue;
52
53
size_t k=0; // counts the number of elements in set with index i
54
for (size_t j = 0; j <card; j++) {
55
if (ind[i][j]) {
56
elem[k]=j;
57
k++;
58
}
59
}
60
61
for (size_t j = 0; j <nr_sets; j++) {
62
if (i==j || !is_max_subset[j] ) // don't compare with itself or something known not to be maximal
63
continue;
64
size_t t;
65
for (t = 0; t<k; t++) {
66
if (!ind[j][elem[t]])
67
break; // not a superset
68
}
69
if (t==k) { // found a superset
70
is_max_subset[i]=false;
71
break; // the loop over j
72
}
73
}
74
}
75
}
76
77
//---------------------------------------------------------------------------
78
79
#ifdef NMZ_MIC_OFFLOAD
80
#pragma offload_attribute (pop)
81
#endif
82
83
} //end namespace libQnormaliz
84
85