Skip to content

Commit 411b3ac

Browse files
committed
Reformatting
1 parent 4ed2c2c commit 411b3ac

File tree

6 files changed

+42
-55
lines changed

6 files changed

+42
-55
lines changed

Diff for: lib/coek/coek/compact/data_map.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DataMapRepn : public DataAssocArrayRepn {
2727

2828
DataMapRepn(const SequenceContext& _arg) : context(_arg), index_sequence(context)
2929
{
30-
index_set = context.index_set();
30+
index_set = context.index_set();
3131
#ifdef CUSTOM_INDEXVECTOR
3232
cache.resize((size() + 1) * (dim() + 1));
3333
#endif
@@ -50,7 +50,7 @@ void DataMapRepn::expand()
5050
{
5151
if (first_expand) {
5252
first_expand = false;
53-
//DataAssocArrayRepn::expand();
53+
// DataAssocArrayRepn::expand();
5454

5555
size_t _dim = dim();
5656
IndexVector x(_dim);
@@ -68,9 +68,9 @@ void DataMapRepn::expand()
6868
vec[j].get_value(x[j]);
6969
index_map[x] = i++;
7070
++it;
71-
}
72-
assert(index_map.size() == index_set.size());
7371
}
72+
assert(index_map.size() == index_set.size());
73+
}
7474
}
7575

7676
//

Diff for: lib/coek/coek/compact/index_sequence.cpp

+16-34
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "coek/compact/coek_exprterm.hpp"
66
#include "coek_sets.hpp"
77
#include "sequence_context.hpp"
8-
//#include "visitor_exprtemplate.hpp"
8+
// #include "visitor_exprtemplate.hpp"
99

