GAP (MatricesForHomalg) - Appendix D: The subpackage ResidueClassRingForHomalg as a sample ring package

Goto Chapter: Top 1 2 3 4 5 6 A B C D E F Bib Ind
[Top of Book] [Contents] [Previous Chapter] [Next Chapter]

[MathJax off]

D The subpackage ResidueClassRingForHomalg as a sample ring package
D.1 The Mandatory Basic Operations
D.1-1 BasisOfRowModule
D.1-2 BasisOfColumnModule
D.1-3 DecideZeroRows
D.1-4 DecideZeroColumns
D.1-5 SyzygiesGeneratorsOfRows
D.1-6 SyzygiesGeneratorsOfColumns
D.1-7 BasisOfRowsCoeff
D.1-8 BasisOfColumnsCoeff
D.1-9 DecideZeroRowsEffectively
D.1-10 DecideZeroColumnsEffectively
D.1-11 RelativeSyzygiesGeneratorsOfRows
D.1-12 RelativeSyzygiesGeneratorsOfColumns
D.2 The Mandatory Tool Operations
D.2-1 InitialMatrix
D.2-2 InitialIdentityMatrix
D.2-3 ZeroMatrix
D.2-4 IdentityMatrix
D.2-5 Involution
D.2-6 TransposedMatrix
D.2-7 CertainRows
D.2-8 CertainColumns
D.2-9 UnionOfRows
D.2-10 UnionOfColumns
D.2-11 DiagMat
D.2-12 KroneckerMat
D.2-13 MulMat
D.2-14 AddMat
D.2-15 SubMat
D.2-16 Compose
D.2-17 IsZeroMatrix
D.2-18 NrRows
D.2-19 NrColumns
D.2-20 Determinant
D.3 Some of the Recommended Tool Operations
D.3-1 AreEqualMatrices
D.3-2 IsOne
D.3-3 IsDiagonalMatrix
D.3-4 ZeroRows
D.3-5 ZeroColumns

### D The subpackage ResidueClassRingForHomalg as a sample ring package

#### D.1 The Mandatory Basic Operations

##### D.1-1 BasisOfRowModule

`‣ BasisOfRowModule`( M ) | ( function )

Returns: a homalg matrix over the ambient ring

    BasisOfRowModule :=
      function( M )
        local Mrel;

        Mrel := UnionOfRowsOp( M );

        Mrel := HomalgResidueClassMatrix(
                        BasisOfRowModule( Mrel ), HomalgRing( M ) );

        return GetRidOfObsoleteRows( Mrel );

      end,

##### D.1-2 BasisOfColumnModule

`‣ BasisOfColumnModule`( M ) | ( function )

Returns: a homalg matrix over the ambient ring

    BasisOfColumnModule :=
      function( M )
        local Mrel;

        Mrel := UnionOfColumnsOp( M );

        Mrel := HomalgResidueClassMatrix(
                        BasisOfColumnModule( Mrel ), HomalgRing( M ) );

        return GetRidOfObsoleteColumns( Mrel );

      end,

##### D.1-3 DecideZeroRows

`‣ DecideZeroRows`( A, B ) | ( function )

Returns: a homalg matrix over the ambient ring

    DecideZeroRows :=
      function( A, B )
        local Brel;

        Brel := UnionOfRowsOp( B );

        Brel := BasisOfRowModule( Brel );

        return HomalgResidueClassMatrix(
                       DecideZeroRows( Eval( A ), Brel ), HomalgRing( A ) );

      end,

##### D.1-4 DecideZeroColumns

`‣ DecideZeroColumns`( A, B ) | ( function )

Returns: a homalg matrix over the ambient ring

    DecideZeroColumns :=
      function( A, B )
        local Brel;

        Brel := UnionOfColumnsOp( B );

        Brel := BasisOfColumnModule( Brel );

        return HomalgResidueClassMatrix(
                       DecideZeroColumns( Eval( A ), Brel ), HomalgRing( A ) );

      end,

##### D.1-5 SyzygiesGeneratorsOfRows

