1# GAP Implementation
2# This file was generated from
3# $Id: present2.gi,v 1.1 2010/05/07 13:30:13 sunnyquiver Exp $
4#
5
6
7InstallMethod( ProjectivePresentation,
8  "for algebras",
9  true,
10  [ IsAlgebra, IsMatrix ], 0,
11  function(A,mat)
12    local P0,P1,P0List,P1List,M,obj,m,n,i,v,terms,nzterm,nzentry;
13
14    # Number of rows in matrix:
15    m := Length(mat);
16    if (m < 1) then
17      Error("Representation matrix cannot be empty.\n");
18    fi;
19
20    # Check each row length to insure column consistency in matrix:
21    n := Length(mat[1]);
22    i := 2;
23    while (i <= m) do
24      if (Length(mat[i]) <> n) then
25        Error("Matrix must have rows of equal length.\n");
26      fi;
27      i := i + 1;
28    od;
29
30    # Initialize list for projective module P0 in presentation:
31    # NOTE: this is the starting vertex in each row, and should be
32    #       the same for each element in each row.
33    P0List := [];
34
35    # Check that each row of matrix has uniformly same starting vertex:
36    i := 1;
37    while (i <= m) do
38
39      # Find first nonzero entry in row and get Source vertex:
40      nzentry := First(mat[i], x->not IsZero(x));
41      nzterm := CoefficientsAndMagmaElements(nzentry);
42      v := SourceOfPath(nzterm[1]);
43
44      if IsLeftUniform(mat[i],v) then
45        P0List[i] := v;
46      else
47        Error("All rows of matrix must contain paths left uniform,\n",
48              "starting with the same vertex.\n");
49      fi;
50
51      i := i + 1;
52    od;
53
54    # Initialize list of vertices for projective module P1 in presentation:
55    P1List := [];
56
57
58    # Check that each column of matrix has uniformly same starting vertex:
59
60    obj := rec();
61    ObjectifyWithAttributes( obj,
62        NewType(ProjectivePresentationFamily,
63                        IsProjectivePresentationDefaultRep),
64        ParentAlgebra,A,
65        MatrixRepresentation,mat,
66	MatrixNumRows,m,
67	MatrixNumCols,n,
68        P0VertexList,P0List
69      );
70
71    return obj;
72
73  end
74);
75