Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/fining/lib/   (GAP Algebra Version 4.15.1©)  Datei vom 27.6.2023 mit Größe 38 kB image not shown  

Quellcode-Bibliothek projectivespace.gi   Sprache: Shell

 

#############################################################################
##
##  projectivespace.gi        FinInG package
##                                                              John Bamberg
##                                                              Anton Betten
##                                                              Jan De Beule
##                                                             Philippe Cara
##                                                            Michel Lavrauw
##                                                           Max Neunhoeffer
##
##  Copyright 2018 Colorado State University
##                  Sabancı Üniversitesi
## Università degli Studi di Padova
## Universiteit Gent
## University of St. Andrews
## University of Western Australia
##                  Vrije Universiteit Brussel
##
##
##  Implementation stuff for projective spaces.
##
#############################################################################

#############################################################################
# Low level help methods:
#############################################################################

# CHECKED 6/09/11 jdb
#############################################################################
#O  Wrap( <geo>, <type>, <o> )
# This is an internal subroutine which is not expected to be used by the user;
# they would be using VectorSpaceToElement. Recall that Wrap is declared in 
# geometry.gd. 
##
InstallMethod(  [IsProjectiveSpace,IsObject]java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
 "for a projective space and an object",
 [IsProjectiveSpace, IsPosInt
 function( geo, # If the object "v" to be unwrapped is a point of a vector space, then we do not want to# return v!.obj, but we want to return a list with one vector, i.e. [v!.obj]
  local w;#
  w# "for a subspace of a projective # [ IsSubspaceOfProjectiveSpace# function( v, u )
  java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
   IsElementOfIncidenceStructureRep# CHECKED 6/09/11 jdb
  #O  ProjectiveSpace( <d>,#O  ProjectiveSpace( <d>, ite field.
 end)

# CHECKED 6/09/11 jdb
#jdb 30/10/15: This method is not used anymore after commenting out the Unwrapper stuff in geometry.gd
#see the comment there.
#############################################################################
#O  \^( <v>, <u> )
# If the object "v" to be unwrapped is a point of a vector space, then we do not want to use
# return v!.obj, but we want to return a list with one vector, i.e. [v!.obj]
# e.g. if p is a point of a projective space
# gap> p^_; 
# will return a list, with the coordinate vector of the point p
##
#InstallMethod( \^,
# "for a subspace of a projective space and an unwrapper",
# [ IsSubspaceOfProjectiveSpace, IsUnwrapper ],
# function( v, u )
# if v!.type = 1 then return [v!.obj];
# else return v!.obj;
# fi;
# end );

#############################################################################
# Constructor methods and some operations/attributes for projective spaces.
#############################################################################

# CHECKED 6/09/11 jdb
#############################################################################
#O  ProjectiveSpace( <d>, <f> )
# returns PG(d,f), f a finite field.
##
InstallMethod(                   IsProjectiveSpace  andIsDesarguesianPlane;
   =NewType(GeometriesFamily
IsProjectiveSpace and IsProjectiveSpaceRep );
    local geo, ty;
    geo := rec( dimension :    fi;
               : (f,d+1 ;
    if d = 2 then
        ty := NewType( GeometriesFamily,
IsProjectiveSpace and IsProjectiveSpaceRep and IsDesarguesianPlane);
    else
        ty := NewType( GeometriesFamily,
                  IsProjectiveSpaceif d=then
    fi;
    Objectify( ty, geo );
SetAmbientSpace(g;
    if d=2 then
        SetOrder(java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 7
    fi;
    return geo;
  end##
 
# CHECKED 6/09/11 jdb
#############################################################################
#O  ProjectiveSpace( <d>, <q> )
# returns PG(d,q). 
##
 return (,GFq));
  [ ,IsPosInt]
  function(#############################################################################
          #############################################################################
  end;
  
#############################################################################
# Display methods:
#############################################################################

function p java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
  (p java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
Print((,!dimension" ,p.),"";
  end

 ,java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
"  projective "java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
[IsProjectiveSpace and IsProjectiveSpaceRep,
 ;
  InstallMethod( PrintObj,[and IsProjectiveSpaceRep ]
nd )

 PrintObj,[IsProjectiveSpaceand sProjectiveSpaceRep],
  function( p  end)
nt"ProjectiveSpace("p.imension""p.,))java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
  end );

InstallMethod( Display, [ IsProjectiveSpace and IsProjectiveSpaceRep ],
    #if HasDiagramOfGeometry( p ) then      
    #   Display
    #if HasDiagramOfGeometry( p ) then      
    #   Display( DiagramOfGeometry( p ) );
    #fi;
  end );#O  \=( <pg1>, <pg2> )

# CHECKED 6/09/11 jdb
#############################################################################
#O  \=( <pg1>, <pg2> )
##
InstallMethod( \=, 
 "for two projective spaces",
 [IsProjectiveSpace, IsProjectiveSpace],
 function(pg1,pg2)[IsProjectiveSpace,IsProjectiveSpace]
 return (pg1  (pg2)
 end ); return UnderlyingVectorSpacep) =UnderlyingVectorSpace);

# CHECKED 8/09/11 jdb
#############################################################################
#O  Rank( <ps> )
# returns the projective dimension of <ps>
##
InstallMethod( Rank, 
 "for a # returns the projective dimension of <ps>
  IsProjectiveSpace IsProjectiveSpaceRep,
 ps"or a projective space,
 );

#############################################################################
#O  BaseField( <sub> )
# returns the basefield of an element of a projective space
##
ps >ps!.imension
 foranelement    space,
 [IsSubspaceOfProjectiveSpace]
 sub -> #O  BaseField( <sub> )

# CHECKED 6/09/11 jdb
#############################################################################
#A  StandardFrame( <ps> )
# if the dimension of the projective space is n, then StandardFrame 
# makes a list of points with coordinates 
# (1,0,...0), (0,1,0,...,0), ..., (0,...,0,1) and (1,1,...,1) 
##
InstallMethod( StandardFrame, 
"ora projective space", 
 [IsProjectiveSpace], 
 function( pg )
  local bas, frame,  local bas, frame, unitpt],
  if not pg!.dimension > 0 then 
   Error(Theargument needs to be a projective space of dimension at least 1!";
  else
   bas:=#A  StandardFrame( <ps> )
  # if the dimension of the projective space is n, then# makes a list of points with coordinates 
   unitpt##
 InstallMethod( StandardFrame, 
   return frame;
  fi;
 end );

# CHECKED 11/09/11 jdb
#############################################################################
#A  RepresentativesOfElements( <ps> )
# Returns the canonical maximal flag for the projective space <ps>
##
InstallMethod(RepresentativesOfElements 
 "for a projective space", [IsProjectiveSpace],
 # returns the canonical maximal flag
 function( ps )
  local dif not pg!dimension > 0then 
 d =(ps);
  gf := 
 id : IdentityMat(d+,gf);
    :ListB()v>ectorSpaceToElement,);
  return elts;
 end );

# CHECKED 18/4/2011 jdb
#############################################################################
#O  Hyperplanes( <ps> )
# returns Hyperplanes(ps,ps!.dimension), <ps> a projective space
## 
 ,
 "for a projective space",
 [ IsProjectiveSpace fijava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
 function( ps# Returns the canonical maximal flag for the projective space <ps>
 (ps .);
 end)

# CHECKED 11/09/11 jdb
#############################################################################
#A  TypesOfElementsOfIncidenceStructure( <ps> )
# returns the names of the types of the elements of the projective space <ps>
# the is a helper operation.
## 
(TypesOfElementsOfIncidenceStructure 
 "for a projective space", [IsProjectiveSpace],
 function( ps )
  ocal d,,types
pes: "";
  d := ProjectiveDimension(ps);
  if d > elts : List(1.] - VectorSpaceToElement(s, id[.i]);
  if e)
  if # CHECKED 18/4#############################################################################
  for i in [5..d] do
   Add(types,Concatenation("proj. ",String(i-1),"-space"));
  od;
  return types;
 end );

# CHECKED 11/09/11 jdb
#############################################################################
#A  TypesOfElementsOfIncidenceStructurePlural( <ps> )
# retunrs the plural of the names of the types of the elements of the 
# projective space <ps>. This is a helper operation.
## 
InstallMethod( TypesOfElementsOfIncidenceStructurePlural, 
 "for a projective space",
 [IsProjectiveSpace],
 function( ps )
  local d,i,types;
  types := ["points"];
  d := ProjectiveDimension(ps);
  if d >= 2 then Add(types,"lines"); fi;
  if d >= 3 then Add(types,"planes"); fi;
  if d >= 4   Add(types,". "String(-1,-pace");
  for i in [5..d] do
   Add(types,Concatenation("proj. ",String(i-1),"  ;
  od;
   returntypes;
 end );

# CHECKED 11/09/11 jdb
#############################################################################
#O  ElementsOfIncidenceStructure( <ps>, <j> )
# returns the elements of the projective space <ps> of type <j>
## 
InstallMethod( ElementsOfIncidenceStructure, 
 "for a projective space and an integer",
 [IsProjectiveSpace, IsPosInt],
 function( ps, j )
  local r;
  r := Rank(ps);
  if j > r then
   Error("<ps> has no elements of type <j>");
  else
   return Objectify(
   NewType( ElementsCollFamily, IsSubspacesOfProjectiveSpace and IsSubspacesOfProjectiveSpaceRep ),
    rec( geometry := ps,
     type := j,
     size := Size(Subspaces(ps!.vectorspace, j))
     )
     );
  fi;
 end);

# CHECKED 11/09/11 jdb
#############################################################################
#O  ElementsOfIncidenceStructure( <ps> )
# returns all the elements of the projective space <ps> 
## 
InstallMethod( ElementsOfIncidenceStructure, 
 " space,
 [IsProjectiveSpace] if  >   Add(types,"lines";fijava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 15
  return Objectify(
pe java.lang.StringIndexOutOfBoundsException: Range [64, 63) out of bounds for length 105
    rec( geometry#############################################################################
     type := "all# returns the elements of the projective space <ps> of java.lang.StringIndexOutOfBoundsException: Range [0, 59) out of bounds for length 3
    );
 end)[, ]

# CHECKED 14/09/11 jdb
#############################################################################
#O  \=( <x>, <y> )
# returns true if the collections <x> and <y> of all subspaces of a projective
# space are the same.
## 
(\java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
  "for set of all subspaces of java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 6
Space   ElementsCollFamilyIsAllSubspacesOfProjectiveSpaceIsAllSubspacesOfProjectiveSpaceRepjava.lang.StringIndexOutOfBoundsException: Range [105, 106) out of bounds for length 105
  function(x,y)
  return ((x!.geometry! )
  y!.geometryend;
end );


# CHECKED 11/09/11 jdb
#############################################################################
#O  Size( <subs>) 
# returns the number of elements in the collection <subs>.
##
java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 20
 "for subspaces of a  IsAllSubspacesOfProjectiveSpace ]
 [ and ],
 function(subsreturn (!g!.dimension=y.!dimension)and(!geometry. java.lang.StringIndexOutOfBoundsException: Index 89 out of bounds for length 89
  return java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0
 end);

#############################################################################
# Constructor methods and some operations/attributes for subspaces of 
# projective spaces.
#############################################################################

#############################################################################
#  VectorSpaceToElement methods
#############################################################################

## Things to check for (dodgy input)
## ---------------------------------
## - dimension
## - field
## - compress the matrix at the end
## - rank of matrix
## - an empty list

## Much of the following will need to change in the new
## version of GAP, with the new Row and Matrix types.

## Should we have methods for the new types given by the cvec package?
## Currently we don't load the cvec package. Since 18/3/14 we do. The next 
## method also inserts a method for cmat.

## - rank of matrix
#############################################################################
#O  VectorSpaceToElement( <geom>, <v> ) returns the elements in <geom> determined
# by the vectorspace <v>. Several checks are built in. 
# This method unpacks the cmat, and uses the other VectorSpaceToElement method for PlistRep.
# this is maybe not too efficient, but row selection like x{list} (list is a list of positions)
# seems to fail, although according to the documentation, it should work. 
# In the future this could be made better.
##
InstallMethod( VectorSpaceToElement,
 "for a projective space and a # This method unpacks the cmat, and uses the other VectorSpaceToElement method for PlistRep.
 [IsProjectiveSpace# seems to fail, although according to the documentation, it should work. 
 function( geom, v )
 InstallMethod( ,
  )

# CHECKED 20/09/11
# changed 19/01/16 (jdb): by a change of IsPlistRep, this method gets also
# called when using a row vector, causing a problem with TriangulizeMat.
# a solution was to add IsMatrix.
#############################################################################
#O  VectorSpaceToElement( <geom>, <v> ) returns the elements in <geom> determined
# by the vectorspace <v>. Several checks are built in. 
##
InstallMethod( VectorSpaceToElement, 
 "for a projective space#############################################################################
#O  VectorSpaceToElement( <geom>, <v> ) # by the vectorspace <v>. java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 2
 function( geom, v )
    x,n,,y;java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
  ## when v is empty... 
                f (v 
 "v does  represent any ";
  fi;   
  #x := EchelonMat(v).vectors;
 fi; java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
 x;java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
  ## dimension should be correct
  if Length( ifLength([1)< !dimension  
 Error"  ");
  fi;
        
  ## Remove zero rows. It is possible the the user
  ## has inputted a matrix which does not have full rank
        n := Length(x); #
  i := 0;
orAllx-i] IsZero)do
   i := i+1; 
  od;
  if i = n then
   return  while i < nand ForAll([-],IsZero) do
  fi;
  x := x{[1..n-i]};
  if Length(  i := i+1; 
   return geom;
  fi od;

  ## It is possible that (a) the user has entered a
  ## matrix with one row, or that (b) the user has
   matrix with rank1 (hus stage
  ## we will have a matrix with one row).
       # We must also compress our vector/matrix.
 y: (sCMatRep,!basefieldLengthx1)x;
  #NewMatrix is currently undocumented in cvec, but creates a CMat object from a list of lists, using CMat which uses then a list of cvec vectors.
  ifLength()=1then
   ## matrix with one row, or that (b) the user has
  #x := x[1];
   #ConvertToVectorRep(x, geom!.basefield); # the extra basefield is necessary.
   #return Wrap(geom, 1, x);
   #return Wrap(geom, 1, CVec(Unpack(x), geom!.basefield) ); # changed to cvec 18/3/2014.
  else
   #ConvertToMatrixRep(x, geom!.basefield);
   #return Wrap(geom, Length(x), x);
    Wrapgeom,Lengthy,y;
  fi;
 end );

# CHECKED 20/09/11
#############################################################################
#O  VectorSpaceToElement( <geom>, <v> ) returns the elements in <geom> determined
# by the vectorspace <v>. Several checks are built in. 
##
InstallMethod( VectorSpaceToElement, 
 "for a projective space and a compressed GF(2)-matrix",
 [IsProjectiveSpace, IsGF2MatrixRep],
 function( geom, v )
  local  x, n, i, y;
  ## when v is empty... 
  if IsEmpty(v) then
   Error("<v> does not represent any element");
  fi;
  x := MutableCopyMat(v);
  TriangulizeMat(x); 
:=EchelonMat(().ectorsjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
  ## dimension should be correct
  if Length  ConvertToVectorRep(x, geom!.basefield); # the extra basefield is necessary.
   Error("Dimensions are incompatible");
  fi;
  #if Length(x) = 0 then
  # return EmptySubspace(geom);
  #fi;
  if Length(x)=ProjectiveDimension(geom)+1 then
  # return geom;
  
  
   #return Wrap(geom, Length(x), x);
  adoes 
  n :=f;
  i := 0;
 whilei  andxn-,)do
   i :=# CHECKED 20/09/11
  od;
  if i = n then
   return EmptySubspace(geom);
  fi;
  x := x{[1..n-i]};
  if Length(x)=ProjectiveDimension(geom) "for a projective  a GF2-"
   eturn geom;
  fi;

  
java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
  ## entered a matrix with rank 1 (thus at this stage
  ## we will have a matrix with one row).
     ## We must also compress our vector/matrix.
 InstallMethod VectorSpaceToElement,
 if Lengthy 1then
  Wrap(geom,1,y[];
   #x := x[1];
   #ConvertToVectorRep(x, geom!.basefield); # the extra basefield is necessary.
   #return Wrap(geom, 1, x);
   #return Wrap(geom, 1, CVec(Unpack(x), geom!.basefield) ); # changed to cvec 18/3/2014.
  else
   #ConvertToMatrixRep(x, geom!.basefield);
   return Wrap(geom, Length(y), y);
  fijava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
  );
  
# CHECKED 20/09/11
#############################################################################
#O  VectorSpaceToElement( <geom>, <v> ) returns the elements in <geom> determined
# by the vectorspace <v>. Several checks are built in. 
##
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 2
" a compressed basis of a vector subspace"
[IsProjectiveSpaceIs8BitMatrixRep],
function geom,v)
  local  x, n, i, y;
  ## when v is empty... 
  if IsEmpty(v) then 
   Error("<v> does not represent any java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 31
  fi;
  #x := EchelonMat(v).vectors;
  x : 
  
  
  ## dimension should be correct
  if Length(v[1]) <> i = 0java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  Error(Dimensions areincompatible";
  i
  
  #if Length(x) = 0 then
  # return EmptySubspace(geom);
  #fi;
  #if Length(x)=ProjectiveDimension(geom)+1 then
  # return geom;
 #fi;
 
  n := Length(x);
  i := 0;
  while i < n and ForAll(x[n fi;
   i := i+1 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
#
  if i = n then
   return EmptySubspace#
  fi;
 :=x[..-]}
()+ 
   return geom;
 java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

 
  ## It is possible that (a) the user has entered a
    return Wrap(geom, 1, CVec(Unpack(x), geom!.basefield) ); # changed to cvec 18/3/2014.
  ## entered a matrix with rank 1 (thus at this stage
 # we will have a matrix with one row).
  ## We must also compress our vector/matrix.
  y
### The next mathod constructs an element using a cvec. 
   return Wrap(geom, 1, y# ADDED 20/3/2014 jdb
   #x := x[1];
   #ConvertToVectorRep(x, geom!.basefield); # the extra basefield is necessary.#O  VectorSpaceToElement( <geom>, <v> ) returns the elements in <geom> determined
   #return Wrap(geom, 1, x);##
  return Wrap(geom, 1, CVec(Unpack(x), geom!.basefield) ); # changed to cvec 18/3/2014.
  else
   #ConvertToMatrixRep(x, geom!.basefield);
  return Wrap(eom Lengthy,y;
  fi;
  end );
 
### The next mathod constructs an element using a cvec. 

# ADDED 20/3/2014 jdb
#############################################################################
#O  VectorSpaceToElement( <geom>, <v> ) returns the elements in <geom> determined
# by the rowvector <v>. Several checks are built in.
##
InstallMethod(VectorSpaceToElement,
 "for a row vector",
 [IsProjectiveSpace, IsCVecRep],
 function(geom v )
   ## di should be correct
 ## when v is empty... does this ever occur for a row vector? No. jdb 21/09/2011
  #if IsEmpty(v) then
not any element);
  #fi;
  x := ShallowCopy(v #java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
  ## dimension should be correctcheckedthis with input ..
  if Length(v) <> geom!.dimension +   return EmptySubspace(geom);
   Error("Dimensions are incompatible");
  fi;
  ## We must also compress our vector.
  #ConvertToVectorRep(x, geom!.basefield);
 bad ,such as jdb,checked this with input zero vector...
  if IsZero(x) then
eturn (geom);
  else
   MultVector(x,Inverse(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   return Wrap# CHECKED 21/09/2011 jdb
  fi;
 end#O  VectorSpaceToElement( <geom>, <v> ) returns the elements in <geom> determined

# CHECKED 11/04/15 jdb
# CHANGED 19/9/2011 jdb + ml
# CHECKED 21/09/2011 jdb
#############################################################################
#O  VectorSpaceToElement( <geom>, <v> ) returns the elements in <geom> determined
# by the rowvector <v>. Several checks are built in.
##
InstallMethod( VectorSpaceToElement, [sProjectiveSpace, IsRowVector],
 "for a row vector",
 [IsProjectiveSpace, IsRowVectorfunction(geom, v )
 function( geom, v )
  local  x  local  x y;
  ## when v is empty... does this ever occur for a row vector? No. jdb 21/09/2011
  #if IsEmpty(v) then
  # Error("<v> does not represent any element");
  #fi;
  x := ShallowCopy(v);
  #fi;
  if: ShallowCopy(v);
   Error("Dimensions are incompatible");
 fi;
  ## We must also compress our vector.
  ConvertToVectorRep(x, geom!.basefield);
 ## bad characters, such as jdb, checked this with input zero vector...
  if IsZero(x) then
   return EmptySubspace(geom);
  else
   MultVector(x,Inverse( x[PositionNonZero(java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 19
   y : else
  #ConvertToVectorRep(x, geom!.basefield);
   return  y := NewMatrix,eom.,(x,x)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
  ;
 end );

# CHECKED 11/04/15 jdb
# CHANGED 19/9/2011 jdb + ml
#############################################################################
#O  VectorSpaceToElement( <geom>, <v> ) returns the elements in <geom> determined
# by the rowvector <v>. Several checks are built in.
##
InstallMethod( VectorSpaceToElement, 
 "for a java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 2
 ]
 function( geom,],
    x,n , ;
  ## when v is empty...  , n, ;
  if IsEmpty(v) then
   return EmptySubspace(geom);
 fi;
  x := ShallowCopy(v);
 ## dimension should be correct
  if Length( 
   Error if Lengthv >geom. +1 then
  fi;
 vectorjava.lang.StringIndexOutOfBoundsException: Range [38, 39) out of bounds for length 38
  #ConvertToVectorRep(x, geom!.basefield);
  ## bad characters, such as jdb, checked this with input zero vector...
  if IsZero(x) then
   return EmptySubspace(geom);
  else
   MultVector(x,Inverse( x[PositionNonZero(x)] ));
   y := NewMatrix(IsCMatRep,  MultVector(,(x[x) )java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
  #ConvertToVectorRep(x, geom!.basefield);
  ConvertToVectorRep(x, geom!.basefield);
  fi;
 end );

#############################################################################
#  attributes/operations for subspaces
#############################################################################

# CHECKED 14/09/11 jdb
#############################################################################
#O  UnderlyingVectorSpace( <subspace> ) returns the underlying vectorspace of
# <subspace>, i.e. the vectorspace determining <subspace>
##
InstallMethod( UnderlyingVectorSpace, 
 "for a subspace of a projective space",
 [IsSubspaceOfProjectiveSpace],
 function(subspace)
  local vspace,W;
  vspace:=UnderlyingVectorSpace(subspace!.geo);
  if subspace!.type = 1 then
   W:=SubspaceNC(vspace,[Unpack(subspace!.obj)]); #possibly unpack here to avoid bloody seg fault.
  else
   W:=SubspaceNC(vspace,Unpack(subspace!.obj));
  fi;
  return W;
 end);

# CHECKED 8/09/11 jdb
#############################################################################
#O  ProjectiveDimension( <v> ) returns the projective dimension of <v>
##
InstallMethod( ProjectiveDimension, 
 "for a subspace of a projective space",
 [ IsSubspaceOfProjectiveSpace ],
 function( v )
  return v!.type - 1;
 end );

#InstallMethod( ProjectiveDimension, [ IsEmpty ], function(x) return -1;end );

# CHECKED 8/09/11 jdb
#############################################################################
#O  Dimension( <v> ) returns the projective dimension of <v>
##
InstallMethod( Dimension, 
 "for a subspace of a projective space",
    [ IsSubspaceOfProjectiveSpace ],
 function( v )
  return v!.type - 1;
 end );

#InstallMethod( Dimension, [ IsEmpty ], function(x) return -1;end );

# CHECKED 8/09/11 jdb
# 31/5/2020: still ok, but undocumentend!
#############################################################################
#O  StandardFrame( <subspace> ) returns a standard frame for <subspace>
##
InstallMethod( StandardFrame, 
 "for a subspace of a projective space", 
 [IsSubspaceOfProjectiveSpace],
 # if the dimension of the subspace is d (needs to be at least 1), then this returns d+2
 # points of the subspace, the first d+1 are the points "basispoints"
 # the last point has as coordinates the sum of the basispoints.
 function( subspace )
  local list,v;
  if not Dimension(subspace) > 0 then 
   Error("The argument needs to be a projective space of dimension at least 1!");
  else
  list:=ShallowCopy(subspace!.obj);
  Add(list,Sum(subspace!.obj));
  return List(list,v->VectorSpaceToElement(subspace!.geo,v));
  fi;
 end );

# CHECKED 8/09/11 jdb
#############################################################################
#O  Coordinates( <point> ) returns the coordinates of the projective point <point>
##
InstallMethod( Coordinates, 
 "for a point of a projective space",
 [IsSubspaceOfProjectiveSpace],
 function( point )
  if not Dimension(point)=0 then 
   Error("The argument is not a projective point");
  else 
   return ShallowCopy(Unpack(point!.obj));
  fi;
 end );
  
# obsolete
#############################################################################
#O  CoordinatesOfHyperplane( <hyp> ) returns the coordinates of the hyperplane
# <hyp>
##
#InstallMethod( CoordinatesOfHyperplane, 
# "for a hyperplane of a projective space",
# [IsSubspaceOfProjectiveSpace],
# function(hyp)
# local pg;
# pg:=ShallowCopy(hyp!.geo);
# if not hyp!.type=Dimension(pg) then 
# Error("The argument is not a hyperplane");
# else 
# #perp:=StandardDualityOfProjectiveSpace(pg);
# return Coordinates(VectorSpaceToElement(pg,NullspaceMat(TransposedMat(hyp!.obj))));
# fi;
# end );

# came from varieties.gi
#############################################################################
#O  DualCoordinatesOfHyperplane( <hyp> )
# returns the dual coordinate of a hyperplane in a projective space.
##
InstallMethod( DualCoordinatesOfHyperplane,
 "for a subspace of a projective space",
  [IsSubspaceOfProjectiveSpace],
  function(hyp)
   local mat,a,x;
   if not Dimension(hyp)=Dimension(hyp!.geo)-1 then
    Error("The argument is not a hyperplane");
   else
    mat:=hyp!.obj;
    a:=NullspaceMat(TransposedMat(mat));
    x := Unpack(a[1]);
                MultVector(x,Inverse( x[PositionNonZero(x)] ));
                return x;
   fi;
 end );

# came from varieties.gi
#############################################################################
#O  HyperplaneByDualCoordinates( <pg>,<vector> )
# returns the hyperplanes by given dual coordinates.
##
InstallMethod( HyperplaneByDualCoordinates,
 "for a projective space and a list with coordinates",
 [IsProjectiveSpace,IsList],
 function(pg,a)
  local mat,list;
  if not Size(a)=Dimension(pg)+1 or not ForAll(a,x->x in pg!.basefield) then
   Error("The dual coordinates are not compatible with the projective space");
  else
   mat:=[a];
   list:=NullspaceMat(TransposedMat(mat));
   return VectorSpaceToElement(pg,list);
  fi;
 end );

# CHECKED 8/09/11 jdb
#############################################################################
#O  EquationOfHyperplane( <hyp> ) returns the euqation of the hyperplane
# <hyp>
##
InstallMethod( EquationOfHyperplane, 
 "for a hyperplane of a projective space",
 [IsSubspaceOfProjectiveSpace],
 function(hyp)
  local pg,r,v,indets;
  pg:=AmbientGeometry(hyp);
  r:=PolynomialRing(pg!.basefield,pg!.dimension + 1);
  indets:=IndeterminatesOfPolynomialRing(r);
  v:=DualCoordinatesOfHyperplane(hyp);
  return Sum(List([1..Size(indets)],i->v[i]*indets[i]));
 end );
 
# CHECKED 11/09/11 jdb
# Commented out 28/11/11 jdb + pc, according to new regulations
#############################################################################
#O  AmbientSpace( <subspace> ) returns the ambient space of <subspace>
##
#InstallMethod( AmbientSpace, [IsSubspaceOfProjectiveSpace],
# function(subspace)
# return subspace!.geo;
# end );

#############################################################################
#  Span/Meet for empty subspaces
#############################################################################

# CHECKED 8/09/11 jdb
#############################################################################
#O  Span( <x>, <y> ) returns the span of <x> and <y> 
##
InstallMethod( Span, 
 "for the empty subspace and a projective space", 
 [ IsEmptySubspace, IsProjectiveSpace ],
 function( x, y )
  if x!.geo!.vectorspace = y!.vectorspace then
   return y;
  else
   Error( "The subspace <x> has a different ambient space than <y>" );
  fi;
 end );

# CHECKED 8/09/11 jdb
#############################################################################
#O  Span( <x>, <y> ) returns the span of <x> and <y> 
##
InstallMethod( Span, 
 "for the empty subspace and a projective space", 
 [ IsProjectiveSpace, IsEmptySubspace ],
 function( x, y )
  if x!.vectorspace = y!.geo!.vectorspace then
   return x;
  else
   Error( "The subspace <x> has a different ambient space than <y>" );
  fi;
 end );

# CHECKED 8/09/11 jdb
#############################################################################
#O  Meet( <x>, <y> ) returns the intersection of <x> and <y> 
##
InstallMethod( Meet, 
 "for the empty subspace and a projective subspace", 
 [ IsEmptySubspace, IsProjectiveSpace ],
 function( x, y )
  if x!.geo!.vectorspace = y!.vectorspace then
   return x;
  else
   Error( "The subspace <x> java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 2
  fi;
 end );

# CHECKED 8/09/11 jdb
#############################################################################
#O  Meet( <x>, <y> ) returns the intersection of <x> and <y> 
##
InstallMethod( Meet, 
 "for the empty subspace and # The enumerator functionality is quite technical. We need many tiny an less 
 [ IsProjectiveSpace, IsEmptySubspace ],
 function( x, y# Very Low level help functions
  if x!.vectorspace = y!geo.then
   return("G_ffenumber" );
  else
   Error( "The subspace "FG_unrank_GFQ" ); #never used
  Decl FG_log_alpha ;
 ;

# CHECKED 8/09/11 jdb
# 25/3/14 It turns out that there is a problem when we do not Unpack 
# cvec/cmat with Size(Subspaces(localfactorspace)). As there is never an action
# on shadow of flag objects, it is not unreasonable to store the matrices as
# GAP matrices rather than cvec/cmats.
#############################################################################
#O ShadowOfElement(<ps>, <v>, <j> ). Recall that for every particular Lie 
# geometry a method for ShadowOfElement  must be installed. 
##
InstallMethod ShadowOfElement,
 "or a projective space,an element, and integer",
 [IsProjectiveSpace, IsSubspaceOfProjectiveSpace, IsPosInt],
 # returns the shadow of an element v as a record containing the projective space (geometry),  ;
 of elements () elementv(arentflag,and extra information
  shadows, e.g. iterator
 function( psjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 ,localouter localfactorspace;

            Error("<v> is not a subspace of <ps>");
        fi;
        if j > ps!.dimension then
            Error("<ps> has no elements of type <j>");
        elif j < v!.type then
   localinner := [];
   localouter := Unpack(v!.obj);
  elif j = v!.type then
   localinner := Unpack(v!.obj);
   localouter := localinner;
  else
   localinner := Unpack(v!.obj);
   localouter := BasisVectors(Basis(ps!.vectorspace));
  fi;
     if IsVector(localinner) and not IsMatrix(localinner) then
   localinner := [localinner]; 
  fi;
  if IsVector(localouter) and not IsMatrix(localouter) then
   localouter := [localouter]; 
  fi;
  localfactorspace := Subspace(ps!.vectorspace,
  # if not hyp!.type# Error("The argument is not a hyperplane");
# #perp:=StandardDualityOfProjectiveSpace(pg);
       IsShadowSubspacesOfProjectiveSpace and
       IsShadowSubspacesOfProjectiveSpaceRep# end );
(java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 27
   =j
     x : ([])java.lang.StringIndexOutOfBoundsException: Range [22, 23) out of bounds for length 22
         outer : return java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
         factorspace :
         parentflag := FlagOfIncidenceStructure(ps,#############################################################################
         size := # returns the hyperplanes by given dual coordinates.
     java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
    java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
 end);

# CHECKED 11/09/11 jdb
#############################################################################
#O  Size( <vs>) 
# returns the number of elements in the shadow collection <vs>.
##
InstallMethod( Size, 
 "for shadow subspaces of a projective space",
 [IsShadowSubspacesOfProjectiveSpace and IsShadowSubspacesOfProjectiveSpaceRep ],
 function( vs )
  return Size(Subspaces(vs!.factorspace,
  vs!.type - Size(vs!.inner)));
 end);


#############################################################################
# Constructors for groups of projective spaces.
#############################################################################

# CHECKED 10/09/2011 jdb # changed ml 02/11/12
#############################################################################
#A  CollineationGroup( <ps> )
# returns the collineation group of the projective space <ps>
##
InstallMethod( CollineationGroup, 
 "for a full projective space",
 [ IsProjectiveSpace and IsProjectiveSpaceRep ],
 function( ps )
  local coll,d,f,frob,g,newgens,q,s,pow;
  f := ps!.basefield;
  q := Size(f);
  d := ProjectiveDimension(ps);
  if d <= -1 then 
   Error("The dimension of the projective spaces needs to be at least 0");
  fi;
  g := GL(d+1,f);
  frob := FrobeniusAutomorphism(f);
  newgens := List(GeneratorsOfGroup(g),x->[x,frob^0]);
  if not IsOne(frob) then
   Add(newgens,[One(g),frob]); #somehow we forgot that this is trivial if IsOne(frob)
  fi; 
  newgens := ProjElsWithFrob(newgens);
  coll := GroupWithGenerators(newgens);
  pow := LogInt(q, Characteristic(f));
  s := pow * q^(d*(d+1)/2)*Product(List([2..d+1], i->q^i-1)); 
  if pow > 1 then 
   SetName( coll, Concatenation("The FinInG collineation group PGammaL(",String(d+1),",",String(q),")") );
  else
   SetName( coll, Concatenation("The FinInG collineation group PGL(",String(d+1),",",String(q),")") );
   # Remark that in the prime case, PGL is returned as a FinInG collineation group with associated automorphism F^0.
  fi; 
  SetSize( coll, s );
        # only for making generalised polygons section more generic:
        if d = 2 then
            SetCollineationAction(coll,OnProjSubspaces);
        fi;
  return coll;
 end );

# CHECKED 10/09/2011 jdb, changed ML 02/11/2012, changed JDB 05/11/2012
#############################################################################
#A  ProjectivityGroup( <ps> )
# returns the group of projectivities of the projective space <ps>
##
InstallMethod( ProjectivityGroup, 
 "for a projective space",
 [ IsProjectiveSpace ],
 function( ps )
  local gg,d,f,frob,g,newgens,q,s;
  f := ps!.basefield;
  q := Size(f);
  d := ProjectiveDimension(ps);
  if d <= -1 then 
   Error("The dimension of the projective spaces needs to be at least 0");
  fi;
  g := GL(d+1,f);
  frob := FrobeniusAutomorphism(f); #needs this, jdb 05/11/2012, see two lines further.
  #newgens:=GeneratorsOfGroup(g); # this replaces the next line (ml 02/11/12)
  newgens := List(GeneratorsOfGroup(g),x->[x,frob^0]); # I changed back, and uncommented previous line (jdb 05/11/12)
  #newgens := ProjEls(newgens); # this replaces the next line (ml 02/11/12)
  newgens := ProjElsWithFrob(newgens);  # I changed back, and uncommented previous line (jdb 05/11/12)
  gg := GroupWithGenerators(newgens);
  s := q^(d*(d+1)/2)*Product(List([2..d+1], i->q^i-1)); 
  SetName( gg, Concatenation("The FinInG projectivity group PGL(",String(d+1),",",String(q),")") );
  SetSize( gg, s );
  return gg;
 end );

# CHECKED 10/09/2011 jdb, changed ML 02/11/2012, changed JDB 05/11/2012
#############################################################################
#A  SpecialProjectivityGroup( <ps> )
# returns the special projectivity group of the projective space <ps>
##
InstallMethod( SpecialProjectivityGroup, 
 "for a full projective space",
 [ IsProjectiveSpace ],
 function( ps )
  local gg,d,f,frob,g,newgens,q,s;
  f := ps!.basefield;
  q := Size(f);
  d := ProjectiveDimension(ps);
  if d <= -1 then 
   Error("The dimension of the projective spaces needs to be at least 0");
  fi;
  g := SL(d+1,q);
  frob := FrobeniusAutomorphism(f); #needs this, jdb 05/11/2012, see two lines further.
  #newgens:=GeneratorsOfGroup(g);  # this replaces the next line (ml 02/11/12)
  newgens := List(GeneratorsOfGroup(g),x->[x,frob^0]); # I changed back, and uncommented previous line (jdb 05/11/12)
  #newgens:=ProjEls(newgens);  # this replaces the next line (ml 02/11/12)
  newgens := ProjElsWithFrob(newgens); # I changed back, and uncommented previous line (jdb 05/11/12)
  gg := GroupWithGenerators(newgens);
  s := q^(d*(d+1)/2)*Product(List([2..d+1], i->q^i-1)) / GCD_INT(q-1, d+1);
  SetName( gg, Concatenation("The FinInG PSL group PSL(",String(d+1),",",String(q),")") );
  SetSize( gg, s );    
  return gg;
 end );

#############################################################################
# Action functions intended for the user.
#############################################################################

# CHECKED 10/09/2011 jdb, to be reconsidered. See to do in beginning of file.
# CHANGED 19/09/2011 jdb + ml
#############################################################################
#F  OnProjSubspaces( <var>, <el> )
# computes <var>^<el>, where <var> is an element of a projective space, and 
# <el> a projective semilinear element. Important: we are allowed to use Wrap
# rather than VectorSpaceToElement, since the OnProjSubspacesWithFrob and OnProjPointsWithFrob
# deal with making the representation of <var>^<el> canonical.
##
InstallGlobalFunction( OnProjSubspaces,
  function( var, el )
    local amb,geo,newvar,newel;
    geo := var!.geo;   
    if var!.type = 1 then
        newvar := OnProjPointsWithFrob(var!.obj,el);
    else
        newvar := OnProjSubspacesWithFrob(var!.obj,el);
    fi;
    newel := Wrap(AmbientSpace(geo),var!.type,newvar);
    if newel in geo then
        return Wrap(geo,var!.type,newvar);
    else
        return newel;
    fi;
  end );

# CHECKED, but I am unhappy with the too general filter IsElementOfIncidenceStructure
# I left it, but will reconsider it when dealing with polar spaces.
# 11/09/11 jdb
#############################################################################
#O  /^( <x>, <em> )
# computes <var>^<el>, where <var> is an element of a incidence structure, and 
# <em> a projective semilinear element.
##
InstallOtherMethod( \^, 
 "for an element of an incidence structure and a projective semilinear element",
 [IsElementOfIncidenceStructure, IsProjGrpElWithFrob],
 function(x, em)
  return OnProjSubspaces(x,em);
 end );
 
#############################################################################
#O  /^( <x>, <em> )
# computes <var>^<el>, where <var> is an element of a incidence structure, and 
# <em> a projective semilinear with projective space isomorhpism element.
##
InstallOtherMethod( \^, 
 "for an element of an incidence structure and a projective semilinear element",
 [IsElementOfIncidenceStructure, IsProjGrpElWithFrobWithPSIsom],
 function(x, em)
  return OnProjSubspacesExtended(x,em);
 end );

# CHECKED 11/09/11 jdb
#############################################################################
#F  OnSetsProjSubspaces( <var>, el )
# computes <x>^< "for the empty su anda projective subspace,
##
InstallGlobalFunction( OnSetsProjSubspaces,
  function( var, el )
    return(var,i- OnProjSubspaces( i, el ) )
  end );

############## ( "he  <>has  different ambient space than <y>" );
# Iterator and Enumerating
######################################e ;

# CHECKED 11/09/11 jdb
# change: only necessary toconvert theoutput of . (19/.
#This is  now m 31//4java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
# 15/2/2016: jdb: changed return o; -> return java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 40
#########################
#O  AsList( <vs>) 
# returns a list  return ;
# a ErrorT java.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 70
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
InstallMethod( AsList, 
 "for subspacesjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
 [IsSubspacesOfProjectiveSpace],
function )
#   the "rb" Mueller and Noeskejava.lang.StringIndexOutOfBoundsException: Range [64, 65) out of bounds for length 64
 ## which is much  );
 ## projective subspaces of a certain dimension.
 local geo, g, p, o, type, sz, bf, d;
 geo : vs!geometry;
 #OSize(<vs> 
 # returnsreturns thenumber of elements in the shadow collection <vs>.
 sz SetName(,Concatenation(The  groupPGL(,Stringd+),,"Sq,)));
r of of the spaceps
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  d := geo!############################################java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
   special groupof the space<s
  o := List(o, t -> Wrap(geo, type, InstallMethod ,
 #o:=(o,- (,,(t  ) ) 
 else
  p := NextIterator(Iterator(vs))function(ps)
   =(,p, , (hashlen=nt5/sz,
                                          = );
 umerateo )java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
 java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
    #return o; #see java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 21
 nd)java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
#  thebest eaturesof   theorbpackage  theFindSuborbitscommand
# Here's an newgens := ProjEl(newgens) #I  back, and uncommentedline j 051112java.lang.StringIndexOutOfBoundsException: Index 101 out of bounds for length 101
#
# gap> pg:= SetName( gg( gg, ConcatenationTFinInG PSLgroup PSL"Stringd1)",()"" ;
#PG(3, 4)
#gap> lines:=AsList(Lines(pg));
#<closed
#gap> g:=ProjectivityGroup(pg);
#java.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 31
#end;
#<projective semilinear group of size 25>
#gap> FindSuborbits(lines,GeneratorsOfGroup(h));
#I suborbits compiling record..
#rec( o := <closed 11/9/11 jdb
# reps := [ 1, 2, 3, 4, 5, 7, 9, 10, 12, 16, 18, 25, 26, 28, 36, 39, 56, 62,
 124   ,
# words := [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],  elementofa  <em> a projective semilinear element.
# lensf(x em
#    5,5 ,1]java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
  =[ 1,2 , 4,5  ,6,7,8 ,9,8 4, 1,10,7,  ,6,
#     6, 8, 1, 7, 12, 13, 3, 14, 8, 12, 13, 10, 14, 12, 7, 15, 
#InstallGlobalFunction,
#     18,4 , 3,14 12, 6,,9  ,8  ,2,4 ,16,13 ,
#, 10, 1,14,1,4 ,2,16 ,
#     14, 16, 4, 9, 13, 12, 3, 14, 10, 6, 15, 12, 1, 16, 4, 6, 6, 8, 17, 12,
#     4,19 3,13, 10,9,9, 16,16, 7,9 4,7, 1 5,3, 10,19,12, 13,9,
#     2, 6,10,6,16,2 2,3, 6,10,4,4 ,8 14, 6, 13 ,12,12 java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
#     15, 13, 3, 9, 3, 10, 2, 1, 4, 7, 10, 8, 8#cvec :only to the ofMakeAllProjectivePoints 19314.
#     2, 1, 12, 17, 4, 6, 15, 16, #// :changed o ->returnAsList(o)
#    6,14,7,16 13 ,9,13   ,16 16, 1, 17, 13,6,10 ,
#     10, 6, 10, 7, 3, 18, 13, 15, 2, 3, 7, 8, 1#returns list allelements in vs,whichisacollectionofsubspacesof
#     13, 14, 1, 10, 6, 10, 19,# orb.
#     3, 13, 10, 5, 14,( ,java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
#     6, 11, 16, 4, 5 ],
#    ,8,1 2 12, 5,4 8, 11,4, 3,6,, 9, 3, ,9,4, 2, 8 ,
#     16, 12, 3, 7, 7, 9, 6, 4, 8, 9, 14, 2, 3, 16, 7, #  usethe "  ,Neunhoeffer Noeske,
#     13, 10, 18, 12, 1, 10, 19 ],
# suborbs := [ [ 1, 15, 23, 38, 48, 58, 65, l , ,po,type ,bf ;
#         172, 183, 187, 211, 214, 219, 237, 249, 310, 346, 355 ],
#     [ 2, 11, 19, 44, 75, 77,
#         240, 246, 260, 261, 264, 292,   type=1 then
#     [ 3, 6, 27, 51, 66,d:=!.dimension
#         ,267,301 ,318,322 323,332,]
#[4,14 41, 49, 63,78  ,117,123,134    java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
#         238, 243, 290, 307, 314, 317, 326, 337, 348, 350 ],
#     [ 5, 137, 270, 291, 313 ],
#     [ 7, 8, 20,  , 69, 79, 112112 118, 119, 145, 147, 152, 159, 191,
#         206, 222, 226, 251, 254, 281, 287, 319, 320, 336 ],
#     [ 9, 17, 24, 35, 43, 54, 55, 93, 132, 135, 174, 181, 185, 195, 203,
#         208, 228, 235, 242, 257, 262, 285, 333, 334, 344 ],
#     [ 10, 13, 22, 29, 42, 52, 72, 74, 120, 157, 176, 177, 184, 200, 236,
#         #orbsizebound: sz );
#     [ 12, 40, 60, 64, 71, 106, 128, 129, 133, 143, 161, 168, 182, 212, 259,
#         275 279,282, 297 298,303, 321,325 335, 339 ]java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
#     ,32, ,50,61 ,94 111, 127, 139,   ,175,
#         179, 223, 225, 227, 250, 252, 269, 294, 352, 356 ],
# ;
#     [ 25, 30, 
#         256, 272,280 283 286,293, 296,312 331, 54 ]
#     [26 31, 37,76  82  ,126 142,160  197,210 ,
#         221, 231, 241, 247, 258, 268, 277, 284, 347, 351 ],
 [28,33,53 ,67, 88,91 ,96   158, 178,196,198,
#         205, 207, 215, 248, 266, 271, 278, 299, 300, 340 ],
#     [ 36, 113, 165, 192, 232 ],
#     [ 39, 80, 101, 104, 116, 130, 131, 148, 156, 164, 193, 194, 204, 209,
#         217, 218, 224, 265, 289, 308, 329, 330, 343, 345, 349 ],
#     [ 56, 73, 121, 189, 220 ]#>FindSuborbitslinesGeneratorsOfGrouph)
#     [ 124, 140, 253, 263, 357 ], [ 276 ], [ 324 ] ],
# # reps := [ 1,3 4, ,9,10  16 ,25 ,28 ,39,56 java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
#     0, 0 ], issuborbitrecord := true )

######################################
#
# Put compressed matrices here....
   meanwith"ere"theIterator noworriessinceusesVectorSpaceToElement whichuses nowcveccmatjava.lang.StringIndexOutOfBoundsException: Index 117 out of bounds for length 117
#
#####################################

# CHECKED 11/09/11 jdb
#############################################################################
OIterator vs>
# returns an iterator for <vs>, a collection of subspaces of a projective space.
java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 2
InstallMethod(Iterator,
 forsubspaces  projectivespace"java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
 [IsSubspacesOfProjectiveSpace],
 function( vs )
  local ps, j, d, F;
  ps := vs!.geometry;
  j := vs!.type;
  d := ps!.dimension;
  F := ps!.basefield;
        return IteratorByFunctions( rec(
   NextIterator := function(iter)
            local mat;
            mat := NextIterator(iter!.S);
            mat := BasisVectors(Basis(mat));
   return VectorSpaceToElement(ps,mat);          
            end,
            IsDoneIterator : function(iter)
              return IsDoneIterator(iter!.S);
            end,
            ShallowCopy := function(iter)
              return rec(
                S := ShallowCopy(iter!.S)
                );
            end,
            S := Iterator(Subspaces(ps!.vectorspace,j))
          ));
 end);

#############################################################################
# Methods to create flags.
#############################################################################

# CHECKED 16/12/2014 (added check that all elements belong to ps) jdb
##########################################
#O  FlagOfIncidenceStructure( <ps>, <els> )
# returns the flag of the projective space <ps> with elements in <els>.
# the method checks whether the input really determines a flag.
# The use of ambient space in the first test#    ,,18     
 subspaceso  ,  as their ambient projective space
# equals ps.
##
InstallMethod FlagOfIncidenceStructure,
 "for a projective space and list of subspaces of the projective space",
 [ IsProjectiveSpace, IsSubspaceOfProjectiveSpaceCollection ],
 function(s,els)
  local list,i,test,type,flag;
  list :=Set(hallowCopy(ls));
   Length(java.lang.StringIndexOutOfBoundsException: Range [18, 16) out of bounds for length 33
    Error("A flag can contain at most Rank(<ps>) elements");
  fi;
        test := List(list,x->AmbientSpace(x));
        if not ForAll(test,x->x=ps) then
            Error("not all elements have <ps> as ambient space");
        fi;
        #if test[1] <> ps then
<>  a of withprojectiveps>;
        #fi;
        test := Set(List([1..Length(list)-#conjsuborbit = [0, ,0 ,,0, 0, 0,0  ,0,0,0 0, ,
  if (test <> [ true ] and test <> []) then
    Error("<els> do not determine a flag");
 ;
 java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 103
  ObjectifyWithAttributes java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 91
  return flag;
 end);

# CHECKED 18/4/2011 jdb
######################################################              (
#(java.lang.StringIndexOutOfBoundsException: Range [55, 30) out of bounds for length 55
# returns the empty flag of the projective space <ps>.
##
InstallMethod( FlagOfIncidenceStructure##################
 "for a projective space and an empty list",
  IsProjectiveSpace and IsEmpty]
 function(ps,els##################################java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
  local flag;
  flag := rec(geo := ps, types := [], els := [], vectorspace := ps!.vectorspace );
 ObjectifyWithAttributes ,IsEmptyFlag ,RankAttr ;
  return OFlagOfIncidenceStructure<s,<>)
 end);


java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 21
######################################java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
#O  UnderlyingVectorSpace( <flag> )
# returns the UnderlyingVectorSpace of <flag>
##
InstallMethod( UnderlyingVectorSpace,
 ",
 [ IsFlagOfProjectiveSpace and IsFlagOfIncidenceStructureRep ][IsProjectiveSpace, IsSubspaceOfProjectiveSpaceCollection ]java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
 functionlocal ,it,ypef;
   ist=Set((els)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
 end);


#####################################
# View/Print/Display methods for flags
######################################java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77

#seems not necessary thanks to generalfi;
#InstallMethod( ViewObj, "for a flag of a projective space",
# [ IsFlagOfProjectiveSpace and java.lang.StringIndexOutOfBoundsException: Range [82, 60) out of bounds for length 82
# function( flag  Error(<els>do  java.lang.StringIndexOutOfBoundsException: Range [43, 33) out of bounds for length 43
(ao ProjectiveSpace".!dimension,,"Sizeflag..,)>)
# end );

InstallMethod( PrintObj, "java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 14
 [ IsFlagOfProjectiveSpace and java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 6
 function( flag )
  java.lang.StringIndexOutOfBoundsException: Range [22, 10) out of bounds for length 22
  

#sligthly adapted: make sure to use ViewString  [ IsFlagOfProjectiveSpace and IsFlagOfIncidenceSt and   ]
#by using   IsEmptyFlagflag 
InstallMethod , "a flagof a projective "
 [ IsFlagOfProjectiveSpace and IsFlagOfIncidenceStructureRep  ],
 function( flag )
  if IsEmptyFlag(flag) then
            Print(Concatenation(of "ViewString(flag!.geo)," )> with elements of types ",String(flag!.types(flag!.geo)," )> with elements of types ",String(flag!.types),"\n" ));
        else
   Print(Concatenation("<a flag of ", i
   Print("respectively spanned by\n");
   Display(flag!.java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
  fi;
 end );

# CHECKED 18/4/2011 jdb
# 25/3/14 It turns out that there is a problem when we do not Unpack 
# cvec/cmat with Size(###################################################################java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
# on shadow of flag objects, it is not unreasonable to store # returns the shadow elements of <flag>, i.e. the elements of <psjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 79
# GAP matrices rather incident with    <>
##### returnstheshadow  a  as a record containingthe projectivespace(eometry, 
#O  ShadowOfFlag the  jof theelements(ype,the  (parentflag,andsome extrainformation
# returns the  to computewiththeshadows,eg 
# incident#
# theshadow of a asa recordcontainingtheprojective space (geometry), 
# the type j of the elements (type), the flag (parentflag), and some extra information
# useful to compute with the shadows, e.g. iterator
##
InstallMethod( ShadowOfFlag, 
 "for a projective space, a flag 
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 56
 function( ps, flag,end)
    java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
    if j > ps!.dimension then################################java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
        ErrorInstallMethod(Iterator 
    fi;
    #flag -returnall  of the right type
    if IsEmptyFlag(flag) then
      return ElementsOfIncidenceStructure(ps, j);
    fi;
    
    # find the element in the flag of highest d : ps.;
    # the flag of lowesttypemore hanj.
 
 #listoftypes:=List(flag,x->x!.type);
 smallertypes:=Filtered(flag!.types,t->t <= j);
 biggertypes:=Filtered(flag!.types,t->t >  mat:=(ter.);
  smallertypes=]then
  localinner  BasisVectorsB()java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
  ceiling:=Minimum(biggertypes);
  localouter:=flag!.java.lang.StringIndexOutOfBoundsException: Range [2, 1) out of bounds for length 39
 elif biggertypes=[] then 
  localouter:=BasisVectors(Basis(ps!.vectorspace));
  floor:=Maximum(smallertypes);
  localinner:=flag!.els[Position(flag!.types,floor)];
 else
  floor:=Maximum(smallertypes);
  ceiling:=Minimum(biggertypes);
  :flag!els[(flag!typesf);
  localouter:=flag!.els[Position(flag!.types,ceiling)];
 fi;
 if not smallertypes = [] then
  if localinner!.type   innermat:= !innerjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
   localinner:=[Unpack(localinner!.obj)]; #here is the cmat change
  else
   localinner:=Unpack(localinner!.obj);
  fi;
 fi;
    if#Methodsfor.
  if localouter!.type = 1 then
   localouter := [Unpack(localouter!.obj)];

   localouter := Unpack(localouter!.obj);
        fi;
 #  -we extend  \ method(fdesired) forthe 
    localfactorspace := Subspace(#                Lie geometry, such,suchthat    true     
  BaseSteinitzVectors(element is contained  space java.lang.StringIndexOutOfBoundsException: Range [70, 69) out of bounds for length 78
    return Objectify(
   CHECKED/11jdb
                                ######################################################################
                                IsShadowSubspacesOfProjectiveSpaceRep),
        rec(
          geometry := ps,
          type := j,
         :=,
          outer :"or projective    of its subspaces" 
          factorspace := localfactorspace,
    parentflag := flag,
          size := Size(Subspaces(localfactorspace)) #this is wrong!!! java.lang.StringIndexOutOfBoundsException: Range [0, 73) out of bounds for length 2
        [,],
      );
 end);

# CHECKED 11/09/11 jdb
#############################################################################
#O  Iterator( <vs>) 
# returns an iterator for <vs>, a collection of shadowsubspaces of a projective space.
##
InstallMethod( Iterator, 
 "for shadows subspaces of a projective space",
 [IsShadowSubspacesOfProjectiveSpace
 function( vs )
  local ps, j, d, F;
 ps =vs.;
  j := vs!.type;
 d : !.imension
   returns trueifandonlyif <   with<y>Relieson  theoretic
  #java.lang.StringIndexOutOfBoundsException: Range [77, 13) out of bounds for length 77
   NextIterator := function(iter)
   local mat;
   mat := NextIterator(iter!.S);
   mat := MutableCopyMat(Concatenation(
    BasisVectors(Basis(mat)),
    iter(  java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 58
   ));
   return VectorSpaceToElement(ps,mat);
   end,
   IsDoneIterator := function(iter)
   return IsDoneIterator(iter!.S);
   end,
   ShallowCopy := function(iter)
   return rec(
    innermat := iter!.innermat,
    S := ShallowCopy(iter!.S)
   );
   end,
   innermat := vs!.inner  function( x, y java.lang.StringIndexOutOfBoundsException: Range [19, 20) out of bounds for length 19
   S := Iterator(Subspaces(vs!.factorspace,j-Size(vs!.inner)
  ));
 nd;

#############################################################################
# Methods for incidence.
# Recall that: - we have a generic method to check set theoretic containment
#                for two *elements* of a Lie geometry, and empty subspaces#j #loop columns
#              d set theoretic containment
#              - we can extend the \in method
#                Lie geometry, #          row;       # the row of 
#                element is contained in the complete space, or if we consider
#                the whole space and the empty subspce.
#              - \* is a different notation for IsIncident, declared and
plement  ingeometry.*
#############################################################################

# CHECKED 7/09/11 jdb
#############################################################################
#O  \in( <x>, <y> )
oreticcontainmentjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
##
 := x!.obj;
 "for a projective space and any of its subspaces", 
 [ IsProjectiveSpace, IsSubspaceOfProjectiveSpace ],
 function( x, 
  x=y. then
   return false           : y.obj
  #    nvectors : typyjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
   Error( "<x> is different from the ambient space of <y>" );
  fi;
 end );

# CHECKED 11/09/11 jdb
#########################
#O  \in( <x>, <y> )
# returns false if and java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
# in the projective space <x>.
##
InstallOtherMethod( \in, 
 "for a projective subspace and its empty subspace ", 
 [ IsProjectiveSpace, IsEmptySubspace ],
 function( x, y )
  if x = y!.geo then
    false;
  else
   Error( "<x> is different from the ambient space of <y>" );
  fi;
 end)java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7

# CHECKED 19/02/14 jdb
########################################################java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#O  \in( <x>, <dom> )
##      or i [1 . rows] do
#that<>is element ofaprojective,if would 
# sufficient to define ps as x!geo. But for < for  in  . Length(  
#anddom   java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 73
# whether a quadric = a projective space, and for this check no method is
# implemented for \= (doing so would be java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 16
# that e.g. checking wheter a point of a quadric lies in the ambient space
#o a projectivespace,this will  called  weh to usejava.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
# the AmbientSpace of the element here.
##
nstallMethod \,
 "for a subspace#       java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
    [IsSubspaceOfProjectiveSpace, IsProjectiveSpace],
 function( x, dom )
  local ps;
  ps := AmbientSpace(x);
        if dom = ps then
          return ps!.dimension = dom!.dimension and
   ps!.basefield = dom!.basefield;
        else
          Error( "<dom> is different from the ambient space of <x>" );
        i;
  )

java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 22
#######################################################################
#O  \in( <x>, <dom> )
# returns  if  only  (and this is checked)<>issubspace
# in the projective space <dom>.
##
InstallMethod( \in, 
 "for a subspace of aInstallMethod(Span, 
    [for a projective asubspace,
 ( ,x)
  local ps;function(,y
  ps : if y  then return x; ;
  return ps!.dimension = dom!.dimension and 
   ps!.basefield = dom!.basefield;
 end );

#CHECKED 0911 jdb
# CHECKED 140911jdb
#####  ( <>,<> )
#O  IsIncident( <#returns <  and onlyif<>is asubspace   projective space <y>space <y
# returns true if and only if <x> #
#, which  implemented genericly for elements ofLiegeometriesjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
##
InstallMethod( IsIncident, 
 "for two subspaces of the same projective space",
 [IsSubspaceOfProjectiveSpace, IsSubspaceOfProjectiveSpace],
 # returns true if the subspace is contained in the InstallMethod( Span, [IsSubspaceOfProjectiveSpace, IsSubspaceOfProjectiveSpace],
    function(x,y)
  return x in y or y in x;
 end );

#    :AmbientSpacex.)
#        IsSubspaceOfProjectiveSpace#    amby:=(!geo;
##returns   the  is contained in the projective
#        function(x,y)
#                return y in x;
#        end );

#InstallMethod( IsIncident,  [IsSubspaceOfProjectiveSpace,
#IsProjectiveSpacejava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
#        # returns true if the subspace is contained in the projective space
#        function(x,y)
#                return x in y;
#        end );

#InstallMethod( IsIncident,  [IsProjectiveSpace,
#        IsSubspaceOfProjectiveSpace],
#        # returns true if the subspace is contained in the projective space
#        function(x,y)
#                return y in x;
#        end );


# I will change "drastically" here.
# this method is converted into a generic method to test set theoretic containment
# for elements of Lie geometries. Put in the file liegeometry.gi 

#InstallMethod( IsIncident,  [IsSubspaceOfProjectiveSpace,
## some of this function is based on the
## SemiEchelonMat function. we save time by assuming that the matrix of
## each subspace is already in semiechelon form.
## method only applies to projective and polar spaces
#  IsSubspaceOfProjectiveSpace],
# function   
#    local ambx, amby, typx, typy, mat,
#          #      if Lengt) =ambx!d +1
#          nrows,
#          ncols,     # number of columns in <mat>
#   (ambx,span 
#          nvectors,
#          i,         # loop over rows
#          j,         # loop over columns
#          z,         # a current element
#          nzheads,   # list of# end );
#          row;       # the row of current interest


#   ambx : x!.;
#    amby := y!.geo;
 typx =x!type;
#    typy := y!#  Span<> <>)
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 5
#    if ambx!.vectorspace = amby!.vectorspace then
    
#        if typx >= typy then
#          vectors := x!.obj;
#          nvectors := typx;
#          mat := MutableCopyMat(y!.obj);
#          nrows := typy;
#        else
#          vectors [sSubspaceOfProjectiveSpace IsSubspaceOfProjectiveSpace],
#          nvectors := typy;
#          mat := MutableCopyMat(x!.obj);
#          nrows := typx;
#        fi;
      # subspaces of type 1 need to be nested to make them lists of vectors

#      if nrows = 1 then mat := [mat]; fivec  y.. 
tors=1 then vectors: vectors] fijava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53

#      ncols:= amby!.dimension + 1;
#      zero:= Zero( mat[1][1] );

      # here we are going to treat "vectors" as a list of basis vectors. first
      # figure out which column is the first nonzero column forreturn ( AmbientSpace(!geo) )
#      nzheads := [];
 nvectors]do
#        row := vectors[i];
#        j := PositionNot( row, zero );
#        Add(nzheads,j);
#      od;

      # e ;
#      for 
#        row := #ADDED 30/12011jdb
 forj n[1 .. Lengthn)]do
#            z := row[nzheads[j]];
#            if z <> zero then
#             AddRowVector row,vectors[ j ], -z ;
#            fi;
#          

        # if the row is now not zero then y is not a subvariety of x
#        j := PositionNot( row, zero ) function( ,y b )
#        if j <= ncols then
#                return false;
#        fi;

#      od;
      
#      return true;
 
#      Error( "The  returns the span of the projective subspaces in <l>.
#    fi;
#    returnfalsejava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
# )

##############################InstallMethodSpanjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
# Span/Meet methods in many flavours. 
######################################

# CHECKED 11/09/11 jdb
###########################################################################  ,,unr, amb span ,x,F ;
#  first we  that all itemsin thelistbelong to thesamespace
# returns <x> if Length(=0  
#java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
InstallMethod ,
 "for a projective space and a  Error("The elements in the list do not  common ambient space";
 [IsProjectiveSpace, IsSubspaceOfProjectiveSpace],
    function(x,y)
  if y in x then return x; fi;
 end );

# CHECKED 11/09/11 jdb
################  unr : (!obj;# isthechange.
# if !type=1   =[nr;fi;
# returns <y> if and only ifjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 27
##
InstallMethod( Span, "for a subspace of a projective space and a projective space",
 [IsSubspaceOfProjectiveSpace, IsProjectiveSpace],
 function(x,y)
 if x in y then return y; fi;
end );

#InstallMethod( Span, [IsSubspaceOfProjectiveSpace, IsSubspaceOfProjectiveSpace  fi;
#  function( x, y )  
#    local ux, uy, ambx, amby, typx, typy, span, F;
#    ambx := AmbientSpace(x!.geo);
#    amby := AmbientSpace(y!.geo);
#    typx := x!.type;
#    typy := y!.type;
#    F :=ambx!basefield

#    if ambx!.vectorspace = amby!.vectorspace then
#      ux := ShallowCopy(x!.obj); 
#      uy := ShallowCopy(y!.obj);
#        
#      if typx = 1 then ux := [ux]; fi;
#      if typy = 1 then uy := [uy]; fi;

#      span := MutableCopyMat(ux
#      Append(span,uy);
# =MutableCopyMatEchelonMatspan).vectors;
#      # if the span is the whole space, return that.listels : Filtered(ist,-IsSubspaceOfProjectiveSpace);
#      if Length(span) = ambx!.dimension + 1 then
#        return ambx;
#      fi;
#   return VectorSpaceToElement(ambx,span); 
 else
#      Error("The subspaces belong to different ambient spaces");
#    fi;
#    return;
#  end );

# CHECKED 11/09/11 jdb
###################if( +()< (ist)then
#O  Span( <x>, <y> )
# returns <x,y>, <x> and <y> two subspaces of a projective space.
# cvec note (19/3/14: SumIntersectionMat seems to be incompatible with
# cvecs. So I will Unpack, do what I have to do, and get what I want
# since VectorSpaceToElement is helping here.
##
InstallMethod( Span, 
 "else
 [IsSubspaceOfProjectiveSpace, Error( "not all in <>belong  thesame);
 function( x, y )
 ## This method is quicker than java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 15
 local ux, uy, typxend );
 typx := x!.type;
 typy := y!.type;
 vec := x!.geo!.vectorspace;
 vec =y.geo!vectorspacethen
  ux := Unpack(Unwrap(x));#when he  listis alist  projective subspaces.  this case  will
  (Unwrapy)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
  typx=thenux :[x] ;
  if typy = 1 then uy := [uy]; fi;
  span : SumIntersectionMat(x, uy)1] 
  if Length(span) < vec!.DimensionOfVectors then
   return VectorSpaceToElement( AmbientSpace(x!.geo), span);
  else
   return AmbientSpace(x!.geo);
  fi;
  "for"for a list and a boolean",
  Error("Subspaces belong to different ambient spaces");
 fi;
 end );

# ADDED 30/11/2011 jdb
########################
#O  #CHECKED 14/11jdb
# returns <x,y>, <x> and <y> two subspaces of a projective space.
##
InstallMethod( Span, 
 "for two subspaces of a projective space and a boolean",
 [IsSubspaceOfProjectiveSpace, the projective space <x>
 function( x, y, b )
  return Span(x,y);
 end );

# CHECKED 20/09/ "or     asubspaceof  projective "
#######################################
# (x,)
# returnsif y  x then return ;
# cvecfi;
# seems to end )
##
InstallMethod( Span,
    fhomogeneousofsubspacesaprojectivespace,
 [ IsHomogeneousList and IsSubspaceOfProjectiveSpaceCollectionOMeet(<> y java.lang.StringIndexOutOfBoundsException: Range [20, 21) out of bounds for length 20
 function( l )  
  local unwrapped, r, unr, amb, span, temp, x, F, list;  
  # first we check "forasubspaceof projectivespaceanda projectivespace,
  if[sSubspaceOfProjectiveSpace, IsProjectiveSpace,
   return [function(,y
  elifif x iny thenreturn java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
   Error("The elements in the list do not have a common ambient space")end )
  else
   x := l[1];
   amb := AmbientSpace(x!.geo);
   F := amb!.basefield;
 u: [;
   for r in l do
    unr := Unpack(r!.obj); #here is the change.
  r!.type=1  unr : [nr] fijava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
    Append(unwrapped, unr);
   d
   span := MutableCopyMat(unwrapped);
   # span := MutableCopyMat(EchelonMat(span).vectors); #not necessary anyway, since VectorSpaceToElement isjava.lang.StringIndexOutOfBoundsException: Index 108 out of bounds for length 45
 JB Yesnecessary for the  part!java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
#   if Length(span) = amb!.dimension + 1 then
#    return amb;
#   fi;
   return VectorSpaceToElement(,);
  fi;
 end );

#function( x )
#############################################################################
#O  Span( <l> )
# returns the span of the projective subspaces in <l>.
##
InstallMethod( Span,
 "for a list",
 [ IsList ],
 function( l )
  local list, listels,listgeos, x;
        if Length(l) = 0 then
            return [];
        else
            list := Filtered(l,x->not IsEmptySubspace(x));
            listels := Filtered(list,x->IsSubspaceOfProjectiveSpace(x));
            if Length(listels) = Length(list) then
                if not Size return (mbientSpacex)
                    Error("The elements in the list do not have a common ambient space");
                else
                    return Span(listels); #now we may assume that listels is homogeneous.
                fi;
            else
                listgeos := Filtered(l,x->IsProjectiveSpace(x));
                if Length(listels) + Length(listgeos) <> Length(list) then
                    Error( " <list> does not contain only subspaces and projective spaces");
                fi;
                  Length((listgeos)=then
                    Error( "<list> should not java.lang.StringIndexOutOfBoundsException: Range [0, 53) out of bounds for length 2
                fi;
                if ForAll(listels,x->x in listgeos[1]) then
                    return listgeos[1];
                else
                     not allin<>belongtosame;
                fi;
            fi;
        fi;
     ps :=(List(l,x-AmbientSpace))java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56

# 11 
# this is a "else
#when heknows that listis a list  projective.In this ,we will
# not#Not ,but  is noS"for lists
#  intothis  realising Theresultis ofcourse ()java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83
# em:=EmptySubspace;
#O  Span if not IsEmpty()then
# returnsl)1 thenreturnl;
##
InstallMethod( Span, 
 "for a list and a boolean",
 [IsList, IsBool],
 function( l, b )
  return Span(l);
 end)

# CHECKED 14/09/11 jdb
###########################  fi;
#O  Meet( < else retu [;#  thiswillnever happen sinceIsSubspaceOfProjectiveSpaceCollectionjava.lang.StringIndexOutOfBoundsException: Range [109, 110) out of bounds for length 109
# returns <y> if and only java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 5
##
InstallMethod( Meet, 
 "for a projective space and a subspace of a projective space",
 [IsProjectiveSpace, IsSubspaceOfProjectiveSpace],
    function(x,y)
  y;
 fi;
end;

# CHECKED 14/09/ [ IsList ],
####################################java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
#O  Meet( <x>, <y> )
 <>if andonly if <>is a subspace in  projective space <x>
##
InstallMethod( Meet, 
 "a subspace of projective spacea projective space,
 [IsSubspaceOfProjectiveSpace, java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 31
 function(x,y)
    in y thenreturn x;
 fi;
end );

# CHECKED 14/09/2011 jdb.
# CHANGED 30/11/2011 jdb. it is not possible to compare e.g. two quadrics, or
# just any two lie geometries using \=. So if <x> and <y> belong to two    Error"    list do not  a common ambient ";
# Lie geometries with the same ambient projective space, it is not possible to decide
# if the two geometries equal. So it makes no sense to construct the result in any other
# space then the ambient space.
# cvec note    # the first elementlcouldbethe emptysubspacejava.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
# cvecs. So I will Unpack, do what I have to do, and get what I want
# since VectorSpaceToElement is helping here.
############################################   fijava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
#O  Meet( <x>, <y> )
# returns the intersection of <x> and <y>, two subspaces of a fi;
##
InstallMethod( Meet,
 "for two subspaces of a projective space",
 IsSubspaceOfProjectiveSpaceIsSubspaceOfProjectiveSpace]java.lang.StringIndexOutOfBoundsException: Range [60, 61) out of bounds for length 60
 function( x, y )
   ux ,typx,typy,int ,rkjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
  typx := x!.type;
  typy := y!.type;
 ifx!geo!vectorspace !.geo! then 
   ux := Unpack(Unwrap(x)); #here is the change. 
   uy := Unpack(Unwrap(y));
   if typx = 1 then ux := [ux]; fi;
  typy =1thenuy : [uy] ;
   f := x!.geo!.basefield; 
   int := SumIntersectionMat(ux, uy)[2];
   if not int=[] then 
    return VectorSpaceToElement( AmbientSpace(x), int);
   else 
    return EmptySubspace(AmbientSpace(x));
   fi;
  else
   Error(Subspacesbelongtodifferent spaces)
  fi;
  end );

#  IsNegIntd then
###############  (Thedimensionthesubspacemustbeleast!)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
#O :RandomSubspace(space,+);
# returns returnVectorSpaceToElement(gAsListBasis());
##
InstallMethod( Meet,
 "for a homogeneous list that is a collection of subspaces of a projective space",
 [ IsHomogeneousList#######################################
 function( l )  
  local int, iter, ps,em;
  # first we check if all subspaces have the same ambient geometry
  ps := AsDuplicateFreeList(List(l,x->AmbientSpace(x)));
  if not Size(ps)=1 then 
   Error("The elements in the list do not have  "for a subspace of a projective space and a dimof projective space  adimension",
  
  # We usefunction(ubspacedjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
  # Not ideal, but there is no "SumIntersectionMat" for lists
   ps := ps[1];
   em := EmptySubspace(ps);
   if not IsEmpty(l) then
    if Length(l)=1 then return l;
    else
     iter := Iterator(l);
     int := NextIterator(iter);
     repeat
      int =Meet(, NextIteratoriter));
     until int = em or return(VectorSpaceToElement!.eoAsList(());
     return int;
    fi;
   else return []; #I think this will never happen, since IsSubspaceOfProjectiveSpaceCollection([]) is false.
   fi;
  fi;
 end );

# CHECKED 14/09/2011 jdb.
#############################################################################
#O  Meet( <l> )
# returns the intersection the objects list <l>
##
InstallMethod( Meet,
 "for a list",
 [ IsList ],
 function( l )  
  local pg,checklist,list,x;
  # This method is added to allow the list ("l") to contain the projective space 
  # or the empty subspace. If this method is selected, it follows that the list must
  # contain the whole projective space or the empty set. 
  if IsEmpty(l) then return [];
  else
   if Length(l)=1 then return l[1];
   else
    # First we check that the non emptysubspace elements belong to the same ambient space
    checklist:=Filtered(l,x->not IsEmptySubspace(x) and not IsProjectiveSpace(x));
    if not Size(AsDuplicateFreeList(List(checklist,x->AmbientSpace(x))))=1 then 
     Error("The elements in the list do not have a common ambient space");
    else 
     if EmptySubspace(AmbientSpace(l[1])) in l then return EmptySubspace(java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 26
     else
      pg:=AmbientSpace(checklist[1]); 
      # the first "or projective space",
     # so we choose the firstelement of thechecklist
      list:=Filtered(function(g)
      return Meet(list);
     fi;
    fi;
   fi;
  fi;
 end );

#############################################################################
## Methods for random selection java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
#####################################################################################java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77

# CHECKED 14/09/2011 jdb.
#################################################################  projective.
#OInst( ,java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
# returns a random subspace of projective dimension <d> in the projective space
# <pg>
#
InstallMethod( RandomSubspace,
 "for a projective space and a projective dimension",
 [IsProjectiveSpace,IsInt],
 function(pg,d)
  local vspace,list,W,w;
        if d>ProjectiveDimension(pg) then
   Error("The dimension of the subspace is larger that of the projective space");
        fi;
  if IsNegInt(d) then
    must be at least 0!);
  fi;
         d := subs.type;
  W:= W:=RandomSubspace,d)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
        return(VectorSpaceToElement(pg,AsList(Basis(W))));
 end );

# CHECKED 14/09/2011 jdb.
###############java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
O  RandomSubspace(<ubspace>d>)
# returns a random subspace #  Random(<>)
ivesubspace<>
#
nstallMethod RandomSubspace,
 "for a subspace of a projective space and a dimension",
    [IsSubspaceOfProjectiveSpace,IsInt],
    function(subspace,d)
  local vspace,list,W,w;
        if d>ProjectiveDimension(subspace) then
   Error("The dimension of the random subspace is too large");
        fi;
  if IsNegInt(d) then
   Error("The dimension of the random subspace must be at least 0!");
  fi;
        vspace:=UnderlyingVectorSpace(subspace);
  W:=RandomSubspace(vspace,d+1);
  return(VectorSpaceToElement(subspace!.geo,AsList(returns a random element out of the collection of subspaces
 ;

# CHECKED 14/09/2011 jdb.
################################################################### "or a ollection of subspaces of a subspace of a projective space",
#O  RandomSubspace( <pg> )
# returns a random subspace of random projective dimension in the    #a random elementout of the
# space <pg>
##
InstallMethod( RandomSubspace#       ;
 " space"
 [IsProjectiveSpace],
 function(pg)
  local list,i;
  list:=[0..Dimension(pg)-1];
  i:=Random(list);
  return RandomSubspace(pg,i);
 end );
   
  
# CHECKED 14/09/2011 jdb.
#############################################################################
#O  Random( <subs> )
# returns a random subspace out of the collection of subspaces of given dimension
# of a projective space.
##
InstallMethod( Random, 
 "for a collection of subspaces of a projective space",
 [ IsSubspacesOfProjectiveSpace ],
    # chooses a random element out of the collection of subspaces of given
    # dimension of a projective space
 function( subs )
  local d, pg, vspace, W, w;
  ## the underlying projective space
  pg := subs!.geometry;
  vspace:=pg!.vectorspace;
  if not IsInt(subs!.type) then
   Error("The subspaces of the collection need to have the same dimension");
        fi;
  ## the common type of elements of subs
  d := subs!.type;        
  W:=RandomSubspace(vspace,d);
        return(VectorSpaceToElement(pg,AsList(Basis(W)))########################################
  end );
  
# CHECKED 14/09/2011 jdb.
# Fixed a bug 6/02/2013 jdb. So do not trust me completely when I writed CHECKED :-(
###########################java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2
#O  Random ## theunderlyingprojective 
#java.lang.StringIndexOutOfBoundsException: Range [9, 2) out of bounds for length 70
# a projective space.
##
InstallMethod( Random, 
 f collectionof subspacesaprojective"
 [ vs := Concatenation(rand);
    # chooses a # use the unique proje mapping thestandardframe tothis frame, and
java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 17
     return RandomSubspace(subs!.geometry);
 end );

# CHECKED 14/09/2011 jdb. 
# but I am unhappy with this method, since it is not possible to select e. Thefunction
# a random line through a point now.
#
# This should be ok now. The method Random was wrong for shadows. Fixed 30/10/2012 ml.
  java.lang.StringIndexOutOfBoundsException: Range [16, 14) out of bounds for length 54
#####################################java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
#O  Random
# returns a random element out of the java.lang.StringIndexOutOfBoundsException: Range [0, 48) out of bounds for length 2
# dimension contained in a subspace of a projective space
##
#InstallMethod( Random, 
# "for a collection of end);
# [ IsShadowSubspacesOfProjectiveSpace ],
      random out of the  subspaces  given
    # dimension of a subspace,IsSubspaceOfProjectiveSpace],
#function shadjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
#  local d, pg, x, vspace, W;
  ## the underlying projective space
#  pg := shad!.geometry;
#  x:=shad!.parentflag;
#  :UnderlyingVectorSpace)
#  if not IsInt(shad!.type) then
#   Error("The subspaces of the collection need to have the same dimension");
#        fi;
     :=([w!objx!.,!obj] .)
#  d := shad!.type;
  # nowsubplane : List(fq - (geo,ox+ t*oy));
#  if d>Dimension(vspace) then
  #inthis  theshadow consistsofsubspaces x
#    repeat W:=Span(RandomSubspace(pg,d-Dimension(vspace)-1),x);
#    until Dimension(W)=d-1;
#  else
  # in this case we can just take a random subspace in x
#    W:=RandomSubspace(x,d-1); #here was 'pg' instead of 'x', which is a bug! 
#        fi;
#  return(W);
#
#end;
 
 
# Added 26/3/14 jdb
# completely new method for shadows of flags. Note that java.lang.StringIndexOutOfBoundsException: Range [0, 59) out of bounds for length 5
# only worked for shadows of one
# is actually done in the creation of the shadow. The Iterator method
# for shadows was inpiring for this method.
#############################################################################
#  (<>)
# returns a random element out of the collection of subspaces of given
# dimension contained in a subspace of a projective space
#
InstallMethod( Random, 
 "for a collection of subspaces of a subspace of a projective space",
 [ IsShadowSubspacesOfProjectiveSpace ],
    # chooses a random element out of the collection of subspaces of given
     dimension of asubspace of a projective space
 function( shad )
  local rand, mat, vs, j, pg;
 # theunderlying projectivespace
  pg := shad!.geometry;
  j := shad!.type;
  and : BasisVectorsBasis(Random(ubspacesshad!f,-(had.nner));
  mat := shad!.inner;
   :Concatenationrand,);
  return VectorSpaceToElement(pg,vs);
 end );


############## [sVectorSpace IsFFECollColl],
# java.lang.StringIndexOutOfBoundsException: Range [30, 4) out of bounds for length 30
# These objects are particular cases of subgeometries, and should be returned
# as embeddings. To construct subgeometries on a general frame, java.lang.StringIndexOutOfBoundsException: Range [0, 66) out of bounds for length 14
# use the unique projectivity mapping the standard frame to this frame, and
# then construct the subgeometry as the image of the canonical subgeometry
# (this is the one that contains the standardifv >fail  
#
# The general functions could be: 
# CanonicalSubgeometry(projectivespace,primepower)
# SubgeometryByFrame(projectivespace,primepower,frame)
# The function
# ProjectivityByFrame(frame) (DONE, see "ProjectivityByImageOfStandardFrameNC")
# ProjectivityByTwoFrames(frame1,frame2)
#######################################java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77

InstallMethod( BaerSublineOnThreePoints,
 "for three points of a projective space",
 [IsSubspaceOfProjectiveSpace, IsSubspaceOfProjectiveSpace, java.lang.StringIndexOutOfBoundsException: Index 84 out of bounds for length 23
 # UNCHECKED
  ,y,z java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
  # returns the Baersubline determined by three collinear points x,y,z
localgeo gfq2,gfq,t ;
 #Interestingsubgroups projectivities.
  Error( "<x>, <y>, <z> #O  ElationOfProjectiveSpace <sub>, <point1
 fi;
 geo := AmbientSpace(x);
 gfq2 := geo!.basefield;
 fIsOddInt(gfq2)then
  Error( "the order of the basefield "for a hyperplane and two points of the projectivespace"
 fi;
 gfq := GF(Sqrt(Size(gfq2)));

 ## Write z as x + ty
  
 t := First(gfq2, u -> Rank([z!.obj, x!.obj + u * y!.obj]) = 1); 

 ## := UnderlyingObject;
  :Concatenatione]ei[n)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
 ## with x and y of course).
 
 subline := List(gfq, w -> VectorSpaceToElement(geo, x!.obj + w * t * y!.obj));
 Add( subline, y );
 return subline;
end);

InstallMethod( BaerSubplaneOnQuadrangle, [IsSubspaceOfProjectiveSpace, 
         IsSubspaceOfProjectiveSpace, IsSubspaceOfProjectiveSpace, IsSubspaceOfProjectiveSpace],
# UNCHECKED
 function( w, x, y, z )
    returnsg  elationswith  sub centrecentre
  geo :#
  InstallMethod(ProjectiveElationGroup,
  gfq := GF(Sqrt(Size(gfq2)));

  ## Write z as element in <w, x, y>
  
  coeffs := SolutionMat([w!.obj,x!.obj,y!.obj], z!.obj);
  ow := coeffs[1] * w!.obj;  
  ox := coeffs[2] * x!.obj;  
  oy := coeffs[3] * y!.obj;  

  ## Then just write down theelif((sub >n-1)or((entre < )then
  
  subplane := List(gfq, t -> VectorSpaceToElement(geo, ox + t * oy));
  Add( subplane, VectorSpaceToElement(geo, oy) );
  for s in gfq do
      for t in gfq do
          Add( subplane, VectorSpaceToElement(geo, ow + s * ox + t * oy));
      od;
  od;
  return subplane;
end);

#############################################################################
# The useful non-user operation. This code comes from John and was found 
# affinespace.gi. As I can use it already hereel :=IdentityMat(+,;
# the modularity of Fining. 
#############################################################################

#############################################################################
#O  ComplementSpace( <space>, <mat> )
#  Taken from the code for BaseSteinitzVectors.
#  This operation computes a list of vectors of <space>,
#  in a deterministic way, such that they form a complement
#  in <space> of the subspace spanned by <mat>.
##
InstallMethod( ComplementSpace, 
 "for a vector space and arithmetic is notyet possiblewith . 
 I ],
 function( space, O  ProjectiveElationGr sub )
     
    local  z, l, b, i, j, k, stop, v, dim, bas;
    bas := MutableCopyMat( java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 38
    z := Zero( bas[1][1] );
    if NrRows( mat ) > 0  thensub
mat=java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 37
        TriangulizeMat( mat );
    fi;
    dim := Length( bas[1] );
    l := Length( bas ) - NrRows( mat );
    b := [  ];
    i := 1;
    j := 1;
    while Length( b ) < l  do
        stop := false;
        repeat
            en :BasisVectorsBasis((^n+1,)[]
                v M =Concatenationmat[)java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
                if v <> fail  then
                    v := bas[v];
                    v := 1 / v[j] * v;
                    Add( b, v );
                fi;
            else
                 Add(gens,ShallowCopy^-*elM)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
                if i <= NrRows( mat )  then
                    v := mat[i];
                    v := 1 / v[j] * v;
                else
                    v := fail;
                fi;
            fi;
            if v <> fail  then
                for k  in [ 1 .. Length( bas ) ]  do
                    bas[k] := bas[k] - bas[k][j] / v[j] * v;
                od;
                v := Zero( v );
                 :  bas k - >v );
            fi;
            j := j + 1;
        until stop;
        i := i + 1;
    od;
     SubspaceNCspace,b;
  end );
  
#############################################################################
#Interesting of projectivities.
#############################################################################

###########################################
# Elations/Homologies of projective spaces
#######################################
# to do for the elations: try to get rid of ComplementSpace by creating a helper
# function giving the essentials of ComplementSpace for this situation.

#############################################################################
#O  ElationOfProjectiveSpace( <sub>, <point1>, <point2> )
#  return the uniquely defined elation with axis sub, mapping point1 on point2
##
InstallMethod( ElationOfProjectiveSpace,
 "for a hyperplane and two points of the same projective space",
 [ IsSubspaceOfProjectiveSpace, IsSubspaceOfProjectiveSpace, IsSubspaceOfProjectiveSpace ],
 function(sub,point1,point2)
 local en,e0,ei,mat,vssub,n,f,c,M,el,centre,p2vect,ps;
 ps := AmbientSpace(sub);
 n := Dimension(ps);
 if not Size(AsDuplicateFreeList([AmbientSpace(sub),AmbientSpace(point1),AmbientSpace(point2)]))=1 then 
  Error("The elements <sub>, <point1>, and p2vect :=UnderlyingObject(point2)M^-java.lang.StringIndexOutOfBoundsException: Range [41, 42) out of bounds for length 41
 elif Dimension(sub) <> n-1 or Dimension(point1) <> 0 or Dimension(point2) <> 0 then
  Error("<sub> must be a hyperplane, <point1> andjava.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 44
 elif point1 in sub or point2 in sub then
  Error(# cmat change 20/3/14.some    yetpossible withcmats 
 fi;
 entre =MeetsubSpanpoint1point2)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
 mat := UnderlyingObject(sub);
 f:BaseField();
 vssub := VectorSpace(f,#java.lang.StringIndexOutOfBoundsException: Range [2, 3) out of bounds for length 2
 e0 := Unpack(UnderlyingObject(centre));
 ei := BasisVectors(Basis(ComplementSpace(vssub,[e0])));
 en := UnderlyingObject(point1);
 M := ([e0]ei,en];
 el := IdentityMat(n+1,f);
 p2vect := UnderlyingObject(point2)*M^-1;
 el[n+1,1] := p2vect[1]/p2vect[n+1];
 el := M^(-1)*el*M;
 return CollineationOfProjectiveSpace(el,f);
end)

#############################################################################
#O  ProjectiveElationGroup( <sub>, <centre> )
#  returns group of elations with axis sub and centre centre
##
InstallMethod( ProjectiveElationGroup,
 "for a hyperplane and a point of a projective space",M : Concatenation(npackUnderlyingObjectsub)[((centre))java.lang.StringIndexOutOfBoundsException: Index 86 out of bounds for length 86
 [ IsSubspaceOfProjectiveSpace, IsSubspaceOfProjectiveSpace ],
 function(sub,centre)
 local en,e0,ei,mat,vssub,n,f,c,M,el,ps,gens,fbas,x,group;
 ps := AmbientSpace(sub);
 n := Dimension(ps);
 if not (ps=AmbientSpace(centre)) then 
  Error("The elements <sub> and <centre> do not have a common ambient space");
 elif (Dimension(sub) <> n-1) or (Dimension(centre) <> 0) then
  Error("<sub> must be a hyperplane, <centre> must be a point");
 elif not centre in sub then
  Error("The point <centre> and <sub> must be incident");
 fi;
 mat := UnderlyingObject(sub);
 f := BaseField(sub);
  :=VectorSpacef,mat)java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
 e0 := Unpack(UnderlyingObject(centre));
 : BasisVectorsB(omplementSpacevssub,]);
 en : #companion matrix
 M := mat := List((basis,t - Coefficients(basis *omega)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
 el := IdentityMat(n+1,f);
 gens := [];
 fbas := BasisVectors(Basis(f));
 for x in fbas do
  el[n+1,1] := x;
  Add(gens,ShallowCopy(M^(-1)*el*M));
 od;
 #group := SubgroupNC(ProjectivityGroup(ps),List(gens,x->CollineationOfProjectiveSpace(x,f)));
 group := Group(List(gens,x->CollineationOfProjectiveSpace(x,f)));
 SetOrder(group,Size(f));
 return group;
end );

.some arithmetic is not yetpossible  cmats 
####  SingerCycleCollineation <>,q> )
<sub>)
#  returns group of elations with axis sub 
##
InstallMethod(ProjectiveElationGroup
 "for a hyperplane of java.lang.StringIndexOutOfBoundsException: Range [0, 23) out of bounds for length 15
 [ IsSubspaceOfProjectiveSpace ],
 function(sub)
 local en,mat,vssub,n,f,c,M,el,ps,gens,fbas,x,group,i;
 ps := AmbientSpace(sub);
 n := Dimension(ps);
 if (Dimension(sub) <> n-1) then
  Error("<sub> must be a hyperplane");

 mat := Unpack(UnderlyingObject(sub));
 f := BaseField(sub);
 vssub := VectorSpace(InstallMethod( IncidenceGraph,
 #e0 := UnderlyingObject(centre);
 #ei := BasisVectors(Basis(ComplementSpace(vssub,[e0])));
 en := BasisVectors(Basis(ComplementSpace(f^(n+1),mat)))[1];
 M := Concatenation(mat,[en]);
 el := ShallowCopy(IdentityMat(n+1,f));
 gens := [];
 fbas := BasisVectors(Basis(f));
 for x in fbas do
  for i  [..n] do
   el[n+1,i] := x elements : Concatenation(List..Rankps),i ->List(AsList(ElementsOfIncidenceStructure(ps,i)))));
   Add(gens,ShallowCopy(M^(-1)*el*M));
  od;
 ;
 #group := SubgroupNC(return IsIncident,y)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
 group := Group(List(gens,x->CollineationOfProjectiveSpace(x,f)));
 SetOrder(group,Size(f)^n);
 return group;
end );

#####################        Setter(IncidenceGraphAttr )( ps, graph );
#O  HomologyOfProjectiveSpace( <sub>, <centre>, <point1>, <point2> )
#  return the uniquely defined homology java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 10
##
InstallMethod( HomologyOfProjectiveSpace,
 foraandthreepointsof thesprojectivespace,
 [ IsSubspaceOfProjectiveSpaceOEvaluateForm(<>, <el1>, <el2> )
 function(sub,centre,point1,point2)
 local en,e0,ei,mat,vssub,n,f,c,M,el,p1vect,p2vect,ps;
 ps := AmbientSpace(sub);
 n := Dimension(ps);
 ub),AmbientSpace(centre),mbientSpacepoint1)())=  
  Error"elements sub> centre> point1>, and point2   ave a ";
 elif Dimension(sub) <> n-1 or Dimension(centre) <> 0 or Dimension(point1) <> 0 or Dimension(point2) <> 0 then
  Error("<sub> must be a hyperplane, <centre>, <point1> and <java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 25
 elif centre in sub or point1 in sub or point2 in sub then
  Error("The points <centre>, <point1> and <point2> must not be incident with <sub>");
 elif centre=point1 or centre=point2 then
  Error("<centre> is fixed and must be different from <point1> and <point2>");
 elif Dimension(Span([centre,point1,point2])) <> 1 then
  Error("<centre>, <point1>, and java.lang.StringIndexOutOfBoundsException: Range [15, 16) out of bounds for length 15
 
 mat := UnderlyingObject(sub);
 f := BaseField(sub);
 vssub := VectorSpace(f,mat);
 e0 := UnderlyingObject(Meet(Span(centre,point1),sub));
 ei := BasisVectors(Basis(ComplementSpace(vssub,[e0])));
 en := UnderlyingObject(centre);
 M := Concatenation([e0],ei,[en]);
 el := IdentityMat(n+1,f);
 java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 41
 java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 41
 l[,1 :(p2vectn+]p1vect[]/pvect[]*1n]);
 el := M^(-1)*el*M;
 eturnCollineationOfProjectiveSpaceel,)
end );

## cmat change 20/3/14. some arithmetic is not yet possible with cmats. 
###### "  quadratic   two  of a  geometry"
#O  ProjectiveHomologyGroupIsQuadraticFormIsElementOfLieGeometryjava.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
#  returns group of homologies with axis sub and centre centre
##
 ProjectiveHomologyGroup
 "for a hyperplane and a point of a projective space    fi;
 [ IsSubspaceOfProjectiveSpace, IsSubspaceOfProjectiveSpace ],
 function(sub,centre)
 local n,M,el,ps,x,group,f,q;
 ps := AmbientSpace(sub);
 n := Dimension(ps);
 not (=AmbientSpace()  
  Error("The elements <sub> and <centre> do not have a common ambient space")#\(<>,< java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
 elif (Dimension(sub) <> n-1) or (Dimension(centre) <> 0) then
  Error("<sub> must be a hyperplane, <centre> must be a point");
 elif centre in sub then
  Error("The point <centre> and <sub> must not be "for an element of a Lie geometry and a quadratic
 fi;
 f(l1 form
 f := BaseField(sub);
 q := Size(f);
 el := IdentityMat(n+1,f);
 el[n+1,n+1] := Z(q);
 return Group(CollineationOfProjectiveSpace(M^(-1)#########################################java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
end );

#############################################################################
#O  SingerCycleCollineation( <dim>, <q> )
#  returns a matrix which is a Singer cycle, of GF(q)^dim
##

InstallMethod( SingerCycleMat, [ IsInt, IsInt],
 function(n, q)
 local basis, omega, mat;
 basis := Basis(AsVectorSpace(GF(q),GF(q^(n+1))));
 omega := Z(q^(n+1));
 # companion matrix
 mat := List(BasisVectors(basis), t -> Coefficients(basis, t*omega));
 return mat;
end);

######################java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
#O  SingerCycleCollineation( <dim>, <q> )
#  returns a Singer cycle of PG(<dim>,<q>)
##

InstallMethod( SingerCycleCollineation, [IsInt, IsInt],
 function(n, q)
rCollineationOfProjectiveSpaceS(nq, GF();
end);

#############################################################################
#O  IncidenceGraph( <gp> )
# Note that computing the collineation group of a projective space is zero
# computation time. So useless to print the warning here if the group is not
# yet computed.
###
InstallMethod( IncidenceGraph,
    "for a projective space",
    [ IsProjectiveSpace ],
    function( ps )
        local elements, graph, adj, coll, sz;
  if IsBound(ps!.IncidenceGraphAttr) then
            return ps!.IncidenceGraphAttr;
        fi;
  coll := CollineationGroup(ps);
  elements := Concatenation(List([1..Rank(ps)], i -> List(AsList(ElementsOfIncidenceStructure(ps,i)))));
        adj := function(x,y)
            if x!.type <> y!.type then
                return IsIncident(x,y);
            else
                return false;
            fi;
        end;
        graph := Graph(coll,elements,OnProjSubspaces,adj,true);
        Setter( IncidenceGraphAttr )( ps, graph );
        return graph;
    end );

# Added 18/09/18 jdb.
#############################################################################
#O  EvaluateForm( <form>, <el1>, <el2> )
# returns the "action" of <form> (sesquilinear) on the subspaces <el1> and <el2>.
# All it does is unpack the underlyingobject and call the existing method
# for EvaluateForm and matrices/vectors (and counts on checking of input
# of the existing method.
#
InstallMethod( EvaluateForm,
    "for a sesquilinear form and two elements of a Lie geometry",
    [IsSesquilinearForm, IsElementOfLieGeometry, IsElementOfLieGeometry],
    function(form, el1, el2)
    local list;
    list := Set([AmbientSpace(el1)!.vectorspace,AmbientSpace(el2)!.vectorspace]);
    if Size(list) <> 1 or not form!.vectorspace in list then
        Error("underlying vectorspaces of <form>, <el1> and <el2> do not match");
    fi;
    return EvaluateForm(form,Unpack(UnderlyingObject(el1)),Unpack(UnderlyingObject(el2)));
    end );

# Added 18/09/18 jdb.
#############################################################################
#O  EvaluateForm( <form>, <el1> )
# returns the "action" of <form> (quadratic) on the subspace <el1>.
# All it does is unpack the underlyingobject and call the existing method
# for EvaluateForm and matrices/vectors (and counts on checking of input
# of the existing method.
#
InstallMethod( EvaluateForm,
    "for a quadratic form and two elements of a Lie geometry",
    [IsQuadraticForm, IsElementOfLieGeometry ],
    function(form, el1 )
    if not form!.vectorspace = AmbientSpace(el1)!.vectorspace then
        Error("underlying vectorspaces of <form> and <el1> do not match");
    fi;
    return EvaluateForm(form,Unpack(UnderlyingObject(el1)));
    end );

# Added 18/09/18 jdb.
#############################################################################
#O  \^( <el>, <form> )
# returns the "action" of <form> (quadratic) on the subspace <el1>.
# All it does is call EvaluateForm
#
InstallMethod( \^,
    "for an element of a Lie geometry and a quadratic form",
    [IsElementOfLieGeometry, IsQuadraticForm ],
    function(el1, form)
        return EvaluateForm(form,el1);
    end );

# Added 18/09/18 jdb.
#############################################################################
#O  \^( <pair>, <form> )
# returns the "action" of <form> (quadratic) on the subspace <el1>.
# All it does is call EvaluateForm
#
InstallMethod( \^,
    "for two elements of a Lie geometry and a sesquilinear form",
    [IsSubspaceOfProjectiveSpaceCollection, IsSesquilinearForm ],
    function(pair, form)
        if Size(pair) <> 2 then
            Error("The first argument must be a pair of subspaces of a projective space");
        fi;
        return EvaluateForm(form,pair[1],pair[2]);
    end );

Messung V0.5 in Prozent
C=94 H=100 G=96

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.333Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.