📄 affine_addend.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 "Affine_addend.h"#include "Expr.h"#include "Var_symbol.h"#include "Mult_expr.h"#include "Min_expr.h"#include "Max_expr.h"#include "Min_max_eps.h"#include "Variable_expr.h"Affine_addend::Affine_addend(Expr * c, const Var_symbol * v) { var = v; coeff = c;}Affine_addend::~Affine_addend() { delete coeff;}Affine_addend* Affine_addend::clone() const{ return new Affine_addend(coeff->clone(), var);} Expr * Affine_addend::get_coeff() const { return coeff->clone();}void Affine_addend::set_coeff(Expr * e) { coeff = e;}const Var_symbol * Affine_addend::get_var() const { return var;}string Affine_addend::to_string() const { string res; res += coeff->to_matlab(); if (var) { res += " * "; res += var->get_name(); } return res;}Expr * Affine_addend::find_min(const Item * originator) const { Expr * var_low, * var_hi; if (!var) { // constant part return coeff->clone(); } else { list < const Symbol * > empty; var->compute_minmax(originator, empty); var_low = new Mult_expr(coeff->clone(), var->get_min()); var_hi = new Mult_expr(coeff->clone(), var->get_max()); return Expr::simpl(new Min_expr(var_low, var_hi)); }}Expr * Affine_addend::find_max(const Item * originator) const { Expr * var_low, * var_hi; if (!var) { // constant part return coeff->clone(); } else { list < const Symbol * > empty; var->compute_minmax(originator, empty); var_low = new Mult_expr(coeff->clone(), var->get_min()); var_hi = new Mult_expr(coeff->clone(), var->get_max()); return Expr::simpl(new Max_expr(var_low, var_hi)); }}Expr * Affine_addend::to_expr() const { if (var) return new Mult_expr(coeff->clone(), new Variable_expr(var, coeff->get_globals())); else return coeff->clone();}void Affine_addend::simplify() { coeff->simplify();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -