Exemplo n.º 1
0
Expression UExprPoly::max_coef() const
{
    Expression curr = get_poly().get_dict().begin()->second;
    for (const auto &it : get_poly().get_dict())
        if (curr.get_basic()->__cmp__(*it.second.get_basic()))
            curr = it.second;
    return curr;
}
Exemplo n.º 2
0
Expression UExprPoly::eval(const Expression &x) const
{
    Expression ans = 0;
    for (const auto &p : get_poly().get_dict()) {
        Expression temp;
        temp = pow_ex(x, Expression(p.first));
        ans += p.second * temp;
    }
    return ans;
}
Exemplo n.º 3
0
int main()
{   
	int degree;
	printf("Enter the degree of the polynomial: ");
	scanf("%d", &degree);
	printf("Enter each coefficient: ");
	double coeff[degree];
	get_poly(coeff[degree], degree);
	double x;
	printf("Enter the value for x: ");
	scanf("%lf", &x);
	eval_poly(coeff[degree], degree, x);

    system("pause");
    return 0;
}
Exemplo n.º 4
0
bool UExprPoly::is_pow() const
{
    return get_poly().size() == 1 and get_poly().get_dict().begin()->second == 1
           and get_poly().get_dict().begin()->first != 1
           and get_poly().get_dict().begin()->first != 0;
}
Exemplo n.º 5
0
bool UExprPoly::is_symbol() const
{
    return get_poly().size() == 1 and get_poly().get_dict().begin()->first == 1
           and get_poly().get_dict().begin()->second == 1;
}
Exemplo n.º 6
0
bool UExprPoly::is_integer() const
{
    if (get_poly().empty())
        return true;
    return get_poly().size() == 1 and get_poly().get_dict().begin()->first == 0;
}
Exemplo n.º 7
0
bool UExprPoly::is_minus_one() const
{
    return get_poly().size() == 1
           and get_poly().get_dict().begin()->second == -1
           and get_poly().get_dict().begin()->first == 0;
}
Exemplo n.º 8
0
bool UExprPoly::is_zero() const
{
    return get_poly().empty();
}