Each iteration of Add(A,B) simply adds (to A) another reference to the same 
copy of B, so all four rows of A refer to a single copy of B.

If you change that one copy (using *any* of the references) then every 
reference to that copy will reflect the change.

You need to actually create four genuine “deep copies" of B if you want them to 
be independent.

(I am also not sure whether GAP treats arrays of booleans as bit patterns which 
is what you would need in order to really save memory)



On 2 Mar 2016, at 2:03 pm, Sara Yaftian 
<sara.yaft...@gmail.com<mailto:sara.yaft...@gmail.com>> wrote:

Dear GAP Forum

I need a m by n Boolean matrix for saving memory in my works. I know
A:=NullMat(m,n);
is a Null matrix but I need boolean version. I wrote the following code

B:=[];
for i in [1..3] do
Add(B,false);
od;
A:=[B];
for j in [1..3] do
Add(A,B);
od;

this is the output:
gap> A;
[ [ false, false, false ], [ false, false, false ], [ false, false, false
], [ false, false, false ] ]

and I obtained a null Boolean matrix but if I use the following command

A[2][3] := true;

I have the following problem

gap> A;
[ [ false, false, true ], [ false, false, true ], [ false, false, true ], [
false, false, true ] ]

I need just A[2][3] := true not A[i][3].

Would you please help me?

Best regards
Sara
_______________________________________________
Forum mailing list
Forum@mail.gap-system.org<mailto:Forum@mail.gap-system.org>
http://mail.gap-system.org/mailman/listinfo/forum

Professor Gordon Royle
School of Mathematics and Statistics
University of Western Australia
gordon.ro...@uwa.edu.au<mailto:gordon.ro...@uwa.edu.au>













_______________________________________________
Forum mailing list
Forum@mail.gap-system.org
http://mail.gap-system.org/mailman/listinfo/forum

Reply via email to