Skip to content

Commit 7ea3874

Browse files
mahrudd-torrance
authored andcommitted
added slightly better random(Module,Module) strategy
1 parent ae86867 commit 7ea3874

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

M2/Macaulay2/m2/genmat.m2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ randomMR := opts -> (F,G) -> (
113113
map(F,G,new Matrix from f))
114114

115115
random(Module, Module) := Matrix => opts -> (F,G) -> (
116-
if not isFreeModule F or not isFreeModule G
116+
if not isFreeModule G
117117
then return homomorphism random(Hom(G, F, DegreeLimit => 0), opts);
118+
if not isFreeModule F
119+
then return map(F, G, random(cover F, G, opts));
118120
R := ring F;
119121
if R =!= ring G then error "modules over different rings";
120122
if opts.MaximalRank then return (randomMR opts)(F,G);

M2/Macaulay2/tests/normal/randommod.m2

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ f = random(S^1, S^1/x)
44
assert isWellDefined f
55
assert(target f === S^1)
66
assert(source f === S^1/x)
7+
8+
f = random(S^1/x, S^1)
9+
assert isWellDefined f
10+
assert(target f === S^1/x)
11+
assert(source f === S^1)

0 commit comments

Comments
 (0)