Skip to content

Commit

Permalink
changed RingElement / Number and fixed Permanents::glynn
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed Aug 14, 2024
1 parent 80e30c8 commit e7f0096
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions M2/Macaulay2/m2/enginering.m2
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,12 @@ RingElement / RingElement := RingElement => (f,g) -> (
f / g)
frac0 = (f,g) -> f/g

-- TODO: should these be more uniform? see 3e329d60815 and 13675361300
Number / RingElement := frac0 @@ promoteleftexact
RingElement / Number := (f,g) -> (1/g) * f
RingElement / Number := (f, g) -> if f % g == 0 then f // g else (1/g) * f

InexactNumber / RingElement := frac0 @@ promoteleftinexact
RingElement / InexactNumber := (f,g) -> (1/g) * f
RingElement / InexactNumber := (f, g) -> if f % g == 0 then f // g else (1/g) * f

fraction(RingElement,RingElement) := (r,s) -> (
R := ring r;
Expand Down
2 changes: 1 addition & 1 deletion M2/Macaulay2/packages/Permanents.m2
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ glynn Matrix := (M) -> (

--need to divide in Glynn's formula
--so can't be characteristic 2
perm=perm//2^(n-1);
perm = perm / 2^(n-1);
perm
)

Expand Down
11 changes: 11 additions & 0 deletions M2/Macaulay2/tests/normal/reals.m2
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@ scan({ZZ, QQ, RR, CC}, F -> (

assert((pi*ii) // (3*ii) == 1)
assert((pi*ii) % (3*ii) + 3*ii == pi*ii)

R = ZZ[x]
f = (2*x+2)^3
assert same {(x+1)^3, f // 8, f / 8}
assert same {(x+1)*x, f // 16}
assert(try f / 16 then false else true)

R = QQ[x]
f = (2*x+2)^3
assert same {(x+1)^3, f // 8, f / 8}
assert same {(x+1)^3/2, f // 16, f / 16}

0 comments on commit e7f0096

Please sign in to comment.