⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 min_max_eps.cc

📁 由matlab开发的hybrid系统的描述语言
💻 CC
字号:
#include "Min_max_eps.h"#include <assert.h>#include "Expr.h"#include <stdio.h>#include "Globals.h"#include "Problem.h"#include "Problem_handler.h"#include "Min_expr.h"#include "Max_expr.h"#include "Real_number.h"Min_max_eps::Min_max_eps(Expr * min, Expr * max, Expr * eps,	const Globals * glob) {		globals = glob;		assert(min && max); //fine	if (min->is_number() && max->is_number()) {		if (((Real_number*)min->compute_number())->get_double() > ((Real_number*)max->compute_number())->get_double()) {			char buf[100]; string msg;			sprintf(buf, "line %d: ", max->get_source_line());			msg = buf;			msg += string("lower bound is larger than upper bound (") + min->get_source() + string(" > ") + max->get_source() + string(")");			globals->problem_handler->process(new Problem(WARNING, msg, BOUNDS_ORDER));		}				}		this->min = new Min_expr(min, max);  // be fault tolerant		this->min->set_source(min->get_source()); // creates confusion!		this->min->set_source_line(min->get_source_line());		this->max = new Max_expr(max, min);		this->max->set_source(max->get_source());		this->max->set_source_line(max->get_source_line());		this->eps = eps;}Min_max_eps * Min_max_eps::clone() const {	Min_max_eps * res;	res = new Min_max_eps(get_min(), get_max(), get_eps(), globals);	res->globals = globals;	res->source_line = source_line;	res->source = source;	return res;}Expr * Min_max_eps::get_min() const {	return min->clone();}Expr * Min_max_eps::get_max() const {	return max->clone();}Expr * Min_max_eps::get_eps() const {	if (eps) return eps->clone(); else return NULL;}void Min_max_eps::semantic_checks() {	string msg;	char buf[100];	min->semantic_checks();	if (!min->is_const()) {		sprintf(buf, "line %d: ", source_line);		msg = buf;		msg += string("bounds must be constant");		globals->problem_handler->process(new Problem(ERROR, msg));	}	max->semantic_checks();	if (!max->is_const()) {		sprintf(buf, "line %d: ", source_line);		msg = buf;		msg += string("bounds must be constant");		globals->problem_handler->process(new Problem(ERROR, msg));	}		if (min->is_number() && max->is_number()) {		if (((Real_number*)min->compute_number())->get_double() > ((Real_number*)max->compute_number())->get_double()) {			sprintf(buf, "line %d: ", max->get_source_line());			msg = buf;			msg += string("lower bound is larger than upper bound (") + min->get_source() + string(" > ") + max->get_source();			globals->problem_handler->process(new Problem(ERROR, msg));		}				}	if (eps) {		eps->semantic_checks();		if (!eps->is_const()) {			sprintf(buf, "line %d: ", source_line);			msg = buf;			msg += string("epsilon must be constant");			//msg+=string(" (eps = ")+eps->to_matlab() + string(")");			globals->problem_handler->process(				new Problem(ERROR, msg));		}	}}string Min_max_eps::arg_range_check_matlab() const {	string res;	res += min->arg_range_check_matlab();	res += max->arg_range_check_matlab();	if (eps) res += eps->arg_range_check_matlab();	return res;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -