synaps/mpol/square_free.h

00001 #ifndef MPOL_SQUARE_FREE_HH
00002 #define MPOL_SQUARE_FREE_HH
00003 
00004 #include <synaps/mpol/MPol.h>
00005 #include <synaps/upol/square_free.h>
00006 __BEGIN_NAMESPACE_SYNAPS
00007 
00008 template<class C, class O, class R>
00009 MPol< C, O, R> square_free ( const MPol<C,O,R> & p )
00010 {
00011   MPol<C,O,R> result;
00012   int lv = LastVar(p);
00013   if ( lv == -1 ) return p;
00014   convert( result, square_free2( p, lv ), lv );
00015 };
00016 
00017 template<class C, class O, class R> 
00018 UPolDse< MPol< C, O, R > > square_free2 ( const MPol< C, O, R > & p , int y = 0 )
00019 {
00020   typedef MPol<C,O,R>     Polynom;
00021   typedef UPolDse< Polynom > UPolynom;
00022   UPolynom f;
00023   let::convert( f, p, y );
00024   Polynom c = gcd_coeffs(f);
00025   Polynom w = f / c;
00026   c = square_free(c);
00027   Polynom wy = diff(w,y);
00028   return (w/gcd(w,wy))*c;
00029 };
00030 
00031 __END_NAMESPACE_SYNAPS
00032 #endif

SYNAPS DOCUMENTATION
logo