[GAP Forum] Pointing objects and how to detect it

Stephen Linton sl4 at st-andrews.ac.uk
Thu Nov 8 11:31:26 GMT 2018


The function you want is called IsIdenticalObj. It’s documented in the manual.

gap> eList:=[0,0,0,0];
[ 0, 0, 0, 0 ]
gap> eL2:=[];
[  ]
gap> Add(eL2, eList);
gap> Add(eL2, eList);
gap> eL3:=[ [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ] ];
[ [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ] ]
gap> IsIdenticalObj(eL2[1],eL2[2]);
true
gap> IsIdenticalObj(eL3[1],eL3[2]);
false
gap> 


	Steve

> On 8 Nov 2018, at 11:02, Mathieu Dutour <mathieu.dutour at gmail.com> wrote:
> 
> I have a question about memory management in GAP.
> 
> If we do
> eList:=[0,0,0,0];
> eL2:=[];
> Add(eL2, eList);
> Add(eL2, eList);
> The state of eL2 is then [ [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ] ]
> Now if we do eL2[1][1]:=1 then we have eL2 being
> [ [ 1, 0, 0, 0 ], [ 1, 0, 0, 0 ] ]
> because eL2 actually contains two pointers to eList.
> 
> On the other hand, if we write eL3:=[ [ 0, 0, 0, 0 ], [ 0, 0, 0, 0 ] ];
> and do eL3[1][1]:=1 then we have eL3 being [ [ 1, 0, 0, 0 ], [ 0, 0, 0, 0 ]
> ].
> 
> Therefore the GAP object behavior depend on the way they are
> constructed.
> 
> If one is given a matrix, is there a way to identify which one are pointing
> to another object? Because right now if one does not know how the objects
> are built then I do not know how to do it.
> 
>  Mathieu
> _______________________________________________
> Forum mailing list
> Forum at gap-system.org
> https://mail.gap-system.org/mailman/listinfo/forum



More information about the Forum mailing list