Skip to content

Commit

Permalink
fixes #3451
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud authored and d-torrance committed Sep 4, 2024
1 parent c12eed4 commit 207cf44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion M2/Macaulay2/m2/genmat.m2
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ random(List,Ring) := RingElement => opts -> (deg,R) -> (

random(ZZ,Ring) := RingElement => opts -> (n,R) -> random({n},R,opts)

other := (i, m) -> (i + random m) % m
randomMR := opts -> (F,G) -> (
R := ring F;
m := numgens F;
Expand All @@ -83,7 +84,6 @@ randomMR := opts -> (F,G) -> (
if m>k then f = f || random(R^(toList( m-k : d1 )), R^n, opts)
else if n > k then f = f | random(R^m, R^(toList (n-k : -d1)), opts);
f = mutableMatrix f;
other := (i,m) -> (i + random(m-1)) % m;
if m>k then (
for i to k-1 do rowAdd(f, i, random(d0,R,opts), random(k,m-1));
for i to k-1 do rowSwap(f, i, other(i,m)))
Expand Down
3 changes: 3 additions & 0 deletions M2/Macaulay2/tests/normal/randommat.m2
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ assert isIsomorphism random(R^4,R^4,MaximalRank=>true)
assert isInjective random(R^6,R^3,MaximalRank=>true)
assert isSurjective random(R^3,R^6,MaximalRank=>true)

assert(random(ZZ^2, ZZ^2, MaximalRank => true) - id_(ZZ^2) != 0)
assert(random(QQ^2, QQ^2, MaximalRank => true) - id_(QQ^2) != 0)
assert(random(R^2, R^2, MaximalRank => true) - id_(R^2) != 0)

0 comments on commit 207cf44

Please sign in to comment.