These are chat archives for symengine/symengine

7th
May 2017
Ranjith Kumar
@ranjithkumar007
May 07 2017 13:52

@isuruf, I am having some problem in writing wrappers for factorisation
I am not sure if the following is the right way.

template <typename Container, template <typename X, typename Y> class BaseType,
          typename Poly>
std::pair<integer_class, std::vector<std::pair<RCP<const Poly>, long>>>
factors(const UFlintPoly<Container, BaseType, Poly> &a)
{
    auto fac = *((a.get_poly().factors()).get_fmpz_poly_factor_t());
    std::vector<std::pair<RCP<const Poly>, long>> S;
    for (long i = 0; i < fac->num; i++) {
        fzp_t z;
        z.set_fmpz_poly_t(&(fac->p[i]));
        S.push_back(
            std::make_pair(make_rcp<const Poly>(a.get_var(), z), fac->exp[i]));
    }
    return {fac->c, S};
}

i am unable to resolve the following error

Linking CXX executable test_uexprpoly
In file included from /home/ranjithkumar/Documents/OpenSource/symengine/symengine/mp_wrapper.h:4:0,
                 from /home/ranjithkumar/Documents/OpenSource/symengine/symengine/mp_class.h:6,
                 from /home/ranjithkumar/Documents/OpenSource/symengine/symengine/dict.h:9,
                 from /home/ranjithkumar/Documents/OpenSource/symengine/symengine/basic.h:32,
                 from /home/ranjithkumar/Documents/OpenSource/symengine/symengine/polys/upolybase.h:8,
                 from /home/ranjithkumar/Documents/OpenSource/symengine/symengine/polys/usymenginepoly.h:4,
                 from /home/ranjithkumar/Documents/OpenSource/symengine/symengine/polys/uintpoly.h:8,
                 from /home/ranjithkumar/Documents/OpenSource/symengine/symengine/tests/polynomial/test_uintpoly_flint.cpp:4:
/home/ranjithkumar/Documents/OpenSource/symengine/symengine/symengine_rcp.h: In instantiation of ‘Teuchos::RCP<T1> SymEngine::make_rcp(Args&& ...) [with T = const SymEngine::UIntPolyFlint; Args = {const Teuchos::RCP<const SymEngine::Basic>&, SymEngine::fmpz_poly_wrapper&}]’:
/home/ranjithkumar/Documents/OpenSource/symengine/symengine/polys/uintpoly_flint.h:166:63:   required from ‘std::pair<SymEngine::mpz_wrapper, std::vector<std::pair<Teuchos::RCP<const Poly>, long int> > > SymEngine::factors(const SymEngine::UFlintPoly<Container, BaseType, Poly>&) [with Container = SymEngine::fmpz_poly_wrapper; BaseType = SymEngine::UIntPolyBase; Poly = SymEngine::UIntPolyFlint]’
/home/ranjithkumar/Documents/OpenSource/symengine/symengine/tests/polynomial/test_uintpoly_flint.cpp:299:26:   required from here
/home/ranjithkumar/Documents/OpenSource/symengine/symengine/symengine_rcp.h:380:54: error: cannot bind ‘SymEngine::fmpz_poly_wrapper’ lvalue to ‘fzp_t&& {aka SymEngine::fmpz_poly_wrapper&&}’
     RCP<T> p = rcp(new T(std::forward<Args>(args)...));
                                                      ^
In file included from /home/ranjithkumar/Documents/OpenSource/symengine/symengine/tests/polynomial/test_uintpoly_flint.cpp:5:0:
/home/ranjithkumar/Documents/OpenSource/symengine/symengine/polys/uintpoly_flint.h:139:5: error:   initializing argument 2 of ‘SymEngine::UIntPolyFlint::UIntPolyFlint(const Teuchos::RCP<const SymEngine::Basic>&, fzp_t&&)’
     UIntPolyFlint(const RCP<const Basic> &var, fzp_t &&dict);
Isuru Fernando
@isuruf
May 07 2017 13:55
make_rcp<const Poly>(a.get_var(), z) -> make_rcp<const Poly>(a.get_var(), std::move(z))
Ranjith Kumar
@ranjithkumar007
May 07 2017 13:56
Ah..thanks