diff --git a/sbg/info.cpp b/sbg/info.cpp deleted file mode 100755 index 951bd25..0000000 --- a/sbg/info.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - - This file is part of Set--Based Graph Library. - - SBG Library is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - SBG Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with SBG Library. If not, see . - - ******************************************************************************/ - -#include "sbg/info.hpp" - -namespace SBG { - -namespace LIB { - -DeclRanged::DeclRanged() : prefix_(), name_(), reps_() {} -DeclRanged::DeclRanged(std::string prefix, std::string name, SetPiece reps) - : prefix_(prefix), name_(name), reps_(reps) {} - -member_imp(DeclRanged, std::string, prefix); -member_imp(DeclRanged, std::string, name); -member_imp(DeclRanged, SetPiece, reps); - -std::ostream &operator<<(std::ostream &out, const DeclRanged &dr) -{ - out << dr.prefix() << " " << dr.name(); - - SetPiece mdi = dr.reps(); - unsigned int sz = mdi.size(); - if (sz > 0) { - out << "["; - unsigned int j = 0; - Interval i; - for (; j < sz - 1; ++j) { - i = mdi[j]; - out << mdi[j].cardinal() << ", "; - } - i = mdi[j]; - out << i.cardinal(); - out << "]"; - } - out << ";"; - - return out; -} - -std::ostream &operator<<(std::ostream &out, const DeclsRanged &ddr) -{ - for (DeclRanged dr : ddr) - out << dr << "\n"; - - return out; -} - -VertexInfo::VertexInfo() : decl_() {} -VertexInfo::VertexInfo(DeclRanged decl) : decl_(decl) {} - -member_imp(VertexInfo, DeclRanged, decl); - -std::ostream &operator<<(std::ostream &out, const VertexInfo &vi) -{ - out << vi.decl(); - - return out; -} - -std::ostream &operator<<(std::ostream &out, const VerticesInfo &vvi) -{ - for (VertexInfo vi : vvi) - out << vi << "\n"; - - return out; -} - -UseRanged::UseRanged() : prefix_(), name_(), subs_(), suffix_() {} -UseRanged::UseRanged(std::string prefix, std::string name, MDLExp subs, std::string suffix) - : prefix_(prefix), name_(name), subs_(subs), suffix_(suffix) {} - -member_imp(UseRanged, std::string, prefix); -member_imp(UseRanged, std::string, name); -member_imp(UseRanged, MDLExp, subs); -member_imp(UseRanged, std::string, suffix); - -std::ostream &operator<<(std::ostream &out, const UseRanged &ur) -{ - out << ur.prefix() << ur.name(); - - MDLExp mdle = ur.subs(); - unsigned int sz = mdle.size(); - if (sz > 0) { - out << "["; - unsigned int j = 0; - for (; j < sz - 1; ++j) out << mdle[j] << ", "; - out << mdle[j]; - out << "]"; - } - - out << ur.suffix(); - - return out; -} - -std::ostream &operator<<(std::ostream &out, const UsesRanged &uur) -{ - for (UseRanged ur : uur) - out << ur; - - return out; -} - -RangedExpr::RangedExpr() : range_(), expr_() {} -RangedExpr::RangedExpr(SetPiece range, UsesRanged expr) : range_(range), expr_(expr) {} - -member_imp(RangedExpr, SetPiece, range); -member_imp(RangedExpr, UsesRanged, expr); - -std::string iterators[7] = {"i", "j", "k", "l", "m", "n", "o"}; - -std::ostream &operator<<(std::ostream &out, const RangedExpr &re) -{ - SetPiece mdi = re.range(); - unsigned int sz = mdi.size(); - if (sz > 0) { - out << "for "; - - unsigned int j = 0; - for (; j < sz - 1; ++j) out << iterators[j] << " in " << mdi[j] << ", "; - out << iterators[j] << " in " << mdi[j]; - - out << " loop\n" << re.expr() << "\nend for;"; - } - - else out << re.expr(); - - return out; -} - -EdgeInfo::EdgeInfo() : expr_() {} -EdgeInfo::EdgeInfo(RangedExpr expr) : expr_(expr) {} - -member_imp(EdgeInfo, RangedExpr, expr); - -std::ostream &operator<<(std::ostream &out, const EdgeInfo &ei) -{ - out << ei.expr(); - - return out; -} - -std::ostream &operator<<(std::ostream &out, const EdgesInfo &eei) -{ - for (EdgeInfo ei : eei) - out << ei << "\n"; - - return out; -} - -} // namespace LIB - -} // namespace SBG diff --git a/sbg/info.hpp b/sbg/info.hpp deleted file mode 100755 index 4c89b30..0000000 --- a/sbg/info.hpp +++ /dev/null @@ -1,127 +0,0 @@ -/** @file info.hpp - - @brief SBG information structures - - These structures were designed to keep information about variable names and - equations definitions in the ModelicaCC context. In sense, they are an - interface between Modelica code and the SBG representation. They store - information to print Modelica-like code after each flatter/causalization - stage in which an SBG is used. - -
- - This file is part of Set--Based Graph Library. - - SBG Library is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - SBG Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with SBG Library. If not, see . - - ******************************************************************************/ - -#ifndef SBG_INFO_HPP -#define SBG_INFO_HPP - -#include -#include - -namespace SBG { - -namespace LIB { - -/** @struct DeclRanged - * - * @brief DeclRanged is used to represent the declaration of an array of - * objects. - * - * In the Modelica context, the declaration of Real a[100] will result in the - * creation of interval [700:799], so there will be a VertexInfo vi with a - * DeclRanged dr such that dr.prefix = "Real", dr.name = "a", - * dr.reps = [700:799]. - */ - -struct DeclRanged { - member_class(std::string, prefix); - member_class(std::string, name); - member_class(SetPiece, reps); - - DeclRanged(); - DeclRanged(std::string prefix, std::string name, SetPiece reps); -}; -std::ostream &operator<<(std::ostream &out, const DeclRanged &rd); - -typedef std::vector DeclsRanged; -std::ostream &operator<<(std::ostream &out, const DeclsRanged &rd); - -struct VertexInfo { - member_class(DeclRanged, decl); - - VertexInfo(); - VertexInfo(DeclRanged decl); -}; -std::ostream &operator<<(std::ostream &out, const VertexInfo &vi); - -typedef std::vector VerticesInfo; -std::ostream &operator<<(std::ostream &out, const VerticesInfo &vvi); - -/** @struct UseRanged - * - * @brief UseRanged should keep info about the use of an array of variables. - * The trail member is used to specify any possible code between two - * consecutive arrays. - * - * For example, when the array "a" is used by a loop: - * for i [5:5:50] loop - * a[i] = b[i]; - * end for; - * the corresponding UseRanged ur will be such that ur.prefix = "", - * ur.name = "a", ur.subs = 1*x+0, ur.suffix = " = " - */ - -struct UseRanged { - member_class(std::string, prefix); - member_class(std::string, name); - member_class(MDLExp, subs); - member_class(std::string, suffix); - - UseRanged(); - UseRanged(std::string prefix, std::string name, MDLExp subs, std::string suffix); -}; -std::ostream &operator<<(std::ostream &out, const UseRanged &rd); - -typedef std::vector UsesRanged; -std::ostream &operator<<(std::ostream &out, const UsesRanged &uur); - -struct RangedExpr { - member_class(SetPiece, range); - member_class(UsesRanged, expr); - - RangedExpr(); - RangedExpr(SetPiece range, UsesRanged expr); -}; -std::ostream &operator<<(std::ostream &out, const RangedExpr &re); - -struct EdgeInfo { - member_class(RangedExpr, expr); - - EdgeInfo(); - EdgeInfo(RangedExpr expr); -}; -std::ostream &operator<<(std::ostream &out, const EdgeInfo &ri); - -typedef std::vector EdgesInfo; -std::ostream &operator<<(std::ostream &out, const EdgesInfo &eei); - -} // namespace LIB - -} // namespace SBG - -#endif diff --git a/sbg/sbg_algorithms.cpp b/sbg/sbg_algorithms.cpp index dcd62c6..fa43856 100644 --- a/sbg/sbg_algorithms.cpp +++ b/sbg/sbg_algorithms.cpp @@ -703,7 +703,7 @@ Exp SBGTopSort::calculateExp(Util::MD_NAT from, Util::MD_NAT to) Exp res; Util::RATIONAL one(1, 1); - for (unsigned int j = 0; j < from.arity(); ++j) { + for (unsigned int j = 0; j < from.size(); ++j) { Util::RATIONAL r_from(from[j]), r_to(to[j]); res.emplaceBack(LExp(1, r_to - r_from)); } diff --git a/sbg/sbg_algorithms.hpp b/sbg/sbg_algorithms.hpp old mode 100755 new mode 100644 index 642a26a..6c55be8 --- a/sbg/sbg_algorithms.hpp +++ b/sbg/sbg_algorithms.hpp @@ -176,24 +176,13 @@ typedef SBGSCC CanonSCC; template struct SBGTopSort { + using Map = SBGMap; using PW = PWMap; //*** SBG info, constant member_class(DSBGraph, dsbg); //----------------------------- - member_class(PW, smap); - - member_class(Set, E); - member_class(PW, mapB); - member_class(PW, mapD); - - member_class(Set, unordered); - member_class(Set, not_dependent); - member_class(Set, visitedV); - - member_class(Util::MD_NAT, curr); - member_class(bool, debug); SBGTopSort(); @@ -202,9 +191,7 @@ struct SBGTopSort { PW calculate(); private: - Exp calculateExp(Util::MD_NAT x1, Util::MD_NAT x2); - void topSortStep(); - void updateStatus(Set dom, Exp exp, Set ingoing); + Exp calculateExp(Util::MD_NAT from, Util::MD_NAT to); }; typedef SBGTopSort BaseTopSort;