From 004fd42830dec9f09614bc153f4d48b1b2c2646a Mon Sep 17 00:00:00 2001 From: Mahrud Sayrafi Date: Wed, 14 Aug 2024 15:29:11 +0200 Subject: [PATCH] changed RingElement / Number and Permanents::glynn --- M2/Macaulay2/m2/enginering.m2 | 6 ++++-- M2/Macaulay2/packages/Permanents.m2 | 2 +- M2/Macaulay2/tests/normal/reals.m2 | 11 +++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/M2/Macaulay2/m2/enginering.m2 b/M2/Macaulay2/m2/enginering.m2 index 62133d97f25..1409104df39 100644 --- a/M2/Macaulay2/m2/enginering.m2 +++ b/M2/Macaulay2/m2/enginering.m2 @@ -641,11 +641,13 @@ 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 +-- Note: % is not implemented for inexact fields InexactNumber / RingElement := frac0 @@ promoteleftinexact -RingElement / InexactNumber := (f,g) -> (1/g) * f +RingElement / InexactNumber := (f, g) -> (1/g) * f fraction(RingElement,RingElement) := (r,s) -> ( R := ring r; diff --git a/M2/Macaulay2/packages/Permanents.m2 b/M2/Macaulay2/packages/Permanents.m2 index cc9d47a47f9..711499b1bec 100644 --- a/M2/Macaulay2/packages/Permanents.m2 +++ b/M2/Macaulay2/packages/Permanents.m2 @@ -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 ) diff --git a/M2/Macaulay2/tests/normal/reals.m2 b/M2/Macaulay2/tests/normal/reals.m2 index 0866f5e46d8..5a62b0e328f 100644 --- a/M2/Macaulay2/tests/normal/reals.m2 +++ b/M2/Macaulay2/tests/normal/reals.m2 @@ -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}