Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/tietze.c
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,8 @@ static Obj FuncREDUCE_LETREP_WORDS_REW_SYS(Obj self, Obj tzrules, Obj a_w)
}
else {
// make space for the new word
nw = NEW_PLIST(TNUM_OBJ(w),newlen);
nw = NEW_PLIST_WITH_MUTABILITY(IS_MUTABLE_OBJ(w), TNUM_OBJ(w),
newlen);

// addresses
wa=ADDR_OBJ(w);
Expand Down
2 changes: 1 addition & 1 deletion src/vecffe.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ static Obj ZeroVecFFE(Obj vec)
TNUM_OBJ(vec) <= T_PLIST_FFE + IMMUTABLE);
len = LEN_PLIST(vec);
assert(len);
res = NEW_PLIST(TNUM_OBJ(vec), len);
res = NEW_PLIST_WITH_MUTABILITY(IS_MUTABLE_OBJ(vec), T_PLIST_FFE, len);
SET_LEN_PLIST(res, len);
z = ZERO_SAMEMUT(ELM_PLIST(vec, 1));
for (i = 1; i <= len; i++)
Expand Down
9 changes: 6 additions & 3 deletions src/vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ static Obj SumIntVector(Obj elmL, Obj vecR)

// make the result list
len = LEN_PLIST(vecR);
vecS = NEW_PLIST(TNUM_OBJ(vecR), len);
vecS = NEW_PLIST_WITH_MUTABILITY(IS_MUTABLE_OBJ(vecR), TNUM_OBJ(vecR),
len);
SET_LEN_PLIST(vecS, len);

// loop over the elements and add
Expand Down Expand Up @@ -93,7 +94,8 @@ static Obj SumVectorInt(Obj vecL, Obj elmR)

// make the result list
len = LEN_PLIST(vecL);
vecS = NEW_PLIST(TNUM_OBJ(vecL), len);
vecS = NEW_PLIST_WITH_MUTABILITY(IS_MUTABLE_OBJ(vecL), TNUM_OBJ(vecL),
len);
SET_LEN_PLIST(vecS, len);

// loop over the elements and add
Expand Down Expand Up @@ -253,7 +255,8 @@ static Obj DiffVectorInt(Obj vecL, Obj elmR)

// make the result list
len = LEN_PLIST(vecL);
vecD = NEW_PLIST(TNUM_OBJ(vecL), len);
vecD = NEW_PLIST_WITH_MUTABILITY(IS_MUTABLE_OBJ(vecL), TNUM_OBJ(vecL),
len);
SET_LEN_PLIST(vecD, len);

// loop over the elements and subtract
Expand Down
11 changes: 11 additions & 0 deletions tst/testinstall/kbsemi.tst
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,16 @@ gap> KnuthBendixRewritingSystem(N, \<);
Knuth Bendix Rewriting System for Monoid( [ m1, m2 ] ) with rules
[ [ m2, m1 ] ]

# the reduced word has the mutability of the given word
gap> w := ReduceLetterRepWordsRewSys([ [ [ 1, 2 ], [ 3 ] ] ], [ 1, 2, 4 ]);;
gap> w; IsMutable(w);
[ 3, 4 ]
true
gap> w := MakeImmutable([ 1, 2, 4 ]);;
gap> w := ReduceLetterRepWordsRewSys([ [ [ 1, 2 ], [ 3 ] ] ], w);;
gap> w; IsMutable(w);
[ 3, 4 ]
false

#
gap> STOP_TEST("kbsemi.tst");
10 changes: 10 additions & 0 deletions tst/testinstall/kernel/vecffe.tst
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,15 @@ gap> SMALLEST_FIELD_VECFFE([Z(2), Z(4)]);
gap> SMALLEST_FIELD_VECFFE([Z(8), Z(4)]);
64

#
# ZeroSameMutability
#
gap> v := [ Z(5), 0*Z(5) ];; IS_VECFFE(v);
true
gap> IsMutable(ZeroSameMutability(v));
true
gap> IsMutable(ZeroSameMutability(MakeImmutable(v)));
false

#
gap> STOP_TEST("kernel/vecffe.tst");
30 changes: 30 additions & 0 deletions tst/testinstall/kernel/vector.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# Tests for functions defined in src/vector.c
#
#@local v, w
gap> START_TEST("kernel/vector.tst");

# sum and difference of a vector and a scalar have the mutability of the vector
gap> v := [ 1, 2, 3 ];;
gap> w := 1 + v;; w; IsMutable(w);
[ 2, 3, 4 ]
true
gap> w := v + 1;; w; IsMutable(w);
[ 2, 3, 4 ]
true
gap> w := v - 1;; w; IsMutable(w);
[ 0, 1, 2 ]
true
gap> MakeImmutable(v);;
gap> w := 1 + v;; w; IsMutable(w);
[ 2, 3, 4 ]
false
gap> w := v + 1;; w; IsMutable(w);
[ 2, 3, 4 ]
false
gap> w := v - 1;; w; IsMutable(w);
[ 0, 1, 2 ]
false

#
gap> STOP_TEST("kernel/vector.tst");
Loading