📄 row_information.cc
字号:
#include "Row_information.h"#include "Section.h"#include "Item.h"#include "Definition_item.h"#include "Var_symbol.h"#include "AD_item.h"#include "DA_item.h"#include "Min_max_eps.h"#include "Expr.h"#include "Affine_func.h"#include "MLD_representation.h"#include <stdio.h>Row_information::~Row_information(){}string Row_information::to_matlab(string prefix) const { list < const Var_symbol * > req; string::iterator string_iter; list < const Var_symbol * >::const_iterator iter; string res; char buf[100]; //cout << "Ri.." ; cout.flush(); res += prefix + string(".section = \'"); res += item->section->get_ident(); res += "\';\n"; res += prefix + string(".item_type = \'"); res += item->get_ident(); res += "\';\n"; res += prefix + string(".defines = \'"); if (item->is_definition_item()) res += ((Definition_item *) item)->get_lhs_var()->get_name(); else res += "NONE"; res += "\';\n"; res += prefix + string(".depends = {"); req = item->get_required_simu(); for (iter = req.begin(); iter != req.end(); iter++) { res += string("'") + (* iter)->get_name() + string("', "); } if (!req.empty()) { // the last ", " is too much -> erase string_iter = res.end(); string_iter--; string_iter--; res.erase(string_iter, res.end()); } res += string("};\n"); res += prefix + string(".group = "); sprintf(buf, "%d", item->group+1); res += buf; res += ";\n"; res += prefix + string(".subgroup = "); sprintf(buf, "%d", item->subgroup+1); res += buf; res += ";\n"; res += prefix + string(".subindex = "); sprintf(buf, "%d", subindex+1); res += buf; res += ";\n"; res += prefix + string(".source = \'"); res += item->source; res += "\';\n"; res += prefix + string(".sourceline = "); sprintf(buf, "%d", item->source_line); res += buf; res += ";\n"; //cout << "ok" << endl; cout.flush(); if (item->is_DA_item()) { Expr *min, *max; min=((const DA_item*)item)->mme_then->get_min(); max=((const DA_item*)item)->mme_then->get_max(); res+=prefix + string(".then_min = ") + min->to_matlab() + string(";\n"); if (((const DA_item*)item)->then_min_computed) res+= prefix + string(".then_min_computed = 1;\n"); else res+= prefix + string(".then_min_computed = 0;\n"); res+=prefix + string(".then_max = ") + max->to_matlab() + string(";\n"); if (((const DA_item*)item)->then_max_computed) res+= prefix + string(".then_max_computed = 1;\n"); else res+= prefix + string(".then_max_computed = 0;\n"); delete min; delete max; min=((const DA_item*)item)->mme_else->get_min(); max=((const DA_item*)item)->mme_else->get_max(); res+=prefix + string(".else_min = ") + min->to_matlab() + string(";\n"); if (((const DA_item*)item)->else_min_computed) res+= prefix + string(".else_min_computed = 1;\n"); else res+= prefix + string(".else_min_computed = 0;\n"); res+=prefix + string(".else_max = ") + max->to_matlab() + string(";\n"); if (((const DA_item*)item)->else_max_computed) res+= prefix + string(".else_max_computed = 1;\n"); else res+= prefix + string(".else_max_computed = 0;\n"); delete min; delete max; } if (item->is_AD_item()) { Expr *min, *max, *eps; min=((const AD_item*)item)->mme->get_min(); max=((const AD_item*)item)->mme->get_max(); eps=((const AD_item*)item)->mme->get_eps(); res+=prefix + string(".aff_min = ") + min->to_matlab() + string(";\n"); if (((const AD_item*)item)->min_computed) res+= prefix + string(".aff_min_computed = 1;\n"); else res+= prefix + string(".aff_min_computed = 0;\n"); res+=prefix + string(".aff_max = ") + max->to_matlab() + string(";\n"); if (((const AD_item*)item)->max_computed) res+= prefix + string(".aff_max_computed = 1;\n"); else res+= prefix + string(".aff_max_computed = 0;\n"); res+=prefix + string(".aff_eps = ") + eps->to_matlab() + string(";\n"); if (((const AD_item*)item)->eps_computed) res+= prefix + string(".aff_eps_computed = 1;\n"); else res+= prefix + string(".aff_eps_computed = 0;\n"); delete min; delete max; delete eps; } /* res+=prefix + string(".required = ") res+="\n"; */ if (is_ineq) res+=prefix + string(".human = \'") + mld->row_to_string(mld_rowid.ineq) + string("\';\n"); else res+=prefix + string(".human = \'") + mld->row_to_string(mld_rowid.lhs) + string("\';\n"); return res;}void Row_information::set_mld(const MLD_representation *mld, int ineq){ this->mld=mld; is_ineq=true; mld_rowid.ineq=ineq;}void Row_information::set_mld(const MLD_representation *mld, const Var_symbol *lhs){ this->mld=mld; is_ineq=false; mld_rowid.lhs=lhs;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -