$Id: issues.html,v 1.11 2003/10/30 21:28:42 jmaurer Exp $
Replace in section 5.1.1 [tr.rand.req], last paragraph
In the following subclauses, a template parameter named UniformRandomNumberGenerator shall denote a[This aligns the wording with the subsequent sentences in the same paragraph.]classtype that satisfies all the requirements of a uniform random number generator.
Replace in section 5.1.4 [tr.rand.eng], second paragraph
The class templates specified in this section satisfy all the requirements of a pseudo-random number engine (given in tables in sectionx.x5.1.1 [tr.rand.req]), except where specified otherwise. Descriptions are provided here only for operations on the engines that are not described in one of these tables or for operations where there is additional semantic information.
Proposed resolution:
Replace in 5.4.1.2 [tr.rand.eng.mers]
Effects: With a linear congruential generator l(i) having parameters ml = 232, al = 69069, cl = 0, and l(0) = value, sets x(-n) ... x(-1) to l(1) ... l(n), respectively.by
Effects: With a linear congruential generator lcg(i) having parameters mlcg = 232, alcg = 69069, clcg = 0, and lcg(0) = value, sets x(-n) ... x(-1) to lcg(1) ... lcg(n), respectively.Replace in 5.4.1.3 [tr.rand.eng.sub]
Effects: With a linear congruential generator l(i)
having parameters ml = 2147483563, al = 40014,
cl = 0, and l(0) = value
, sets x(-r) ... x(-1)
to l(1) mod m ... l(r) mod m, respectively. If x(-1) == 0, sets
carry(-1) = 1, else sets carry(-1) = 0.
by
Effects: With a linear congruential generator lcg(i)
having parameters mlcg = 2147483563, alcg = 40014,
clcg = 0, and lcg(0) = value
, sets x(-r) ... x(-1)
to lcg(1) mod m ... lcg(r) mod m, respectively. If x(-1) == 0, sets
carry(-1) = 1, else sets carry(-1) = 0.
Replace in 5.4.1.4 [tr.rand.eng.sub1]
Effects: With a linear congruential generator l(i) having parameters m = 2147483563, a = 40014, c = 0, and l(0) =byvalue
, sets x(-r) ... x(-1) to (l(1)*2-w) mod 1 ... (l(r)*2-w) mod 1, respectively. If x(-1) == 0, sets carry(-1) = 2-w, else sets carry(-1) = 0.
Effects: With a linear congruential generator lcg(i)
having parameters mlcg = 2147483563, alcg =
40014, clcg = 0, and lcg(0) = value
, sets
x(-r) ... x(-1) to (lcg(1)*2-w) mod 1
... (lcg(r)*2-w) mod 1, respectively. If x(-1) == 0, sets
carry(-1) = 2-w, else sets carry(-1) = 0.
Replace in 5.1.4.6 [tr.rand.eng.xor]
The template parameters UniformRandomNumberGenerator1 and UniformRandomNumberGenerator[Replace "1" by "2" once.]12 shall denote classes that satisfy all the requirements of a uniform random number generator, ...
v.min()
Proposed Resolution:
Change the first sentence of the description
of v.min()
in 5.1.1 [tr.rand.req], Table 5.2
(Uniform random number generator requirements) from:
Returns somel
wherel
is less than or equal to all values potentially returned byoperator()
.
to:
Returns a value that is less than or equal to all values
potentially returned by operator()
.
v.max()
Proposed Resolution:
Change the first sentence of the description
of v.max()
in 5.1.1 [tr.rand.req], Table 5.2
(Uniform random number generator requirements) from:
Ifstd::numeric_limits<T>::is_integer
, returnsl
wherel
is less than or equal to all values potentially returned byoperator()
, otherwise, returnsl
wherel
is strictly less than all values potentially returned byoperator()
.
to:
Ifstd::numeric_limits<T>::is_integer
, returns a value that is greater than or equal to all values potentially returned byoperator()
, otherwise, returns a value that is strictly greater than all values potentially returned byoperator()
.
Proposed Resolution:
Copy the description of X::result_type
from 5.1.1
[tr.rand.req], Table 5.1 (Number generator requirements) to 5.1.1
[tr.rand.req], Table 5.2 (Uniform random number generator
requirements) and to 5.1.1 [tr.rand.req], Table 5.4 (Random
distribution requirements) and remove 5.1.1 [tr.rand.req], Table 5.1
(Number generator requirements).
UniformRandomNumberGenerator::result_type
, although
variate_generator
is supposed to possibly convert between
integer and floating-point types.
Proposed resolution:
In 5.1.1 [tr.rand.req], replace the pre/post-condition for
result_type
(fold with resolution for issue 3):
bystd::numeric_limits<T>::is_specialized
istrue
T
is an arithmetic type [basic.fundamental]
Additional requirements: The complexity of both copy construction and assignment is O(size of state).
Proposed resolution:
Replace in 5.1.1 [tr.rand.req], last paragraph
Furthermore, a template parameter named RealType shall denote a type that holds an approximation to a real number. This type shall meet the requirements for a numeric type (26.1 [lib.numeric.requirements]), the binary operators +, -, *, / shall be applicable to it, a conversion from double shall exist, and function signatures corresponding to those for type double in subclause 26.5 [lib.c.math] shall be available by argument-dependent lookup (3.4.2 [basic.lookup.koenig]). [Note: The built-in floating-point types float and double meet these requirements.]by
Furthermore, the effect of instantiating a template that has a template type parameter namedDelete from 5.1.7 [tr.rand.dist]RealType
is undefined unless that type is one offloat
,double
, orlong double
.
A template parameter named IntType shall denote a type that represents an integer number. This type shall meet the requirements for a numeric type (26.1 [lib.numeric.requirements]), the binary operators +, -, *, /, % shall be applicable to it, and a conversion from int shall exist. [Footnote: The built-in types int and long meet these requirements.]Add after 5.1.1 [tr.rand.req], last paragraph[...]
No function described in this section throws an exception, unless an operation on values of IntType or RealType throws an exception. [Note: Then, the effects are undefined, see [lib.numeric.requirements]. ]
The effect of instantiating a template that has a template type parameter namedIntType
is undefined unless that type is one ofshort
,int
,long
, or their unsigned variants.The effect of instantiating a template that has a template type parameter named
UIntType
is undefined unless that type is one ofunsigned short
,unsigned int
, orunsigned long
.
[This last change also prevents questions that random number engines / distributions have to be usable with IntType = bool and other atrocities.]
variate_generator
Holding a
Reference Be Assignable?Proposed Resolution:
Change the first two sentences of the third paragraph of 5.1.3 [tr.rand.var] from:
Specializations ofvariate_generator
satisfy the requirements of CopyConstructible. They also satisfy the requirements of Assignable unless the template parameterEngine
is of the formU&
.
to:
Specializations of variate_generator
satisfy the
requirements of CopyConstructible and Assignable.
Replace in 5.1.3 [tr.rand.var]
The complexity of all functions specified in this section is constant.by
Except where specified otherwise, the complexity of all functions specified in this section is constant.Add for
variate_generator(engine_type e, distribution_type
d)
Complexity: Sum of the complexities of the copy construtors ofAdd forengine_type
anddistribution_type
.
result_type operator()()
Complexity: Amortized constant.Add for
result_type operator()(T value)
Complexity: Amortized constant.
In 5.1.3 [tr.rand.var], add the highlighted text for
min()
:
Precondition: distribution().min() is well-formed
Proposed resolution:
Add in 5.1.4.6 [tr.rand.eng.xor] in the paragraph after the class definition
BothUniformRandomNumberGenerator1::result_type
andUniformRandomNumberGenerator2::result_type
shall denote (possibly different) unsigned integral types. The size of the state ...
In 5.1.4.6 [tr.rand.eng.xor] replace
typedef typename base_type::result_type result_type;by
typedef /* see below */ result_type;and add at the end of the paragraph below the class definition
The memberresult_type
is defined to that type ofUniformRandomNumberGenerator1::result_type
andUniformRandomNumberGenerator2::result_type
that provides the most storage [basic.fundamental].
Proposed resolution:
Add in 5.1.4.6 [tr.rand.eng.xor], paragraph after the class definition, before "The size of the state ..."
The following relation shall hold: 0 <= s1 and 0 <= s2.
Proposed resolution:
Add in 5.1.4.6 [tr.rand.eng.xor] in the paragraph after the class definition:
The size of the state is the size of the state of b1 plus the size of the state of b2.
In 5.1.4.3 [tr.rand.eng.sub], replace
The template parameterbyIntType
shall denote a signed integral type large enough to store values up tom
-1.
The template parameterIntType
shall denote an integral type large enough to store values up tom
.
Replace in 5.1.4.4 [tr.rand.eng.sub1] [signature was changed in issue 16, "l" was changed to "lcg" in issue J4, this contains the consolidated edits as far as overlaps are concerned]
byvoid seed(unsigned int value = 19780503)Effects: With a linear congruential generator l(i) having parameters m = 2147483563, a = 40014, c = 0, and l(0) =value
, sets x(-r) ... x(-1) to (l(1)*2-w) mod 1 ... (l(r)*2-w) mod 1, respectively. If x(-1) == 0, sets carry(-1) = 2-w, else sets carry(-1) = 0.
Complexity: O(r)
void seed(unsigned long value = 19780503ul)Effects: With n=(w+31)/32 (rounded downward) and given an iterator range[first, last)
that refers to the sequence of values lcg(1) ... lcg(n*r) obtained from a linear congruential generator lcg(i) having parameters mlcg = 2147483563, alcg = 40014, clcg = 0, and lcg(0) =value
, invokeseed(first,last)
.
Complexity: O(r*n)
Proposed resolution:
In 5.1.4.2 [tr.rand.eng.mers], change the signature of a constructor and a seed function from
toexplicit mersenne_twister(result_type value); void seed(result_type value);
In 5.1.4.3 [tr.rand.eng.sub], change the signature of a constructor and a seed function fromexplicit mersenne_twister(unsigned long value); void seed(unsigned long value);
toexplicit subtract_with_carry(IntType value); void seed(IntType value = 19780503);
In 5.1.4.4 [tr.rand.eng.sub1], change the signature of a constructor and a seed function fromexplicit subtract_with_carry(unsigned long value); void seed(unsigned long value = 19780503ul);
to:subtract_with_carry_01(unsigned int value); void seed(unsigned int value = 19780503);
subtract_with_carry_01(unsigned long value); void seed(unsigned long value = 19780503ul);
subtract_with_carry::seed(In&, In)
Required Sequence Length Too LongProposed Resolution:
Change
Withn=w/32+1
(rounded downward) and given the valuesz0 ... zn*r-1
to
Withn=(w+31)/32
(rounded downward) and given the valuesz0 ... zn*r-1
in the description of subtract_with_carry::seed(In& first, In
last)
in 5.1.4.3 [tr.rand.eng.sub] and in the description of
subtract_with_carry_01::seed(In& first, In last)
in
5.1.4.4 [tr.rand.eng.sub1].
Replace in 5.1.4.1 [tr.rand.eng.lcong], in the paragraph after the class definition
If the template parameter m is 0, the behaviour is implementation-defined.by
If the template parameter m is 0, the modulus m used throughout this section isstd::numeric_limits<IntType>::max()
plus 1. [Note: The result is not representable as a value of typeIntType
.]
Replace in 5.1.4.1 [tr.rand.eng.lcong]
byexplicit linear_congruential(IntType x0 = 1)Requires: c > 0 || (x0 % m) > 0
Effects: Constructs a linear_congruential engine with state x(0) := x0 mod m.void seed(IntType x0 = 1)Requires: c > 0 || (x0 % m) > 0
Effects: Sets the state x(i) of the engine to x0 mod m.templateRequires: c > 0 || *first > 0linear_congruential(In& first, In last)
Effects: Sets the state x(i) of the engine to *first mod m.
Complexity: Exactly one dereference of *first.
Replace in 5.1.4.2 [tr.rand.eng.mers] [see issue J4 for the change to "lcg"]explicit linear_congruential(IntType x0 = 1)Effects: Constructs alinear_congruential
engine and invokesseed(x0)
.void seed(IntType x0 = 1)Effects: Ifc
modm
= 0 andx0
modm
= 0, sets the state x(i) of the engine to 1 modm
, else sets the state x(i) of the engine tox0
modm
.templateEffects: Iflinear_congruential(In& first, In last) c
modm
= 0 and*first
modm
= 0, sets the state x(i) of the engine to 1 modm
, else sets the state x(i) of the engine to*first
modm
.
Complexity: Exactly one dereference of*first
.
byvoid seed()Effects: Invokes seed(4357).void seed(result_type value)Requires: value > 0
Effects: With a linear congruential generator l(i) having parameters ml = 232, al = 69069, cl = 0, and l(0) = value, sets x(-n) ... x(-1) to l(1) ... l(n), respectively.
Complexity: O(n)
Replace in 5.4.1.3 [tr.rand.eng.sub] [see issue J4 for the change to "lcg"] [see issue 16 for the change to "unsigned long"]void seed()Effects: Invokes seed(0).void seed(result_type value)Effects: Ifvalue
== 0, setsvalue
to 4357. In any case, with a linear congruential generator lcg(i) having parameters mlcg = 232, alcg = 69069, clcg = 0, and lcg(0) =value
, sets x(-n) ... x(-1) to lcg(1) ... lcg(n), respectively.
Complexity: O(n)
byvoid seed(unsigned int value = 19780503)Requires:value > 0
Effects: With a linear congruential generator l(i) having parameters ml = 2147483563, al = 40014, cl = 0, and l(0) =value
, sets x(-r) ... x(-1) to l(1) mod m ... l(r) mod m, respectively. If x(-1) == 0, sets carry(-1) = 1, else sets carry(-1) = 0.
Complexity: O(r)
Replace in 5.4.1.4 [tr.rand.eng.sub1] [see issue J4 for the change to "lcg"] [see issue 16 for the change to "unsigned long"]void seed(unsigned long value = 19780503ul)Effects: Ifvalue
== 0, setsvalue
to 19780503. In any case, with a linear congruential generator lcg(i) having parameters mlcg = 2147483563, alcg = 40014, clcg = 0, and lcg(0) =value
, sets x(-r) ... x(-1) to lcg(1) mod m ... lcg(r) mod m, respectively. If x(-1) == 0, sets carry(-1) = 1, else sets carry(-1) = 0.
Complexity: O(r)
byvoid seed(unsigned int value = 19780503)Effects: With a linear congruential generator l(i) having parameters m = 2147483563, a = 40014, c = 0, and l(0) =value
, sets x(-r) ... x(-1) to (l(1)*2-w) mod 1 ... (l(r)*2-w) mod 1, respectively. If x(-1) == 0, sets carry(-1) = 2-w, else sets carry(-1) = 0.
Complexity: O(r)
void seed(unsigned long value = 19780503ul)Effects: Ifvalue
== 0, setsvalue
to 19780503. In any case, with a linear congruential generator lcg(i) having parameters mlcg = 2147483563, alcg = 40014, clcg = 0, and lcg(0) =value
, sets x(-r) ... x(-1) to lcg(1) mod m ... lcg(r) mod m, respectively. If x(-1) == 0, sets
Complexity: O(r)
linear_congruential
-- Should the Template Arguments Be Unsigned?Proposed Resolution:
In clause 5.1.4.1 [tr.rand.eng.lcong] replace every occurrence of IntType
with UIntType
and change the first sentence after the definition of the template
from:
The template parameterIntType
shall denote an integral type large enough to store values up to(m-1)
.
to:
The template parameterUIntType
shall denote an unsigned integral type large enough to store values up to(m-1)
.
Proposed resolution:
Replace in 5.1.4.5 [tr.rand.eng.disc]
r <= qby
The following relation shall hold: 0 <= r <= p.
Proposed resolution:
In 5.1.7.2 [tr.rand.dist.bern],
change the section heading to "Class bernoulli_distribution",
remove template <class RealType = double>
from the declaration of bernoulli_distribtion
, change the declaration of the
constructor from:
explicit bernoulli_distribution(const RealType& p = RealType(0.5));
to:
explicit bernoulli_distribution(double p = 0.5);
and change the header for the subclause describing the constructor from:
bernoulli_distribution(const RealType& p = RealType(0.5))
to:
bernoulli_distribution(double p = 0.5)
Proposed resolution:
In 5.1.7.6 [tr.rand.dist.runif], replace
min <= x <= maxby
min <= x < max[The half-open interval should be used to avoid various special cases in derived distributions, this is (and always was) correct in the boost documentation.]
Proposed Resolution:
Change the first paragraph of 5.1.7.8 [tr.rand.dist.norm] from:
Anormal_distribution
random distribution produces random numbersx
distributed with probability density function(1/sqrt(2*pi*sigma))e-(x-mean)2/(2*sigma2)
, wheremean
andsigma
are the parameters of the distribution.
to:
Anormal_distribution
random distribution produces random numbersx
distributed with probability density function(1/(sqrt(2*pi)*sigma))e-(x-mean)2/(2*sigma2)
, wheremean
andsigma
are the parameters of the distribution.