`‣ SyzygiesGeneratorsOfRows`( M ) | ( function )

Returns: a homalg matrix over the ambient ring

    SyzygiesGeneratorsOfRows :=
      function( M )
        local R, ring_rel, rel, S;

        R := HomalgRing( M );

        ring_rel := RingRelations( R );

        rel := MatrixOfRelations( ring_rel );

        if IsHomalgRingRelationsAsGeneratorsOfRightIdeal( ring_rel ) then
            rel := Involution( rel );
        fi;

        rel := DiagMat( ListWithIdenticalEntries( NrColumns( M ), rel ) );

        S := SyzygiesGeneratorsOfRows( Eval( M ), rel );

        S := HomalgResidueClassMatrix( S, R );

        S := GetRidOfObsoleteRows( S );

        if IsZero( S ) then

            SetIsLeftRegular( M, true );

        fi;

        return S;

      end,

##### D.1-6 SyzygiesGeneratorsOfColumns

`‣ SyzygiesGeneratorsOfColumns`( M ) | ( function )

Returns: a homalg matrix over the ambient ring

    SyzygiesGeneratorsOfColumns :=
      function( M )
        local R, ring_rel, rel, S;

        R := HomalgRing( M );

        ring_rel := RingRelations( R );

        rel := MatrixOfRelations( ring_rel );

        if IsHomalgRingRelationsAsGeneratorsOfLeftIdeal( ring_rel ) then
            rel := Involution( rel );
        fi;

        rel := DiagMat( ListWithIdenticalEntries( NrRows( M ), rel ) );

        S := SyzygiesGeneratorsOfColumns( Eval( M ), rel );

        S := HomalgResidueClassMatrix( S, R );

        S := GetRidOfObsoleteColumns( S );

        if IsZero( S ) then

            SetIsRightRegular( M, true );

        fi;

        return S;

      end,

##### D.1-7 BasisOfRowsCoeff

`‣ BasisOfRowsCoeff`( M, T ) | ( function )

Returns: a homalg matrix over the ambient ring

    BasisOfRowsCoeff :=
      function( M, T )
        local Mrel, TT, bas, nz;

        Mrel := UnionOfRowsOp( M );

        TT := HomalgVoidMatrix( HomalgRing( Mrel ) );

        bas := BasisOfRowsCoeff( Mrel, TT );

        bas := HomalgResidueClassMatrix( bas, HomalgRing( M ) );

        nz := NonZeroRows( bas );

        SetEval( T, CertainRows( CertainColumns( TT, [ 1 .. NrRows( M ) ] ), nz ) );

        ResetFilterObj( T, IsVoidMatrix );

        ## the generic BasisOfRowsCoeff will assume that
        ## ( NrRows( B ) = 0 ) = IsZero( B )
        return CertainRows( bas, nz );

      end,

##### D.1-8 BasisOfColumnsCoeff

`‣ BasisOfColumnsCoeff`( M, T ) | ( function )

Returns: a homalg matrix over the ambient ring

    BasisOfColumnsCoeff :=
      function( M, T )
        local Mrel, TT, bas, nz;

        Mrel := UnionOfColumnsOp( M );

        TT := HomalgVoidMatrix( HomalgRing( Mrel ) );

        bas := BasisOfColumnsCoeff( Mrel, TT );

        bas := HomalgResidueClassMatrix( bas, HomalgRing( M ) );

        nz := NonZeroColumns( bas );

        SetEval( T, CertainColumns( CertainRows( TT, [ 1 .. NrColumns( M ) ] ), nz ) );

        ResetFilterObj( T, IsVoidMatrix );

        ## the generic BasisOfColumnsCoeff will assume that
        ## ( NrColumns( B ) = 0 ) = IsZero( B )
        return CertainColumns( bas, nz );

      end,

##### D.1-9 DecideZeroRowsEffectively

`‣ DecideZeroRowsEffectively`( A, B, T ) | ( function )