1010
namespace coek {
1111

@@ -18,7 +18,7 @@ class IndexSequenceRepn {
1818
SequenceContext context;
1919

2020
public:
21-
IndexSequenceRepn(const SequenceContext& context_) : context(context_) { }
21+
IndexSequenceRepn(const SequenceContext& context_) : context(context_) {}
2222
};
2323

2424
//
@@ -30,7 +30,7 @@ class IndexSeqIteratorRepn {
3030
IndexSequenceRepn* seq;
3131
std::vector<SetIterator> context_iter;
3232
size_t ncontexts;
33-
//Index converted_expr;
33+
// Index converted_expr;
3434
std::vector<IndexParameter> indices;
3535
bool done;
3636

@@ -45,12 +45,12 @@ class IndexSeqIteratorRepn {
4545
done = end;
4646
if (!done) {
4747
// Collect indices
48-
for (auto& context: seq->context.repn->context) {
49-
for (auto& iparam: context.indices)
48+
for (auto& context : seq->context.repn->context) {
49+
for (auto& iparam : context.indices)
5050
indices.push_back(iparam);
5151
}
52-
//std::cout << "HERE " << indices.size() << std::endl;
53-
//std::cout << "HERE " << _seq->context.repn->dim << std::endl;
52+
// std::cout << "HERE " << indices.size() << std::endl;
53+
// std::cout << "HERE " << _seq->context.repn->dim << std::endl;
5454
assert(indices.size() == _seq->context.repn->dim);
5555

5656
// Setup context iters
@@ -62,7 +62,7 @@ class IndexSeqIteratorRepn {
6262
Context& curr = seq->context[i];
6363
*it = curr.index_set.begin(curr.indices);
6464
}
65-
//converted_expr = convert_expr_template(seq->expression_template.repn);
65+
// converted_expr = convert_expr_template(seq->expression_template.repn);
6666
}
6767
ncontexts = context_iter.size();
6868
}
@@ -82,8 +82,8 @@ class IndexSeqIteratorRepn {
8282
}
8383
if (i_ == ncontexts)
8484
done = true;
85-
//else
86-
// converted_expr = convert_expr_template(seq->expression_template.repn);
85+
// else
86+
// converted_expr = convert_expr_template(seq->expression_template.repn);
8787
}
8888

8989
bool operator==(const IndexSeqIteratorRepn* other) const
@@ -144,46 +144,28 @@ bool IndexSeqIterator::operator!=(const IndexSeqIterator& other) const
144144

145145
IndexSeqIterator::reference IndexSeqIterator::operator*() { return repn->operator*(); }
146146

147-
IndexSeqIterator::const_reference IndexSeqIterator::operator*() const
148-
{
149-
return repn->operator*();
150-
}
147+
IndexSeqIterator::const_reference IndexSeqIterator::operator*() const { return repn->operator*(); }
151148

152149
IndexSeqIterator::pointer IndexSeqIterator::operator->() { return repn->operator->(); }
153150

154-
IndexSeqIterator::const_pointer IndexSeqIterator::operator->() const
155-
{
156-
return repn->operator->();
157-
}
151+
IndexSeqIterator::const_pointer IndexSeqIterator::operator->() const { return repn->operator->(); }
158152

159153
//
160154
// IndexSequence
161155
//
162-
IndexSequence::IndexSequence(const std::shared_ptr<IndexSequenceRepn>& _repn)
163-
: repn(_repn)
164-
{
165-
}
156+
IndexSequence::IndexSequence(const std::shared_ptr<IndexSequenceRepn>& _repn) : repn(_repn) {}
166157

167158
IndexSequence::IndexSequence(const SequenceContext& context_)
168159
{
169160
repn = std::make_shared<IndexSequenceRepn>(context_);
170161
}
171162

172-
IndexSeqIterator IndexSequence::begin()
173-
{
174-
return IndexSeqIterator(repn.get(), false);
175-
}
163+
IndexSeqIterator IndexSequence::begin() { return IndexSeqIterator(repn.get(), false); }
176164

177165
IndexSeqIterator IndexSequence::end() { return IndexSeqIterator(repn.get(), true); }
178166

179-
const IndexSeqIterator IndexSequence::begin() const
180-
{
181-
return IndexSeqIterator(repn.get(), false);
182-
}
167+
const IndexSeqIterator IndexSequence::begin() const { return IndexSeqIterator(repn.get(), false); }
183168

184-
const IndexSeqIterator IndexSequence::end() const
185-
{
186-
return IndexSeqIterator(repn.get(), true);
187-
}
169+
const IndexSeqIterator IndexSequence::end() const { return IndexSeqIterator(repn.get(), true); }
188170

189171
} // namespace coek

Diff for: lib/coek/coek/compact/parameter_map.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ class ParameterMapRepn : public ParameterAssocArrayRepn {
1919
bool names_generated = false;
2020

2121
public:
22-
ParameterMapRepn(const ConcreteSet& _arg) : context(_arg), index_set(_arg), index_sequence(context)
22+
ParameterMapRepn(const ConcreteSet& _arg)
23+
: context(_arg), index_set(_arg), index_sequence(context)
2324
{
2425
#ifdef CUSTOM_INDEXVECTOR
2526
cache.resize((size() + 1) * (dim() + 1));
2627
#endif
2728
}
2829

29-
//ParameterMapRepn(const SequenceContext& _arg) : concrete_set(_arg.index_set())
30+
// ParameterMapRepn(const SequenceContext& _arg) : concrete_set(_arg.index_set())
3031
ParameterMapRepn(const SequenceContext& _arg) : context(_arg), index_sequence(context)
3132
{
3233
index_set = context.index_set();
@@ -92,7 +93,7 @@ void ParameterMapRepn::expand()
9293
{
9394
if (first_expand) {
9495
first_expand = false;
95-
//ParameterAssocArrayRepn::expand();
96+
// ParameterAssocArrayRepn::expand();
9697

9798
size_t _dim = dim();
9899
IndexVector x(_dim);
@@ -102,15 +103,16 @@ void ParameterMapRepn::expand()
102103
auto end = index_sequence.end();
103104
while (it != end) {
104105
auto expr = value_template.value_expression().expand();
105-
values.emplace_back(CREATE_POINTER(ParameterTerm, CREATE_POINTER(ConstantTerm, expr.value())));
106+
values.emplace_back(
107+
CREATE_POINTER(ParameterTerm, CREATE_POINTER(ConstantTerm, expr.value())));
106108

107109
auto& vec = *it;
108110
assert(vec.size() == _dim);
109111
for (size_t j = 0; j < _dim; j++)
110112
vec[j].get_value(x[j]);
111113
index_map[x] = i++;
112114
++it;
113-
}
115+
}
114116
assert(index_map.size() == index_set.size());
115117
}
116118
}

Diff for: lib/coek/coek/compact/sequence_context.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ SequenceContext::SequenceContext(const ConcreteSet& _index_set)
2525
repn = std::make_shared<SequenceContextRepn>();
2626
std::vector<IndexParameter> indices;
2727
ConcreteSet tmp = _index_set;
28-
for (size_t i=0; i<tmp.dim(); ++i) {
29-
std::string name = "_i"+std::to_string(repn->dim+i);
30-
indices.emplace_back( set_element(name) );
31-
}
28+
for (size_t i = 0; i < tmp.dim(); ++i) {
29+
std::string name = "_i" + std::to_string(repn->dim + i);
30+
indices.emplace_back(set_element(name));
31+
}
3232
repn->context.emplace_back(indices);
3333
Context& curr = repn->context.back();
3434
curr.index_set = tmp;

Diff for: lib/coek/coek/compact/sequence_context.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ class Context {
4242
class SequenceContextRepn {
4343
public:
4444
std::vector<Context> context;
45-
size_t dim=0;
45+
size_t dim = 0;
4646
};
4747

48-
4948
class SequenceContext {
5049
public:
5150
std::shared_ptr<SequenceContextRepn> repn;

Diff for: lib/coek/coek/compact/variable_map.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class VariableMapRepn : public VariableAssocArrayRepn {
2424
std::unordered_map<IndexVector, size_t> index_map;
2525

2626
public:
27-
VariableMapRepn(const ConcreteSet& _arg) : context(_arg), index_set(_arg), index_sequence(context)
27+
VariableMapRepn(const ConcreteSet& _arg)
28+
: context(_arg), index_set(_arg), index_sequence(context)
2829
{
2930
#ifdef CUSTOM_INDEXVECTOR
3031
cache.resize((size() + 1) * (dim() + 1));
@@ -96,7 +97,7 @@ void VariableMapRepn::expand()
9697
{
9798
if (first_expand) {
9899
first_expand = false;
99-
//VariableAssocArrayRepn::expand();
100+
// VariableAssocArrayRepn::expand();
100101

101102
size_t _dim = dim();
102103
IndexVector x(_dim);
@@ -108,9 +109,12 @@ void VariableMapRepn::expand()
108109
auto vtype = value_template.within();
109110
bool binary = (vtype == Boolean) or (vtype == Binary);
110111
bool integer = vtype == Integers;
111-
auto lower = std::make_shared<ConstantTerm>(value_template.lower_expression().expand().value());
112-
auto upper = std::make_shared<ConstantTerm>(value_template.upper_expression().expand().value());
113-
auto value = std::make_shared<ConstantTerm>(value_template.value_expression().expand().value());
112+
auto lower = std::make_shared<ConstantTerm>(
113+
value_template.lower_expression().expand().value());
114+
auto upper = std::make_shared<ConstantTerm>(
115+
value_template.upper_expression().expand().value());
116+
auto value = std::make_shared<ConstantTerm>(
117+
value_template.value_expression().expand().value());
114118
values.emplace_back(CREATE_POINTER(VariableTerm, lower, upper, value, binary, integer));
115119

116120
auto& vec = *it;
@@ -119,7 +123,7 @@ void VariableMapRepn::expand()
119123
vec[j].get_value(x[j]);
120124
index_map[x] = i++;
121125
++it;
122-
}
126+
}
123127
assert(index_map.size() == index_set.size());
124128
}
125129
}

0 commit comments

Comments
 (0)