[GAP Forum] HomalgComplex with sparse matrices
Mohamed Barakat
mohamed.barakat at uni-siegen.de
Mon Aug 14 13:48:35 BST 2017
Dear Joshua,
> I'm confused by the following behaviour:
>
>> ZZ := HomalgRingOfIntegers();
>> x := 2 / ZZ;
> 2
This is in fact a no-op; we didn’t wan’t to wrap GAP’s efficient integers.
>> x in ZZ;
> false
In the next GAP release it will return true. But as mentioned, this is faked, but will fix the bug you encounter below. However, we recommend to avoid using Gauss directly, see below:
> I'm trying to construct a sparse matrix using Gauss, then feed that into Homalg (using GaussForHomalg), e.g. as follows:
>
>> d := SparseZeroMatrix(2, 2, ZZ);
>> SetEntry(d, 1, 1, 2);
>> complex := HomalgComplex( 2 * ZZ);
>> Add(complex, HomalgMatrix(d, ZZ));
>
> This causes an error on the "SetEntry" line where it complains that 2 isn't in ZZ. (Nor are "2 / ZZ" or "2 * One(ZZ)" or various other similar combinations.) I've also tried replacing HomalgRingOfIntegers with just Integers, which makes "SetEntry" happy but then fails later on when I try to add the sparse matrix to the complex.
>
> Is there some combination of commands I can use to make both Gauss and Homalg happy?
The problem here is that Gauss does not support sparse matrices over the ring of integers, since it contains no implementation for sparse HNF. In general you can do everything with HomalgMatrix and the proper Gauss sparse matrices will be constructed in the background, if supported:
## Gauss supports the following:
gap> HomalgInitialMatrix( 2, 2, HomalgFieldOfRationals() );
<An initial 2 x 2 matrix over an internal ring>
gap> Eval( last );
<a 2 x 2 sparse matrix over Rationals>
gap> HomalgInitialMatrix( 2, 2, HomalgRingOfIntegers( 2 ) );
<An initial 2 x 2 matrix over an internal ring>
gap> Eval( last );
<a 2 x 2 sparse matrix over GF(2)>
gap> HomalgInitialMatrix( 2, 2, HomalgRingOfIntegers( 4 ) );
<An initial 2 x 2 matrix over an internal ring>
gap> Eval( last );
<a 2 x 2 sparse matrix over (Integers mod 4)>
## Gauss does not support the following
gap> HomalgInitialMatrix( 2, 2, HomalgRingOfIntegers() / 2 );
<A 2 x 2 mutable matrix over a residue class ring>
gap> Eval( last );
<An initial 2 x 2 matrix over an internal ring>
gap> HomalgInitialMatrix( 2, 2, HomalgRingOfIntegers() );
<An initial 2 x 2 matrix over an internal ring>
gap> Eval( last );
<A hull for a homalg internal matrix>
I hope this helps.
Best regards,
Mohamed
More information about the Forum
mailing list