📄 continuous_item.cc
字号:
/* HYSDEL Copyright (C) 1999-2002 Fabio D. Torrisi This file is part of HYSDEL. HYSDEL 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 2 of the License, or (at your option) any later version. HYSDEL 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 this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA CONTACT INFORMATION =================== Fabio D. Torrisi ETH Zentrum Physikstrasse. 3 ETL, CH-8032 Zurich Switzerland mailto:torrisi@aut.ee.ethz.ch (preferred)*/#include "Continuous_item.h"#include "Var_symbol.h"#include "Expr.h"#include "Affine_func.h"#include "Symbol_table.h"#include "MLD_representation.h"#include "Cmd_options.h"#include "Linear_item.h"#include <stdio.h>#include "Globals.h"#include "Problem.h"#include "Problem_handler.h"Continuous_item::Continuous_item(const Var_symbol * lhs, Expr * e, const Globals * glob) : Definition_item(lhs, glob) { affine_expr = e;}list < const Var_symbol * > Continuous_item::get_required_mme() const { list < const Var_symbol * > req; add_required(req, affine_expr); return req;}list < const Var_symbol * > Continuous_item::get_required_simu() const { return get_required_mme();}Continuous_item::~Continuous_item() { delete affine_expr; this->Definition_item::~Definition_item();}list < Item * > Continuous_item::unroll() { Expr * lin_expr; Item * cnst_item = NULL; list < Item * > res; list < Item * >::iterator iter; if (globals->cmd_options->consts_in_eq_as_auxvar()) { cnst_item = extract_const_from_aff(affine_expr, & lin_expr); delete affine_expr; affine_expr = lin_expr; } if (globals->cmd_options->consts_in_eq_as_error()) { Affine_func *aff; aff = affine_expr->compute_affine(); if (aff->find_addend(NULL)) { // there is a constant term string msg; char buf[20]; sprintf(buf, "line %d: ", get_source_line()); msg = buf; msg += string("constant term in OUTPUT"); globals->problem_handler->process( new Problem(ERROR, msg)); } delete aff; } res = affine_expr->unroll(); if (cnst_item) res.push_back(cnst_item); for (iter = res.begin(); iter != res.end(); iter++) (* iter)->set_unrolled_from(this); return res;}MLD_representation * Continuous_item::translate_MLD() const { MLD_representation * mld; Affine_func * aff; int subind_cnt = 0; assert(affine_expr->is_affine()); //fine mld = new MLD_representation(globals); aff = affine_expr->compute_affine(); aff_to_mld_eq(lhs_var, aff, mld, & subind_cnt); delete aff; return mld;}void Continuous_item::semantic_checks() { string msg; char buf[20]; if (lhs_var->get_kind() != STATE_KIND) { sprintf(buf, "line %d: ", get_source_line()); msg = buf; msg += string("left hand side variable ") + lhs_var->get_name() + string(" is not state"); msg += string(" (") + lhs_var->get_name() + string(" declared at line "); sprintf(buf, "%d)", lhs_var->get_line_of_decl()); msg += string(buf); globals->problem_handler->process(new Problem(ERROR, msg)); } if (lhs_var->get_type() != REAL_TYPE) { sprintf(buf, "line %d: ", get_source_line()); msg = buf; msg += string("left hand side variable ") + lhs_var->get_name() + string(" is not real"); msg += string(" {") + lhs_var->get_name() + string(" declared at line "); sprintf(buf, "%d)", lhs_var->get_line_of_decl()); msg += string(buf); globals->problem_handler->process(new Problem(ERROR, msg)); } affine_expr->semantic_checks(); if (!affine_expr->is_affine()) { sprintf(buf, "line %d: ", get_source_line()); msg = buf; msg += string("expression must be affine"); globals->problem_handler->process(new Problem(ERROR, msg)); }}string Continuous_item::matlab_simu() const { string res; res += string("% ") + get_source() + string("\n"); res += lhs_var->to_matlab_newstate() + string(" = ") + affine_expr->to_matlab() + string(";\n"); res += string("\n"); return res;}string Continuous_item::arg_range_check_matlab() const { string res; res += affine_expr->arg_range_check_matlab(); return res;}Min_max_eps * Continuous_item::compute_minmax() const { Min_max_eps * mme; Affine_func * aff; aff = affine_expr->compute_affine(); mme = compute_mme_from_aff(aff); delete aff; return mme;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -