realroot_doc 0.1.1
|
# include <realroot/GMP.hpp> # include <realroot/polynomial_sparse.hpp> # include <realroot/polynomial_tensor.hpp> # include <realroot/subresultant.hpp> int main(int argc, char** argv) { using namespace mmx; typedef polynomial< GMP::integer, with<Sparse,DegRevLex > > PolynomialZ; typedef PolynomialZ::Monomial MonomialZ; //Poly( C, d, i) means C * x_i^d PolynomialZ F("5*t^2*y^2+2*y^4+3*y*t-1"); F = F*F; PolynomialZ G =diff(F,1); std::cout << "F : " << F << std::endl; std::cout << "G : " << G << std::endl; std::cout << "S : " << subresultant<euclidean>::sequence(F,G, 1) << std::endl; std::cout << "R : " << subresultant<euclidean>::resultant(F,G, 1) << std::endl; std::cout << "D : " << gcd(F,G) << std::endl; PolynomialZ P0("2*x0*x1^2*x2-2*x0*x1*x2-2*x1+2"), P1("-6*x0*x1^2*x2^2+6*x0*x1^2*x2+6*x1*x2-6*x1"); std::cout << "P0 : " << P0 << std::endl; std::cout << "P1 : " << P1 << std::endl; std::cout << "D : " << gcd(P1,P0) << std::endl; std::cout << "-----" << std::endl; typedef polynomial< double, with<Sparse, DegRevLex> > Polynomial; typedef Polynomial::Monomial Monomial; //Poly( C, d, i) means C * x_i^d Polynomial f("5*t^2*y^2+2*y^4+3*y*t-1"); f = f*f; Polynomial g =diff(f,1); std::cout << "f : " << f << std::endl; std::cout << "g : " << g << std::endl; std::cout << "s : " << subresultant<euclidean>::sequence(f,g, 1) << std::endl; std::cout << "r : " << subresultant<euclidean>::resultant(f,g, 1) << std::endl; std::cout << "d : " << gcd(f,g) << std::endl; return 0; }