Skip to content

Commit 7e76a45

Browse files
authored
fix ImmutableMatrix for IsMatrixObj (#6186)
According to the documentation, `ImmutableMatrix` does the same as `ChangedBaseDomain` if the 2nd argument is in `IsMatrixObj`. This was not the case up to now. (And we are allowed to call `MakeImmutable` instead of `Immutable` if the 3rd argument is `true`.)
1 parent 6f79e5e commit 7e76a45

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

hpcgap/lib/vecmat.gi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,9 +1584,13 @@ local sf, rep, ind, ind2, row, i,big,l,nr;
15841584
if IsMatrixObj(matrix) then
15851585
# result is a matrix object iff 'matrix' is
15861586
if field=BaseDomain(matrix) then
1587-
return Immutable(matrix);
1587+
if change then
1588+
return MakeImmutable(matrix);
1589+
else
1590+
return Immutable(matrix);
1591+
fi;
15881592
else
1589-
return ImmutableMatrix(field,Unpack(matrix));
1593+
return MakeImmutable(ChangedBaseDomain(matrix, field));
15901594
fi;
15911595
elif not (IsPlistRep(matrix) or IsGF2MatrixRep(matrix) or
15921596
Is8BitMatrixRep(matrix)) then

lib/vecmat.gi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,9 +1581,13 @@ local sf, rep, ind, ind2, row, i,big,l,nr;
15811581
if IsMatrixObj(matrix) then
15821582
# result is a matrix object iff 'matrix' is
15831583
if field=BaseDomain(matrix) then
1584-
return Immutable(matrix);
1584+
if change then
1585+
return MakeImmutable(matrix);
1586+
else
1587+
return Immutable(matrix);
1588+
fi;
15851589
else
1586-
return ImmutableMatrix(field,Unpack(matrix));
1590+
return MakeImmutable(ChangedBaseDomain(matrix, field));
15871591
fi;
15881592
elif not (IsPlistRep(matrix) or IsGF2MatrixRep(matrix) or
15891593
Is8BitMatrixRep(matrix)) then

tst/testinstall/vecmat.tst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,22 @@ gap> w := ImmutableMatrix( F, m, true );;
249249
gap> IsMutable(w);
250250
false
251251

252+
# matrix object
253+
gap> m:= Matrix( IsPlistMatrixRep, GF(2), [ [ Z(2) ] ] );
254+
<1x1-matrix over GF(2)>
255+
gap> w:= ImmutableMatrix( GF(4), m );
256+
<immutable 1x1-matrix over GF(2^2)>
257+
gap> IsMutable( w );
258+
false
259+
gap> IsMatrixObj( w );
260+
true
261+
gap> w:= ImmutableMatrix( GF(2), m, true );
262+
<immutable 1x1-matrix over GF(2)>
263+
gap> IsMutable( w );
264+
false
265+
gap> IsIdenticalObj( m, w );
266+
true
267+
252268
# empty matrix
253269
gap> m := ImmutableMatrix( Rationals, [] );
254270
[ ]

0 commit comments

Comments
 (0)