Returns: a homalg matrix over the ambient ring

    DecideZeroRowsEffectively :=
      function( A, B, T )
        local Brel, TT, red;

        Brel := UnionOfRowsOp( B );

        TT := HomalgVoidMatrix( HomalgRing( Brel ) );

        red := DecideZeroRowsEffectively( Eval( A ), Brel, TT );

        SetEval( T, CertainColumns( TT, [ 1 .. NrRows( B ) ] ) );

        ResetFilterObj( T, IsVoidMatrix );

        return HomalgResidueClassMatrix( red, HomalgRing( A ) );

      end,

##### D.1-10 DecideZeroColumnsEffectively

`‣ DecideZeroColumnsEffectively`( A, B, T ) | ( function )

Returns: a homalg matrix over the ambient ring

    DecideZeroColumnsEffectively :=
      function( A, B, T )
        local Brel, TT, red;

        Brel := UnionOfColumnsOp( B );

        TT := HomalgVoidMatrix( HomalgRing( Brel ) );

        red := DecideZeroColumnsEffectively( Eval( A ), Brel, TT );

        SetEval( T, CertainRows( TT, [ 1 .. NrColumns( B ) ] ) );

        ResetFilterObj( T, IsVoidMatrix );

        return HomalgResidueClassMatrix( red, HomalgRing( A ) );

      end,

##### D.1-11 RelativeSyzygiesGeneratorsOfRows

`‣ RelativeSyzygiesGeneratorsOfRows`( M, M2 ) | ( function )

Returns: a homalg matrix over the ambient ring

    RelativeSyzygiesGeneratorsOfRows :=
      function( M, M2 )
        local M2rel, S;

        M2rel := UnionOfRowsOp( M2 );

        S := SyzygiesGeneratorsOfRows( Eval( M ), M2rel );

        S := HomalgResidueClassMatrix( S, HomalgRing( M ) );

        S := GetRidOfObsoleteRows( S );

        if IsZero( S ) then

            SetIsLeftRegular( M, true );

        fi;

        return S;

      end,

##### D.1-12 RelativeSyzygiesGeneratorsOfColumns

`‣ RelativeSyzygiesGeneratorsOfColumns`( M, M2 ) | ( function )

Returns: a homalg matrix over the ambient ring

    RelativeSyzygiesGeneratorsOfColumns :=
      function( M, M2 )
        local M2rel, S;

        M2rel := UnionOfColumnsOp( M2 );

        S := SyzygiesGeneratorsOfColumns( Eval( M ), M2rel );

        S := HomalgResidueClassMatrix( S, HomalgRing( M ) );

        S := GetRidOfObsoleteColumns( S );

        if IsZero( S ) then

            SetIsRightRegular( M, true );

        fi;

        return S;

      end,

#### D.2 The Mandatory Tool Operations

Here we list those matrix operations for which homalg provides no fallback method.

##### D.2-1 InitialMatrix

`‣ InitialMatrix`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `InitialMatrix` (B.1-1))

    InitialMatrix := C -> HomalgInitialMatrix(
                          NrRows( C ), NrColumns( C ), AmbientRing( HomalgRing( C ) ) ),

##### D.2-2 InitialIdentityMatrix

`‣ InitialIdentityMatrix`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `InitialIdentityMatrix` (B.1-2))

    InitialIdentityMatrix := C -> HomalgInitialIdentityMatrix(
            NrRows( C ), AmbientRing( HomalgRing( C ) ) ),

##### D.2-3 ZeroMatrix

`‣ ZeroMatrix`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `ZeroMatrix` (B.1-3))

    ZeroMatrix := C -> HomalgZeroMatrix(
                          NrRows( C ), NrColumns( C ), AmbientRing( HomalgRing( C ) ) ),

##### D.2-4 IdentityMatrix

`‣ IdentityMatrix`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `IdentityMatrix` (B.1-4))

    IdentityMatrix := C -> HomalgIdentityMatrix(
            NrRows( C ), AmbientRing( HomalgRing( C ) ) ),

##### D.2-5 Involution

