/usr/share/gap/pkg/Alnuth/gap/factors.gi is in gap-alnuth 3.0.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | ############################################################################
##
#W factors.gi Alnuth - ALgebraic NUmber THeory Andreas Distler
##
#############################################################################
##
#M IrrFacsAlgExtPol(<f>) . . . . . lists of irreducible factors of rational
## polynomial over algebraic extensions, initialize default
##
InstallOtherMethod(IrrFacsAlgExtPol,true,[IsPolynomial],0,f -> []);
#############################################################################
##
#F StoreFactorsAlgExtPol( <pring>, <upol>, <factlist> ) . store factors list
##
InstallGlobalFunction(StoreFactorsAlgExtPol,function(R,f,fact)
local irf;
irf:=IrrFacsAlgExtPol(f);
if not ForAny(irf,i->i[1]=R) then
Add(irf,[R,fact]);
fi;
end);
#############################################################################
##
#F FactorsPolynomialAlgExt, function( <H>, <poly> )
##
## Factorizes the rational polynomial <poly> over the field <H>, a proper
## algebraic extension of the rationals, using PARI/GP
##
InstallGlobalFunction( FactorsPolynomialAlgExt, function( H, poly )
local faktoren, irf, i;
if not ForAll( CoefficientsOfUnivariatePolynomial( poly ), IsRat ) then
Error( "polynomial has to be defined over the Rationals" );
fi;
if H = Rationals then
return Factors( poly );
fi;
irf := IrrFacsAlgExtPol( poly );
i := PositionProperty( irf, k -> k[1] = H );
if i <> fail then
return irf[i][2];
fi;
faktoren := FactorsPolynomialPari( AlgExtEmbeddedPol( H, poly ));
StoreFactorsAlgExtPol( H, poly, faktoren );
return faktoren;
end );
#############################################################################
##
#F FactorsPolynomialPari, function( <poly> )
##
## Factorizes the polynomial <poly> defined over an algebraic extension of
## the rationals using PARI/GP
##
## As a method of 'Factors' ? AD
##
InstallGlobalFunction(FactorsPolynomialPari, function( poly )
local faktoren, fak, coeff, c, lcoeff, irf, i, coeffs, H;
H := CoefficientsRing( DefaultRing( poly ));
irf := IrrFacsAlgExtPol( poly );
i := PositionProperty( irf, k -> k[1] = H );
if i <> fail then
return irf[i][2];
fi;
if DegreeOfLaurentPolynomial( poly ) < 2 then
faktoren := [ poly ];
StoreFactorsPol( H, poly, faktoren );
return faktoren;
fi;
faktoren := [ ];
lcoeff := LeadingCoefficient( poly );
coeffs := CoefficientsOfUnivariatePolynomial( poly / lcoeff );
coeffs := List( Reversed( coeffs ), ExtRepOfObj );
for fak in PolynomialFactorsDescriptionPari( H, coeffs ) do
coeff := [ ];
for c in Reversed( fak ) do
if ( c in Rationals ) then
Add( coeff, c );
else
Add( coeff, LinearCombination( EquationOrderBasis(H), c ) );
fi;
od;
Add( faktoren, UnivariatePolynomial( H, One(H)*coeff ) );
od;
faktoren[1] := lcoeff * faktoren[1];
StoreFactorsPol( H, poly, faktoren );
return faktoren;
end );
#############################################################################
##
#E
|