> < ^ Date: Wed, 18 Sep 1996 18:42:13 +0200
> < ^ From: Richard Rossmanith <richard@maxp03.mathe.uni-jena.de >
> ^ Subject: Gaps in GAP's functions for polynomials

Dear Gap-Forum,

I have encountered two small gaps in GAP's functions that deal (or rather,
refuse to deal) with polynomials:

1. The HTML-GAP-Manual, Release 3.4 (10. Jul. 1994), states that
> there is no generic way to test whether a [Ring] element is irreducible.
Yes, there is:

RingOps.IsIrreducible:=function(arg)
if Length(arg)=1 then
return Length(Factors(arg[1]))=1;
elif Length(arg)=2 then
return Length(Factors(arg[1],arg[2]))=1;
else
Error("Wrong number of arguments");
fi;
end;

2. Usually, you use a list to define a polynomial. But maybe later on, you want
the list back, and you want that simply by using the command List(p). (E.g. I
wanted to construct the companion matrix of a polynomial.) The following patch
for List allows this:

List:=function ( arg )
    local  lst, i, fun;
    if Length( arg ) = 1  then
        if IsString( arg[1] )  then
            lst := [  ];
            for i  in [ 1 .. LengthString( arg[1] ) ]  do
                lst[i] := SubString( arg[1], i, i );
            od;
        elif IsList( arg[1] )  then
            lst := arg[1];
        elif IsPerm( arg[1] )  then
            lst := [  ];
            for i  in [ 1 .. LargestMovedPointPerm( arg[1] ) ]  do
                lst[i] := i ^ arg[1];
            od;
        elif IsWord( arg[1] )  then
            lst := [  ];
            for i  in [ 1 .. LengthWord( arg[1] ) ]  do
                lst[i] := Subword( arg[1], i, i );
            od;
        elif IsPolynomial( arg[1] )  then   #  *** THIS IS ***
            lst := arg[1].coefficients;     #  *** NEW !!! ***
        else
            Error( "can't convert ", arg[1], " into a list" );
        fi;
    elif Length( arg ) = 2 and IsList( arg[1] ) and IsFunc( arg[2] )  then
        lst := [  ];
        fun := arg[2];
        for i  in [ 1 .. Length( arg[1] ) ]  do
            lst[i] := fun( arg[1][i] );
        od;
    else
        Error( "usage: List( <obj> ) or List( <list>, <func> )" );
    fi;
    return lst;
end;

Regards, Richard

_______________________________________________________________________________
 richard rossmanith
 http://www.minet.uni-jena.de/~richard/

> < [top]