`‣ Involution`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `Involution` (B.1-5))

    Involution :=
      function( M )
        local N, R;

        N := Involution( Eval( M ) );

        R := HomalgRing( N );

        if not ( HasIsCommutative( R ) and IsCommutative( R ) and
                 HasIsReducedModuloRingRelations( M ) and
                 IsReducedModuloRingRelations( M ) ) then

            ## reduce the matrix N w.r.t. the ring relations
            N := DecideZero( N, HomalgRing( M ) );
        fi;

        return N;

      end,

##### D.2-6 TransposedMatrix

`‣ TransposedMatrix`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `TransposedMatrix` (B.1-6))

    TransposedMatrix :=
      function( M )
        local N, R;

        N := TransposedMat( Eval( M ) );

        R := HomalgRing( N );

        if not ( HasIsCommutative( R ) and IsCommutative( R ) and
                 HasIsReducedModuloRingRelations( M ) and
                 IsReducedModuloRingRelations( M ) ) then

            ## reduce the matrix N w.r.t. the ring relations
            N := DecideZero( N, HomalgRing( M ) );
        fi;

        return N;

      end,

##### D.2-7 CertainRows

`‣ CertainRows`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `CertainRows` (B.1-7))

    CertainRows :=
      function( M, plist )
        local N;

        N := CertainRows( Eval( M ), plist );

        if not ( HasIsReducedModuloRingRelations( M ) and
                 IsReducedModuloRingRelations( M ) ) then

            ## reduce the matrix N w.r.t. the ring relations
            N := DecideZero( N, HomalgRing( M ) );
        fi;

        return N;

      end,

##### D.2-8 CertainColumns

`‣ CertainColumns`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `CertainColumns` (B.1-8))

    CertainColumns :=
      function( M, plist )
        local N;

        N := CertainColumns( Eval( M ), plist );

        if not ( HasIsReducedModuloRingRelations( M ) and
                 IsReducedModuloRingRelations( M ) ) then

            ## reduce the matrix N w.r.t. the ring relations
            N := DecideZero( N, HomalgRing( M ) );
        fi;

        return N;

      end,

##### D.2-9 UnionOfRows

`‣ UnionOfRows`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `UnionOfRows` (B.1-9))

    UnionOfRows :=
      function( A, B )
        local N;

        N := UnionOfRowsOp( Eval( A ), Eval( B ) );

        if not ForAll( [ A, B ], HasIsReducedModuloRingRelations and
                   IsReducedModuloRingRelations ) then

            ## reduce the matrix N w.r.t. the ring relations
            N := DecideZero( N, HomalgRing( A ) );
        fi;

        return N;

      end,

##### D.2-10 UnionOfColumns

`‣ UnionOfColumns`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `UnionOfColumns` (B.1-10))

    UnionOfColumns :=
      function( A, B )
        local N;

        N := UnionOfColumnsOp( Eval( A ), Eval( B ) );

        if not ForAll( [ A, B ], HasIsReducedModuloRingRelations and
                   IsReducedModuloRingRelations ) then

            ## reduce the matrix N w.r.t. the ring relations
            N := DecideZero( N, HomalgRing( A ) );
        fi;

        return N;

      end,

##### D.2-11 DiagMat

`‣ DiagMat`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `DiagMat` (B.1-11))

    DiagMat :=
      function( e )
        local N;

        N := DiagMat( List( e, Eval ) );

        if not ForAll( e, HasIsReducedModuloRingRelations and
                   IsReducedModuloRingRelations ) then

            ## reduce the matrix N w.r.t. the ring relations
            N := DecideZero( N, HomalgRing( e[1] ) );
        fi;

        return N;

      end,

##### D.2-12 KroneckerMat

`‣ KroneckerMat`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `KroneckerMat` (B.1-12))

    KroneckerMat :=
      function( A, B )
        local N;

        N := KroneckerMat( Eval( A ), Eval( B ) );

        if not ForAll( [ A, B ], HasIsReducedModuloRingRelations and
                   IsReducedModuloRingRelations ) then

            ## reduce the matrix N w.r.t. the ring relations
            N := DecideZero( N, HomalgRing( A ) );
        fi;

        return N;

      end,

