diff --git a/M2/Macaulay2/d/interface.dd b/M2/Macaulay2/d/interface.dd index 0785ae007a..ba77bc9b17 100644 --- a/M2/Macaulay2/d/interface.dd +++ b/M2/Macaulay2/d/interface.dd @@ -70,12 +70,12 @@ export rawRandomQQ(e:Expr):Expr := ( is ht:ZZcell do toExpr(Ccode(QQ, "rawRandomQQ(", ht.v, ")")) else WrongArgZZ()); setupfun("rawRandomQQ",rawRandomQQ); -export rawRandomRR(e:Expr):Expr := ( +export rawRandomRRUniform(e:Expr):Expr := ( when e is prec:ZZcell do if !isULong(prec.v) then WrongArgSmallInteger() - else toExpr(Ccode(RR, "rawRandomRR(", toULong(prec.v), ")")) + else toExpr(Ccode(RR, "rawRandomRRUniform(", toULong(prec.v), ")")) else WrongArgZZ()); -setupfun("rawRandomRR",rawRandomRR); +setupfun("rawRandomRRUniform",rawRandomRRUniform); export rawRandomRRNormal(e:Expr):Expr := ( when e is prec:ZZcell do if !isULong(prec.v) then WrongArgSmallInteger() diff --git a/M2/Macaulay2/e/interface/random.cpp b/M2/Macaulay2/e/interface/random.cpp index b25bb4e6b4..0fb1289fbb 100644 --- a/M2/Macaulay2/e/interface/random.cpp +++ b/M2/Macaulay2/e/interface/random.cpp @@ -168,7 +168,7 @@ gmp_QQ rawRandomQQ(gmp_ZZ height) return moveTo_gmpQQ(result); } -gmp_RR rawRandomRR(unsigned long precision) +gmp_RR rawRandomRRUniform(unsigned long precision) /* returns a uniformly distributed random real with the given precision, in * range [0.0,1.0] */ { @@ -192,8 +192,8 @@ gmp_CC rawRandomCC(unsigned long precision) * [1.0,1.0] */ { gmp_CCmutable result = getmemstructtype(gmp_CCmutable); - result->re = const_cast(rawRandomRR(precision)); - result->im = const_cast(rawRandomRR(precision)); + result->re = const_cast(rawRandomRRUniform(precision)); + result->im = const_cast(rawRandomRRUniform(precision)); return reinterpret_cast(result); } diff --git a/M2/Macaulay2/e/interface/random.h b/M2/Macaulay2/e/interface/random.h index 4bd06a7113..1bcecbf926 100644 --- a/M2/Macaulay2/e/interface/random.h +++ b/M2/Macaulay2/e/interface/random.h @@ -42,7 +42,7 @@ void rawSetRandomQQ(mpq_ptr result, gmp_ZZ height); /* sets result = a sample from the standard uniform distribution, rounded */ /* to the nearest rational number with denominator bounded by height */ -gmp_RR rawRandomRR(unsigned long prec); +gmp_RR rawRandomRRUniform(unsigned long prec); /* returns a uniformly distributed random real with the given precision, in * range [0.0,1.0] */ diff --git a/M2/Macaulay2/m2/reals.m2 b/M2/Macaulay2/m2/reals.m2 index 67d905d9c8..20fd49f6ed 100644 --- a/M2/Macaulay2/m2/reals.m2 +++ b/M2/Macaulay2/m2/reals.m2 @@ -243,9 +243,9 @@ truncate Number := {} >> o -> x -> ( else if x < 0 then ceiling x else 0) -- e.g., RRi's containing 0 as interior pt -random RR := RR => opts -> x -> x * rawRandomRR precision x +random RR := RR => opts -> x -> x * rawRandomRRUniform precision x random(RR,RR) := opts -> (x,y) -> x + random(y-x) -RR'.random = opts -> R -> rawRandomRR R.precision +RR'.random = opts -> R -> rawRandomRRUniform R.precision CC'.random = opts -> C -> rawRandomCC C.precision random RingFamily := opts -> R -> random(default R,opts)