Skip to content

Commit

Permalink
Rename rawRandomRR -> rawRandomRRUniform
Browse files Browse the repository at this point in the history
For consistency w/ rawRandomRRNormal
  • Loading branch information
d-torrance committed Sep 18, 2024
1 parent 71bbe70 commit c976fa1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions M2/Macaulay2/d/interface.dd
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions M2/Macaulay2/e/interface/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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] */
{
Expand All @@ -192,8 +192,8 @@ gmp_CC rawRandomCC(unsigned long precision)
* [1.0,1.0] */
{
gmp_CCmutable result = getmemstructtype(gmp_CCmutable);
result->re = const_cast<gmp_RRmutable>(rawRandomRR(precision));
result->im = const_cast<gmp_RRmutable>(rawRandomRR(precision));
result->re = const_cast<gmp_RRmutable>(rawRandomRRUniform(precision));
result->im = const_cast<gmp_RRmutable>(rawRandomRRUniform(precision));
return reinterpret_cast<gmp_CC>(result);
}

Expand Down
2 changes: 1 addition & 1 deletion M2/Macaulay2/e/interface/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] */

Expand Down
4 changes: 2 additions & 2 deletions M2/Macaulay2/m2/reals.m2
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c976fa1

Please sign in to comment.