예제 #1
0
umap_int_basic URatPSeriesFlint::as_dict() const
{
    umap_int_basic map;
    mpq_t gc;
    mpq_init(gc);
    for (int n=0; n<degree_; n++) {
        const flint::fmpqxx fc(p_.get_coeff(n));
        if (not fc.is_zero()) {
            fmpq_get_mpq(gc, fc._data().inner);
            RCP<const Number> basic = Rational::from_mpq(std::move(rational_class(gc)));
            map[n] = basic;
        }
    }
    mpq_clear(gc);
    return map;
}
예제 #2
0
RCP<const Basic> URatPSeriesFlint::as_basic() const
{
    RCP<const Symbol> x = symbol(var_);
    RCP<const Number> zcoef;
    umap_basic_num dict_;
    mpq_t gc;
    mpq_init(gc);
    for (int n = 0; n < degree_; n++) {
        const flint::fmpqxx fc(p_.get_coeff(n));
        if (not fc.is_zero()) {
            fmpq_get_mpq(gc, fc._data().inner);
            RCP<const Number> basic = Rational::from_mpq(rational_class(gc));
            auto term = SymEngine::mul(SymEngine::pow(x, SymEngine::integer(n)),
                                       basic);
            if (n == 0)
                zcoef = basic;
            Add::coef_dict_add_term(outArg(basic), dict_, one, term);
        } else if (n == 0)
            zcoef = integer(0);
    }
    mpq_clear(gc);
    return std::move(Add::from_dict(zcoef, std::move(dict_)));
}