예제 #1
0
static unsigned check_factorization(const exvector& factors)
{
	ex e = (new mul(factors))->setflag(status_flags::dynallocated);
	ex ef = factor(e.expand());
	if (ef.nops() != factors.size()) {
		clog << "wrong number of factors, expected " << factors.size() <<
			", got " << ef.nops();
		return 1;
	}
	for (size_t i = 0; i < ef.nops(); ++i) {
		if (find(factors.begin(), factors.end(), ef.op(i)) == factors.end()) {
			clog << "wrong factorization: term not found: " << ef.op(i);
			return 1;
		}
	}
	return 0;
}
예제 #2
0
static ex make_divide_expr(const exvector& args)
{
	exvector rest_args;
	rest_args.reserve(args.size() - 1);
	std::copy(args.begin() + 1, args.end(), std::back_inserter(rest_args));
	ex rest_base = (new mul(rest_args))->setflag(status_flags::dynallocated);
	ex rest = pow(rest_base, *_num_1_p);
	return (new mul(args[0], rest))->setflag(status_flags::dynallocated);
}
예제 #3
0
static ex lst_reader(const exvector& ev)
{
	return GiNaC::lst(ev.begin(), ev.end());
}