Exemple #1
0
void Function::print(std::ostream& os) const {
	if (name!=NULL) os << name << ":";
	os << "(";
	for (int i=0; i<nb_arg(); i++) {
		os << arg_name(i);
		if (i<nb_arg()-1) os << ",";
	}
	os << ")->" << expr();
}
void Function::print(std::ostream& os) const {
	if (name!=NULL) os << name << ":";
	os << "(";
	for (int i=0; i<nb_arg(); i++) {
		const ExprSymbol& x = arg(i);
		os << x;
		if (x.dim.nb_rows()>1) os << '[' << x.dim.nb_rows() << ']';
		if (x.dim.nb_cols()>1) {
			if (x.dim.nb_rows()==1) os << "[1]";
			os << '[' << x.dim.nb_cols() << ']';
		}
		if (i<nb_arg()-1) os << ",";
	}
	os << ")->" << expr();
}
Exemple #3
0
Function::~Function() {
	if (_used_var!=NULL)
		delete[] _used_var;

	if (comp!=NULL) {
		/* warning... if there is only one constraint
		 * then comp[0] is the same object as f itself!
		 *
		 * This is not a very consistent choice...
		 */
		if (image_dim()>1) {
			for (int i=0; i<image_dim(); i++)
				if (!zero || comp[i]!=zero) delete comp[i];
		}
		if (zero) delete zero;
		delete[] comp;
	}

	if (cf.code!=NULL) {

		cleanup(expr(),false);

		for (int i=0; i<nb_arg(); i++) {
			delete &arg(i);
		}
	}

	if (df!=NULL) delete df;

	if (name!=NULL) { // name==NULL if init/build_from_string was never called.
		free((char*) name);
		delete[] symbol_index;
	}
}
Exemple #4
0
const ExprApply& Function::operator()(const vector<const ExprNode*>& arg) const {
	Array<const ExprNode> tmp(arg.size());
	assert(nb_arg()==(int)arg.size());
	for (unsigned int i=0; i<arg.size(); i++)
		tmp.set_ref(i,*arg[i]);
	return ExprApply::new_(*this, tmp);
}
Function::~Function() {

	if (root!=NULL) {

		/* warning... if there is only one constraint
		 * then comp is the same object as f itself!
		 *
		 * This is not a very consistent choice...
		 */
		if (!expr().dim.is_scalar()) delete[] comp;

		for (unsigned int i=0; i<exprnodes.size(); i++) {
			delete node(i).deco.d;
			delete node(i).deco.g;
			delete node(i).deco.p;
		}
		cleanup(expr(),false);

		for (int i=0; i<nb_arg(); i++)
			delete &arg(i);

		delete[] used_var;
	}

	free((char*) name);
}
Exemple #6
0
static void		count_and_init_command(t_data *data, t_cmd *fake_cmd,
	char *str, size_t *i)
{
	fake_cmd->p_error = 0;
	fake_cmd->error = 0;
	data->parse_old_i = *i;
	data->parse_count = nb_arg(i, str, fake_cmd);
}
const ExprApply& Function::operator()(const vector<const ExprNode*>& arg) {
	int n=arg.size();
	assert(nb_arg()==n);
	const ExprNode** tmp=new const ExprNode*[n];
	for (int i=0; i<n; i++) tmp[i]=arg[i];
	const ExprApply* a=&ExprApply::new_(*this, tmp);
	delete[] tmp;
	return *a;
}
Exemple #8
0
const ExprApply& Function::operator()(const Array<const ExprNode>& args) const {
	assert(nb_arg()==args.size());
	return ExprApply::new_(*this,args);
}
const ExprNode& Function::operator()(const Array<const ExprNode>& new_args) const {
	assert(nb_arg()==new_args.size());
//	return ExprApply::new_(*this,args);
	return ExprCopy().copy(args(),new_args,expr());
}