##### D.2-13 MulMat

`‣ MulMat`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `MulMat` (B.1-13))

    MulMat :=
      function( a, A )

        return DecideZero( EvalRingElement( a ) * Eval( A ), HomalgRing( A ) );

      end,
    MulMatRight :=
      function( A, a )

        return DecideZero( Eval( A ) * EvalRingElement( a ), HomalgRing( A ) );

      end,

##### D.2-14 AddMat

`‣ AddMat`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `AddMat` (B.1-14))

    AddMat :=
      function( A, B )

        return DecideZero( Eval( A ) + Eval( B ), HomalgRing( A ) );

      end,

##### D.2-15 SubMat

`‣ SubMat`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `SubMat` (B.1-15))

    SubMat :=
      function( A, B )

        return DecideZero( Eval( A ) - Eval( B ), HomalgRing( A ) );

      end,

##### D.2-16 Compose

`‣ Compose`( ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `Compose` (B.1-16))

    Compose :=
      function( A, B )

        return DecideZero( Eval( A ) * Eval( B ), HomalgRing( A ) );

      end,

##### D.2-17 IsZeroMatrix

`‣ IsZeroMatrix`( M ) | ( function )

Returns: `true` or `false`

(--> `IsZeroMatrix` (B.1-17))

    IsZeroMatrix := M -> IsZero( DecideZero( Eval( M ), HomalgRing( M ) ) ),

##### D.2-18 NrRows

`‣ NrRows`( C ) | ( function )

Returns: a nonnegative integer

(--> `NrRows` (B.1-18))

    NrRows := C -> NrRows( Eval( C ) ),

##### D.2-19 NrColumns

`‣ NrColumns`( C ) | ( function )

Returns: a nonnegative integer

(--> `NrColumns` (B.1-19))

    NrColumns := C -> NrColumns( Eval( C ) ),

##### D.2-20 Determinant

`‣ Determinant`( C ) | ( function )

Returns: an element of ambient homalg ring

(--> `Determinant` (B.1-20))

    Determinant := C -> DecideZero( Determinant( Eval( C ) ), HomalgRing( C ) ),

#### D.3 Some of the Recommended Tool Operations

Here we list those matrix operations for which homalg does provide a fallback method. But specifying the below `homalgTable` functions increases the performance by replacing the fallback method.

##### D.3-1 AreEqualMatrices

`‣ AreEqualMatrices`( A, B ) | ( function )

Returns: `true` or `false`

(--> `AreEqualMatrices` (B.2-1))

    AreEqualMatrices :=
      function( A, B )

        return IsZero( DecideZero( Eval( A ) - Eval( B ), HomalgRing( A ) ) );

      end,

##### D.3-2 IsOne

`‣ IsOne`( M ) | ( function )

Returns: `true` or `false`

(--> `IsIdentityMatrix` (B.2-2))

    IsIdentityMatrix := M ->
              IsOne( DecideZero( Eval( M ), HomalgRing( M ) ) ),

##### D.3-3 IsDiagonalMatrix

`‣ IsDiagonalMatrix`( M ) | ( function )

Returns: `true` or `false`

(--> `IsDiagonalMatrix` (B.2-3))

    IsDiagonalMatrix := M ->
              IsDiagonalMatrix( DecideZero( Eval( M ), HomalgRing( M ) ) ),

##### D.3-4 ZeroRows

`‣ ZeroRows`( C ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `ZeroRows` (B.2-4))

    ZeroRows := C -> ZeroRows( DecideZero( Eval( C ), HomalgRing( C ) ) ),

##### D.3-5 ZeroColumns

`‣ ZeroColumns`( C ) | ( function )

Returns: a homalg matrix over the ambient ring

(--> `ZeroColumns` (B.2-5))

    ZeroColumns := C -> ZeroColumns( DecideZero( Eval( C ), HomalgRing( C ) ) ),

[Top of Book] [Contents] [Previous Chapter] [Next Chapter]
Goto Chapter: Top 1 2 3 4 5 6 A B C D E F Bib Ind

generated by GAPDoc2HTML