Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions algorithms/matching/bfs_matching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
******************************************************************************/

#include "algorithms/matching/bfs_matching.hpp"
#include "sbg/natural.hpp"
#include "sbg/integer.hpp"
#include "util/logger.hpp"

namespace SBG {
Expand Down Expand Up @@ -73,17 +73,17 @@ PWMap BFSMatching::partitionSubsetEdges() const
PWMap result;
Set free_edges = _dsbg.E().difference(_M);
std::size_t arity = free_edges.arity();
NAT j = 1;
unsigned int j = 1;
PWMap Emap = _dsbg.Emap();
_dsbg.foreachSetEdge([&](const MD_NAT& SE)
_dsbg.foreachSetEdge([&](const IntTuple& SE)
{
Set domain_edges = Emap.preImage(Set{SE});

Expression matched_expr{MD_NAT{arity, j}};
Expression matched_expr{IntTuple{arity, j}};
result.emplace(_M.intersection(domain_edges), matched_expr);
++j;

Expression free_expr{MD_NAT{arity, j}};
Expression free_expr{IntTuple{arity, j}};
result.emplace(free_edges.intersection(domain_edges), free_expr);
++j;
});
Expand Down
6 changes: 3 additions & 3 deletions algorithms/mfvs/greedy_mfvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "algorithms/mfvs/greedy_mfvs.hpp"
#include "algorithms/scc/scc.hpp"
#include "sbg/natural.hpp"
#include "sbg/integer.hpp"
#include "sbg/pw_map.hpp"
#include "util/logger.hpp"

Expand All @@ -40,7 +40,7 @@ GreedyMFVS::GreedyMFVS() {}
/**
* @brief It calculates the minimum vertex with maximum degree.
*/
MD_NAT maxDegreeVertex(const DirectedSBG& dsbg)
IntTuple maxDegreeVertex(const DirectedSBG& dsbg)
{
Set V = dsbg.V();
PWMap mapB = dsbg.mapB();
Expand Down Expand Up @@ -76,7 +76,7 @@ Set GreedyMFVS::calculate(const DirectedSBG& input_dsbg) const
Set visitedSV;
while (rmap.fixedPoints() != rmap.domain()) {
// Get minimum vertex with maximum degree
MD_NAT max_degree_vertex = maxDegreeVertex(dsbg);
IntTuple max_degree_vertex = maxDegreeVertex(dsbg);
Set Vj{max_degree_vertex};
fvs_result = std::move(fvs_result).disjointCup(Vj);

Expand Down
8 changes: 4 additions & 4 deletions algorithms/mfvs/smallest_sv_mfvs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "algorithms/mfvs/smallest_sv_mfvs.hpp"
#include "algorithms/scc/scc.hpp"
#include "sbg/natural.hpp"
#include "sbg/integer.hpp"
#include "sbg/pw_map.hpp"
#include "util/logger.hpp"

Expand All @@ -45,11 +45,11 @@ SmallestSVMFVS::SmallestSVMFVS() {}
Set getVerticesFromSmallestSV(const PWMap& Vmap)
{
Set Vmap_image = Vmap.image();
NAT min_sz = Inf;
std::size_t min_sz = std::numeric_limits<std::size_t>::min();
Set remaining = Vmap_image;
while (!remaining.isEmpty()) {
Set jth_sv{remaining.minElem()};
NAT jth_sz = Vmap.preImage(jth_sv).cardinal();
std::size_t jth_sz = Vmap.preImage(jth_sv).cardinal();
if (jth_sz < min_sz) {
min_sz = jth_sz;
}
Expand All @@ -75,7 +75,7 @@ Set getVerticesFromSmallestSV(const PWMap& Vmap)
/**
* @brief It calculates the minimum vertex of maximum degree of V.
*/
MD_NAT getMaxDegreeVertex(const Set& V, const DirectedSBG& dsbg)
IntTuple getMaxDegreeVertex(const Set& V, const DirectedSBG& dsbg)
{
PWMap mapB = dsbg.mapB();
PWMap mapD = dsbg.mapD();
Expand Down
5 changes: 3 additions & 2 deletions algorithms/scc/minadj_mrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
******************************************************************************/

#include "algorithms/scc/minadj_mrv.hpp"
#include "sbg/integer.hpp"
#include "util/logger.hpp"

namespace SBG {
Expand Down Expand Up @@ -88,11 +89,11 @@ PWMap MinAdjMRV::calculate(const DirectedSBG& dsbg)
// Distance map
PWMap dmap;
Set ith = end;
NAT dist = 0;
unsigned int dist = 0;
// Calculate distance for vertices in same_rep that reach reps
for (; dmap.domain().intersection(Vc.intersection(VR)).isEmpty();) {
Set domain = ith.difference(dmap.domain());
Expression expr(MD_NAT{arity, dist});
Expression expr(IntTuple{arity, dist});
dmap.emplace(domain, expr);
// Update ith to vertices that have outgoing edges entering ith
ith = mapB.image(mapD.preImage(ith));
Expand Down
7 changes: 3 additions & 4 deletions algorithms/sorting/topological/min_vertex_ts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
******************************************************************************/

#include "algorithms/sorting/topological/min_vertex_ts.hpp"
#include "sbg/natural.hpp"
#include "util/debug.hpp"
#include "util/logger.hpp"

Expand Down Expand Up @@ -138,7 +137,7 @@ PWMap MinVertexTS::repetition(const Set& init_V, const DirectedSBG& dsbg)

// getVertex -------------------------------------------------------------------

MD_NAT MinVertexTS::getVertex()
IntTuple MinVertexTS::getVertex()
{
Set V = _dsbg.V();
PWMap mapD = _dsbg.mapD();
Expand Down Expand Up @@ -214,8 +213,8 @@ PWMap MinVertexTS::calculate(const DirectedSBG& dsbg

std::size_t arity = V.arity();
Expression successor_expr{arity, 1, 0};
MD_NAT vj;
MD_NAT old_vj = V.difference(_dsbg.mapD().image()).minElem();
IntTuple vj;
IntTuple old_vj = V.difference(_dsbg.mapD().image()).minElem();
_start = old_vj;
do {
// Find new vertex without dependencies, and add it to the sorting.
Expand Down
3 changes: 2 additions & 1 deletion algorithms/sorting/topological/min_vertex_ts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "sbg/directed_sbg.hpp"
#include "sbg/expression.hpp"
#include "sbg/integer.hpp"
#include "sbg/pw_map.hpp"
#include "sbg/set.hpp"

Expand Down Expand Up @@ -54,7 +55,7 @@ class MinVertexTS {
PWMap calculate(const DirectedSBG& dsbg, const PWMap& pmap);

private:
MD_NAT getVertex();
IntTuple getVertex();

/**
* @brief Identifies the "path" that leads to the repetition in _smap and
Expand Down
18 changes: 9 additions & 9 deletions ast/expr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@

******************************************************************************/

#ifndef PARSER_EXPR_AST_HPP
#define PARSER_EXPR_AST_HPP
#ifndef SBGRAPH_AST_EXPR_HPP_
#define SBGRAPH_AST_EXPR_HPP_

#include <iosfwd>
#include "sbg/integer.hpp"
#include "util/defs.hpp"

#include <boost/variant/variant.hpp>
#include <boost/variant/recursive_wrapper.hpp>
#include <boost/variant/variant.hpp>

#include "sbg/natural.hpp"
#include "util/defs.hpp"
#include <iosfwd>

namespace SBG {

Expand All @@ -39,7 +39,7 @@ namespace AST {
// Arithmetic and call structures ----------------------------------------------

using Name = std::string;
using Natural = LIB::NAT;
using Integer = LIB::Int;
struct Rational;
struct UnaryOp;
struct BinOp;
Expand All @@ -56,7 +56,7 @@ class BipartiteSBG;
struct DSBG;
struct ParenExpr;

using Expr = boost::variant<Natural, Name,
using Expr = boost::variant<Integer, Name,
boost::recursive_wrapper<Rational>,
boost::recursive_wrapper<UnaryOp>,
boost::recursive_wrapper<BinOp>,
Expand Down Expand Up @@ -303,4 +303,4 @@ std::ostream &operator<<(std::ostream &out, const ParenExpr &pe);

} // namespace SBG

#endif
#endif // SBGRAPH_AST_EXPR_HPP_
10 changes: 5 additions & 5 deletions ast/sbg_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ namespace SBG {

namespace AST {

SBGProgram::SBGProgram() : nmbr_dims_(1), stms_(), exprs_() {}
SBGProgram::SBGProgram(StatementList stms, ExprList exprs) : nmbr_dims_(1)
SBGProgram::SBGProgram() : arity_(1), stms_(), exprs_() {}
SBGProgram::SBGProgram(StatementList stms, ExprList exprs) : arity_(1)
, stms_(stms), exprs_(exprs) {}
SBGProgram::SBGProgram(LIB::NAT nmbr_dims, StatementList stms, ExprList exprs)
: nmbr_dims_(nmbr_dims), stms_(stms), exprs_(exprs) {}
SBGProgram::SBGProgram(std::size_t arity, StatementList stms, ExprList exprs)
: arity_(arity), stms_(stms), exprs_(exprs) {}

member_imp(SBGProgram, LIB::NAT, nmbr_dims);
member_imp(SBGProgram, std::size_t, arity);
member_imp(SBGProgram, StatementList, stms);
member_imp(SBGProgram, ExprList, exprs);

Expand Down
10 changes: 5 additions & 5 deletions ast/sbg_program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

******************************************************************************/

#ifndef PARSER_PROGRAM_AST_HPP
#define PARSER_PROGRAM_AST_HPP
#ifndef SBGRAPH_AST_SBG_PROGRAM_HPP_
#define SBGRAPH_AST_SBG_PROGRAM_HPP_

#include "ast/statement.hpp"

Expand All @@ -31,18 +31,18 @@ namespace SBG {
namespace AST {

struct SBGProgram {
member_class(LIB::NAT, nmbr_dims);
member_class(std::size_t, arity);
member_class(StatementList, stms);
member_class(ExprList, exprs);

SBGProgram();
SBGProgram(StatementList stms, ExprList exprs);
SBGProgram(LIB::NAT nmbr_dims, StatementList stms, ExprList exprs);
SBGProgram(std::size_t arity, StatementList stms, ExprList exprs);
};
std::ostream &operator<<(std::ostream &out, const SBGProgram &prog);

} // namespace AST

} // namespace SBG

#endif
#endif // SBGRAPH_AST_SBG_PROGRAM_HPP_
20 changes: 11 additions & 9 deletions ast/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,22 @@ std::ostream &operator<<(std::ostream &out, const Assign &asgn)
return out;
}

ConfigDims::ConfigDims() : nmbr_dims_() {}
ConfigDims::ConfigDims(LIB::NAT nmbr_dims) : nmbr_dims_() {
if (nmbr_dims > 0)
nmbr_dims_ = nmbr_dims;

else
Util::ERROR("ConfigDims: dimension should be greater than 0\n");
ConfigDims::ConfigDims() : arity_(0) {}
ConfigDims::ConfigDims(std::size_t arity) : arity_(arity) {
if (arity > 0) {
arity_ = arity;
}

else {
Util::ERROR("ConfigDims::ConfigDims: dimension should be greater than 0\n");
}
}

member_imp(ConfigDims, LIB::NAT, nmbr_dims);
member_imp(ConfigDims, std::size_t, arity);

std::ostream &operator<<(std::ostream &out, const ConfigDims &cfg)
{
out << "nmbr_dims = " << cfg.nmbr_dims();
out << "arity = " << cfg.arity();

return out;
}
Expand Down
10 changes: 5 additions & 5 deletions ast/statement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

******************************************************************************/

#ifndef PARSER_STATEMENT_AST_HPP
#define PARSER_STATEMENT_AST_HPP
#ifndef SBGRAPH_AST_STATEMENT_HPP_
#define SBGRAPH_AST_STATEMENT_HPP_

#include "ast/expr.hpp"
#include "util/debug.hpp"
Expand All @@ -41,10 +41,10 @@ struct Assign {
std::ostream &operator<<(std::ostream &out, const Assign &asgn);

struct ConfigDims {
member_class(LIB::NAT, nmbr_dims);
member_class(std::size_t, arity);

ConfigDims();
ConfigDims(LIB::NAT nmbr_dims);
ConfigDims(std::size_t arity);
};
std::ostream &operator<<(std::ostream &out, const ConfigDims &cfg);

Expand All @@ -64,4 +64,4 @@ std::ostream &operator<<(std::ostream &out, const StatementList &stm);

} // namespace SBG

#endif
#endif // SBGRAPH_AST_STATEMENT_HPP_
8 changes: 4 additions & 4 deletions eval/base_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include "sbg/bipartite_sbg.hpp"
#include "sbg/directed_sbg.hpp"
#include "sbg/expression.hpp"
#include "sbg/integer.hpp"
#include "sbg/map.hpp"
#include "sbg/natural.hpp"
#include "sbg/pw_map.hpp"
#include "sbg/rational.hpp"
#include "sbg/sbg.hpp"
Expand All @@ -45,9 +45,9 @@ namespace SBG {
namespace Eval {

using ExprBaseType = std::variant<bool
, LIB::NAT
, LIB::MD_NAT
, LIB::RATIONAL
, LIB::Int
, LIB::IntTuple
, LIB::Rational
, LIB::Set
, LIB::Expression
, LIB::Map
Expand Down
1 change: 0 additions & 1 deletion eval/visitors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ target_sources(
expr_evaluator.cpp
func_evaluator.cpp
int_evaluator.cpp
nat_evaluator.cpp
linear_expr_evaluator.cpp
program_evaluator.cpp
rational_evaluator.cpp
Expand Down
2 changes: 1 addition & 1 deletion eval/visitors/autom_impl_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ EvalUserInput AutomImplVisitor::visit(AST::SBGProgram p) const
if (!p.stms().empty()) {
AST::Statement first = p.stms()[0];
if (boost::apply_visitor(cfg_visit, first)) {
eval_context.setArity(boost::get<AST::ConfigDims>(first).nmbr_dims());
eval_context.setArity(boost::get<AST::ConfigDims>(first).arity());
}
}

Expand Down
14 changes: 7 additions & 7 deletions eval/visitors/expr_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

#include "eval/visitors/expr_evaluator.hpp"
#include "eval/visitors/func_evaluator.hpp"
#include "eval/visitors/int_evaluator.hpp"
#include "eval/visitors/linear_expr_evaluator.hpp"
#include "eval/visitors/nat_evaluator.hpp"
#include "eval/visitors/rational_evaluator.hpp"
#include "util/debug.hpp"

Expand Down Expand Up @@ -69,9 +69,9 @@ ExprEvaluator::ExprEvaluator(EvalContext& eval_ctx) : _eval_context(eval_ctx)
eval_ctx.insertFunction("sort", BuiltInFunctions::topoSortEvaluator);
}

ExprBaseType ExprEvaluator::operator()(AST::Natural v) const
ExprBaseType ExprEvaluator::operator()(AST::Integer v) const
{
return (LIB::NAT) v;
return (LIB::Int) v;
}

ExprBaseType ExprEvaluator::operator()(AST::Rational v) const
Expand Down Expand Up @@ -131,11 +131,11 @@ ExprBaseType ExprEvaluator::operator()(AST::Call v) const

ExprBaseType ExprEvaluator::operator()(AST::Interval v) const
{
NatEvaluator nat_evaluator{_eval_context.venv()};
IntEvaluator int_evaluator{_eval_context.venv()};

LIB::NAT b = boost::apply_visitor(nat_evaluator, v.begin());
LIB::NAT s = boost::apply_visitor(nat_evaluator, v.step());
LIB::NAT e = boost::apply_visitor(nat_evaluator, v.end());
LIB::Int b = boost::apply_visitor(int_evaluator, v.begin());
LIB::Int s = boost::apply_visitor(int_evaluator, v.step());
LIB::Int e = boost::apply_visitor(int_evaluator, v.end());

return LIB::Set{b, s, e};
}
Expand Down
Loading
Loading