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

📄 sqrt_expr.cc

📁 由matlab开发的hybrid系统的描述语言
💻 CC
字号:
#include "Sqrt_expr.h"#include "Affine_func.h"#include "Real_number.h"#include <stdio.h>#include "Globals.h"#include "Problem.h"#include "Problem_handler.h"Sqrt_expr::Sqrt_expr(Expr * c) : Unary_expr(c) {}void Sqrt_expr::semantic_checks() {	child->semantic_checks();	assert(child->is_real()); //fine}Affine_func * Sqrt_expr::compute_affine() const {	Affine_func * aff;	aff = new Affine_func(clone(), globals); // put this as constant	return aff;}bool Sqrt_expr::is_affine() const {	return child->is_const();}bool Sqrt_expr::is_number() const {	return child->is_number();}Number * Sqrt_expr::compute_number() const {	Real_number * num;	num = (Real_number *) child->compute_number();	num->sqrt();	return num;}string Sqrt_expr::arg_range_check_matlab() const {	string res;	string msg;	char buf[100];	res += Unary_expr::arg_range_check_matlab();	if (child->is_number()) { // warn if = 0 ???		if (((Real_number *) child->compute_number())->get_double() < 0.0) {			sprintf(buf, "line %d: ", get_source_line());			msg = buf;			msg += string("sqrt of negative (") +				child->get_source() + string(")");			globals->problem_handler->process(				new Problem(ERROR, msg));		}	} else if (child->is_const()) {		res += string("if ") + child->to_matlab() + string(" < 0.0") +			string(" then error(\'");		sprintf(buf, "line %d: ", get_source_line());		res += buf;		res += string("sqrt of negative (") +			child->get_source() + string(")");		res += string("\'); end\n");	}	return res;}

⌨️ 快捷键说明

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