> < ^ Date: Tue, 28 Aug 2001 18:03:14 +0200
> < ^ From: Thomas Breuer <Thomas.Breuer@Math.RWTH-Aachen.DE >
> < ^ Subject: Re: infinite-dimensional vector spaces

Dear GAP Forum,

recently Jan Draisma pointed to the problem
that GAP 4.2 cannot reasonably deal with finite dimensional subspaces
of universal enveloping algebras or of polynomial rings.

Willem de Graaf has already sent code for the former case,
here is now code for the latter.
(One can simply load it into a GAP session
before one creates the vector spaces in question.)

All the best,
Thomas

#############################################################################
##
#F  IsSpaceOfRationalFunctions( <V> )
##
##  If an $F$-vector space <V> is in the filter `IsSpaceOfRationalFunctions'
##  then this expresses that <V> consists of rational functions,
##  and that <V> is handled via the mechanism of nice bases in the following
##  way.
##  Let $v_1, v_2, \ldots, v_k$ be vector space generators of <V>,
##  let $d$ be a polynomial such that all $d \cdot v_i$ are polynomials,
##  and let $S$ be the set of monomials that occur in these polynomials.
##  Then the `NiceFreeLeftModuleInfo' value of <V> is a record with the
##  following components.
##  \beginitems
##  `family' &
##     the elements family of <V>,
##
##  `monomials' &
##     the list $S$,
##
##  `denom' &
##     the polynomial $d$,
##
##  `zerocoeff' &
##     the zero coefficient of elements in <V>,
##
##  `zerovector' &
##     the zero row vector in the nice free left module.
##  \enditems
##  The `NiceVector' value of $v \in <V>$ is defined as the row vector of
##  coefficients of $v$ w.r.t.~$S$.
##
##  Finite dimensional free left modules of rational functions
##  are by default handled via the mechanism of nice bases.
##
DeclareHandlingByNiceBasis( "IsSpaceOfRationalFunctions",
    "for free left modules of rational functions" );


#############################################################################
##
#M  NiceFreeLeftModuleInfo( <V> )
#M  NiceVector( <V>, <v> )
#M  UglyVector( <V>, <r> )
##
InstallHandlingByNiceBasis( "IsSpaceOfRationalFunctions", rec(
    detect := function( F, gens, V, zero )
      return IsRationalFunctionCollection( V );
      end,
NiceFreeLeftModuleInfo := function( V )
  local gens,
        nums,
        dens,
        denom,
        monomials,
        gen,
        list,
        i,
        zero,
        info;

gens:= GeneratorsOfLeftModule( V );

# Compute the product of denominators.
nums:= List( gens, NumeratorOfRationalFunction );
dens:= List( gens, DenominatorOfRationalFunction );
denom:= Product( dens, One( Zero( V ) ) );

monomials:= [];

for gen in gens do
  list:= ExtRepPolynomialRatFun( gen * denom );
  UniteSet( monomials, list{ [ 1, 3 .. Length( list ) - 1 ] } );
od;

zero:= Zero( LeftActingDomain( V ) );
info:= rec( monomials := monomials,
            denom     := denom,
            zerocoeff := zero,
            family    := ElementsFamily( FamilyObj( V ) ) );

# For the zero row vector, catch the case of empty `monomials' list.
if IsEmpty( monomials ) then
  info.zerovector := [ zero ];
else
  info.zerovector := ListWithIdenticalEntries( Length( monomials ),
                                               zero );
fi;

return info;
end,

NiceVector := function( V, v )
  local info, c, monomials, i, pos;
  info:= NiceFreeLeftModuleInfo( V );
  c:= ShallowCopy( info.zerovector );
  v:= v * info.denom;
  if not IsPolynomial( v ) then
    return fail;
  fi;
  v:= ExtRepPolynomialRatFun( v );
  monomials:= info.monomials;
  for i in [ 2, 4 .. Length( v ) ] do
    pos:= Position( monomials, v[ i-1 ] );
    if pos = fail then
      return fail;
    fi;
    c[ pos ]:= v[i];
  od;
  return c;
  end,

UglyVector := function( V, r )
  local info, list, i;
  info:= NiceFreeLeftModuleInfo( V );
  if Length( r ) <> Length( info.zerovector ) then
    return fail;
  elif IsEmpty( info.monomials ) then
    if IsZero( r ) then
      return Zero( V );
    else
      return fail;
    fi;
  fi;
  list:= [];
  for i in [ 1 .. Length( r ) ] do
    if r[i] <> info.zerocoeff then
      Add( list, info.monomials[i] );
      Add( list, r[i] );
    fi;
  od;
  return PolynomialByExtRep( info.family, list ) / info.denom;
  end ) );
#############################################################################
##
#E

Miles-Receive-Header: reply


> < [top]