Skip to content

Commit 621457c

Browse files
committed
remove incorrect promote(RR,QQ)
1 parent 19914f7 commit 621457c

File tree

6 files changed

+12
-31
lines changed

6 files changed

+12
-31
lines changed

M2/Macaulay2/m2/reals.m2

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ QQ _ ComplexField :=
159159
RR _ ComplexField :=
160160
CC _ ComplexField := (x,R) -> toCC(R.precision,x)
161161

162+
lift1 := z -> if z === 0. then 0/1 else if isFinite z then (
163+
(prec,sgn,expt,m,numbits) := partsRR z;
164+
sgn * m / 2^(numbits - expt)
165+
)
162166
lift(RR,QQ) := opts -> (r,QQ) -> (
163167
if r == 0 then return 0/1;
164168
r' := r;
@@ -174,7 +178,7 @@ lift(RR,QQ) := opts -> (r,QQ) -> (
174178
d := m_(1,0);
175179
q := n / d;
176180
if r === numeric(p,q) then return q;
177-
if r' == 0 or abs(n*d) > p2 then return promote(r,QQ);
181+
if r' == 0 or abs(n*d) > p2 then return lift1 r;
178182
r' = 1/r' ;
179183
))
180184
lift(RR,ZZ) := opts -> (r,ZZ) -> (
@@ -185,10 +189,6 @@ lift(CC,QQ) := lift(CC,ZZ) := opts -> (z,R) -> (
185189
if imaginaryPart z == 0 then lift(realPart z, R)
186190
else if opts.Verify then error "lift: complex number not real"
187191
)
188-
promote(RR,QQ) := (z,QQ) -> if z === 0. then 0/1 else if isFinite z then (
189-
(prec,sgn,expt,m,numbits) := partsRR z;
190-
sgn * m / 2^(numbits - expt)
191-
) else error "promote(RR,QQ): non-finite number encountered"
192192
liftable(RRi,QQ) := (z,RR) -> diameter(z) == 0
193193
liftable(RRi,ZZ) := (z,RR) -> diameter(z) == 0
194194
lift(RRi,QQ) := opts -> (r,QQ) -> (

M2/Macaulay2/packages/Macaulay2Doc/changes.m2

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2857,11 +2857,6 @@ document {
28572857
"The quotient and remainder for two ring elements can now be obtained simultaneously,
28582858
saving time. See ", TO (quotientRemainder,RingElement,RingElement), "."
28592859
},
2860-
LI {
2861-
"The binary representation of a real number is now available using ", TO (promote,RR,QQ), ".
2862-
The code for ", TO (lift,RR,QQ), " has been tightened up so a rational number is provided
2863-
that provides exactly the same real number when promoted."
2864-
},
28652860
LI {
28662861
"The Emacs commands ", KBD "M-x M2", ", bound to ", KBD "F12", ", and ", TT "M2-send-to-program",
28672862
", bound to ", KBD "F11", ", have some new capability.

M2/Macaulay2/packages/Macaulay2Doc/functions/lift-doc.m2

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,19 +118,16 @@ document {
118118
lift(3.0,QQ)
119119
///,
120120
PARA{
121-
"A continued fraction method is used to lift a real number to a rational number, whereas
122-
", TO "promote", " uses the internal binary representation.",
121+
"A continued fraction method is used to lift a real number to a rational number."
123122
},
124123
EXAMPLE lines ///
125124
lift(123/2341.,QQ)
126-
promote(123/2341.,QQ)
127125
factor oo
128126
///,
129127
PARA { "For numbers and ring elements, an alternate syntax with ", TO "^", " is available,
130128
analogous to the use of ", TO "_", " for ", TO "promote", "." },
131129
EXAMPLE lines ///
132130
.0001^QQ
133-
.0001_QQ
134131
///,
135132
SeeAlso => { baseRings, promote },
136133
Subnodes => {

M2/Macaulay2/packages/Macaulay2Doc/functions/promote-doc.m2

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ undocumented {(promote,CC,CC_*),
9797

9898
document {
9999
Key => {promote,
100-
(symbol _, RingElement, Ring),(symbol _,Number,Ring),
101-
(promote,RR,QQ)},
100+
(symbol _, RingElement, Ring),(symbol _,Number,Ring)},
102101
Headline => "promote to another ring",
103102
Usage => "promote(f,R)",
104103
Inputs => {
@@ -120,17 +119,6 @@ document {
120119
promote(f,S)
121120
G = map(S,R); G(f)
122121
///,
123-
PARA {
124-
"Promotion of real numbers to rational numbers is accomplished by using all of the bits of
125-
the internal representation."
126-
},
127-
EXAMPLE lines ///
128-
promote(101.,QQ)
129-
promote(.101,QQ)
130-
factor denominator oo
131-
ooo + 0.
132-
oo === .101
133-
///,
134122
PARA {
135123
"For promotion of ring elements, there is the following shorter notation."
136124
},

M2/Macaulay2/packages/Nauty.m2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ generateRandomGraphs (ZZ, ZZ, ZZ) := List => opts -> (n, num, p) -> (
247247
rndSeed := if instance(opts.RandomSeed, ZZ) then " -S" | toString(opts.RandomSeed % 2^30) else "";
248248
callNauty("genrang -qg -P" | toString p | " " | toString n | " " | toString num | rndSeed, {})
249249
)
250-
generateRandomGraphs (ZZ, ZZ, QQ) := List => opts -> (n, num, p) -> (
250+
generateRandomGraphs (ZZ, ZZ, QQ) :=
251+
generateRandomGraphs (ZZ, ZZ, RR) := List => opts -> (n, num, p) -> (
251252
if n < 1 then error("generateRandomGraphs: nauty does not like graphs with non-positive numbers of vertices.");
252253
if num < 1 then return {};
253254
if p <= 0 or p > 1 then error("generateRandomGraphs: Probability must be between 0 and 1.");
@@ -257,7 +258,6 @@ generateRandomGraphs (ZZ, ZZ, QQ) := List => opts -> (n, num, p) -> (
257258
q := round(100000000 * p) / 100000000;
258259
callNauty("genrang -qg -P" | toString q | " " | toString n | " " | toString num | rndSeed, {})
259260
)
260-
generateRandomGraphs (ZZ, ZZ, RR) := List => opts -> (n, num, p) -> generateRandomGraphs(n, num, promote(p, QQ), opts)
261261
generateRandomGraphs (ZZ, ZZ) := List => opts -> (n, num) -> (
262262
if n < 1 then error("generateRandomGraphs: nauty does not like graphs with non-positive numbers of vertices.");
263263
if not instance(opts.RandomSeed, Nothing) and not instance(opts.RandomSeed, ZZ) then error("generateRandomGraphs: Option [RandomSeed] is not a valid type, i.e., ZZ or Nothing.");

M2/Macaulay2/packages/NautyGraphs.m2

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ generateRandomGraphs (ZZ, ZZ, ZZ) := List => opts -> (n, num, p) -> (
233233
rndSeed := if instance(opts.RandomSeed, ZZ) then " -S" | toString(opts.RandomSeed % 2^30) else "";
234234
callNauty("genrang -qg -P" | toString p | " " | toString n | " " | toString num | rndSeed, {})
235235
)
236-
generateRandomGraphs (ZZ, ZZ, QQ) := List => opts -> (n, num, p) -> (
236+
237+
generateRandomGraphs (ZZ, ZZ, QQ) :=
238+
generateRandomGraphs (ZZ, ZZ, RR) := List => opts -> (n, num, p) -> (
237239
if n < 1 then error("generateRandomGraphs: nauty does not like graphs with non-positive numbers of vertices.");
238240
if num < 1 then return {};
239241
if p <= 0 or p > 1 then error("generateRandomGraphs: Probability must be between 0 and 1.");
@@ -243,7 +245,6 @@ generateRandomGraphs (ZZ, ZZ, QQ) := List => opts -> (n, num, p) -> (
243245
q := round(100000000 * p) / 100000000;
244246
callNauty("genrang -qg -P" | toString q | " " | toString n | " " | toString num | rndSeed, {})
245247
)
246-
generateRandomGraphs (ZZ, ZZ, RR) := List => opts -> (n, num, p) -> generateRandomGraphs(n, num, promote(p, QQ), opts)
247248
generateRandomGraphs (ZZ, ZZ) := List => opts -> (n, num) -> (
248249
if n < 1 then error("generateRandomGraphs: nauty does not like graphs with non-positive numbers of vertices.");
249250
if not instance(opts.RandomSeed, Nothing) and not instance(opts.RandomSeed, ZZ) then error("generateRandomGraphs: Option [RandomSeed] is not a valid type, i.e., ZZ or Nothing.");

0 commit comments

Comments
 (0)