Commit 3f792cca authored by Lynn Garren's avatar Lynn Garren
Browse files

adding operator double()

parent c6111eb4
......@@ -85,7 +85,8 @@ public:
void showStatus() const;
// Dumps the current engine status on the screen.
operator float(); // flat value, without worrying about filling bits
operator double(); // Returns same as flat()
operator float(); // flat value, without worrying about filling bits
operator unsigned int(); // 32-bit flat value, quickest of all
virtual std::ostream & put (std::ostream & os) const;
......
......@@ -72,8 +72,9 @@ public:
void showStatus() const;
// Dumps the engine status on the screen
operator float(); // flat value, without worrying about filling bits
operator unsigned int(); // 32-bit flat value, quickest of all
operator double(); // Returns same as flat()
operator float(); // flat value, without worrying about filling bits
operator unsigned int(); // 32-bit flat value, quickest of all
virtual std::ostream & put (std::ostream & os) const;
virtual std::istream & get (std::istream & is);
......
......@@ -71,8 +71,9 @@ public:
void showStatus() const;
// Dumps the engine status on the screen
operator float(); // flat value, without worrying about filling bits
operator unsigned int(); // 32-bit flat value, quickest of all
operator double(); // Returns same as flat()
operator float(); // flat value, without worrying about filling bits
operator unsigned int(); // 32-bit flat value, quickest of all
virtual std::ostream & put (std::ostream & os) const;
virtual std::istream & get (std::istream & is);
......
......@@ -77,6 +77,10 @@ public:
void showStatus() const;
// Dumps the engine status on the screen.
operator double();
// Returns same as flat()
operator float();
// less precise flat, faster if possible
operator unsigned int();
// 32-bit flat, but slower than double or float.
......
......@@ -66,7 +66,8 @@ public:
void showStatus() const;
// Dumps the current engine status on the screen.
operator float(); // returns flat, without worrying about filling bits
operator double(); // Returns same as flat()
operator float(); // returns flat, without worrying about filling bits
operator unsigned int(); // 32-bit flat, quickest of all
virtual std::ostream & put (std::ostream & os) const;
......
......@@ -91,6 +91,10 @@ public:
void showStatus() const;
// Dumps the engine status on the screen.
operator double();
// Returns same as flat()
operator float();
// less precise flat, faster if possible
operator unsigned int();
// 32-bit flat
......@@ -179,7 +183,7 @@ private:
typedef struct rng_state_st rng_state_t; // struct alias
rng_state_t S;
};
} // namespace CLHEP
#endif
......@@ -90,6 +90,8 @@ public:
void showStatus() const;
// Dumps the engine status on the screen.
operator double(); // Returns same as flat()
operator float(); // flat value, without worrying about filling bits
operator unsigned int(); // 32-bit flat value, quickest of all.
virtual std::ostream & put (std::ostream & os) const;
......
......@@ -85,6 +85,10 @@ public:
void showStatus() const;
// Dumps the engine status on the screen.
operator double();
// Returns same as flat()
operator float();
// less precise flat, faster if possible
operator unsigned int();
// 32-bit int flat, faster in this case
......
......@@ -92,6 +92,8 @@ public:
int getLuxury() const { return luxury; }
// Gets the luxury level.
operator double(); // Returns same as flat()
operator float(); // less precise flat, faster if possible
operator unsigned int(); // 32-bit flat, but slower than double or float
virtual std::ostream & put (std::ostream & os) const;
......
......@@ -84,20 +84,21 @@ public:
void showStatus() const;
// Dumps the engine status on the screen
operator float(); // flat value, without worrying about filling bits
operator unsigned int(); // 32-bit flat value, quickest of all
operator double(); // Returns same as flat()
operator float(); // flat value, without worrying about filling bits
operator unsigned int(); // 32-bit flat value, quickest of all
virtual std::ostream & put (std::ostream & os) const;
virtual std::istream & get (std::istream & is);
static std::string beginTag ( );
virtual std::istream & getState ( std::istream & is );
virtual std::ostream & put (std::ostream & os) const;
virtual std::istream & get (std::istream & is);
static std::string beginTag ( );
virtual std::istream & getState ( std::istream & is );
std::string name() const;
static std::string engineName() {return "RanshiEngine";}
std::string name() const;
static std::string engineName() {return "RanshiEngine";}
std::vector<unsigned long> put () const;
bool get (const std::vector<unsigned long> & v);
bool getState (const std::vector<unsigned long> & v);
std::vector<unsigned long> put () const;
bool get (const std::vector<unsigned long> & v);
bool getState (const std::vector<unsigned long> & v);
private:
enum {numBuff = 512};
......
......@@ -83,8 +83,9 @@ public:
void showStatus() const;
// Dumps the current engine status on the screen.
operator float(); // flat value, without worrying about filling bits
operator unsigned int(); // 32-bit flat value, quickest of all
operator double(); // Returns same as flat()
operator float(); // flat value, without worrying about filling bits
operator unsigned int(); // 32-bit flat value, quickest of all
virtual std::ostream & put (std::ostream & os) const;
virtual std::istream & get (std::istream & is);
......
......@@ -23,10 +23,6 @@ void DoubConv::fill_byte_order () {
z *= 256;
}
// x, in IEEE format, would now be 0x4330060504030201
union DB8 {
unsigned char b[8];
double d;
};
DB8 xb;
xb.d = x;
int n;
......@@ -121,4 +117,4 @@ double DoubConv::longs2double (const std::vector<unsigned long> & v) {
return db.d;
}
} // end namespace HepMC
} // end namespace CLHEP
......@@ -216,6 +216,10 @@ void DualRand::showStatus() const {
std::cout.precision(pr);
}
DualRand::operator double() {
return flat();
}
DualRand::operator float() {
return (float) ( (integerCong ^ tausworthe) * twoToMinus_32()
+ nearlyTwoToMinus_54() );
......
......@@ -243,6 +243,10 @@ void Hurd160Engine::showStatus() const {
std::cout.precision(pr);
}
Hurd160Engine::operator double() {
return flat();
}
Hurd160Engine::operator float() {
if( wordIndex <= 1 ) { // MF 9/15/98: skip word 0
advance();
......
......@@ -263,6 +263,10 @@ void Hurd288Engine::showStatus() const {
std::cout << "-------------------------------------------" << std::endl;
}
Hurd288Engine::operator double() {
return flat();
}
Hurd288Engine::operator float() {
if( wordIndex <= 1 ) { // MF 9/15/98: skip word 0
advance();
......
......@@ -296,6 +296,14 @@ void HepJamesRandom::flatArray(const int size, double* vect)
}
}
HepJamesRandom::operator double() {
return flat();
}
HepJamesRandom::operator float() {
return float( flat() );
}
HepJamesRandom::operator unsigned int() {
return ((unsigned int)(flat() * exponent_bit_32()) & 0xffffffff ) |
(((unsigned int)( u[i97] * exponent_bit_32())>>16) & 0xff);
......
......@@ -231,6 +231,10 @@ void MTwistEngine::showStatus() const
std::cout << "----------------------------------------" << std::endl;
}
MTwistEngine::operator double() {
return flat();
}
MTwistEngine::operator float() {
unsigned int y;
......
......@@ -339,6 +339,16 @@ void MixMaxRng::flatArray(const int size, double* vect )
for (int i=0; i<size; ++i) { vect[i] = flat(); }
}
MixMaxRng::operator double()
{
return flat();
}
MixMaxRng::operator float()
{
return float( flat() );
}
MixMaxRng::operator unsigned int()
{
return static_cast<unsigned int>(get_next());
......@@ -706,7 +716,7 @@ myuint_t MixMaxRng::apply_bigskip( myuint_t* Vout, myuint_t* Vin, myID_t cluster
myuint_t MixMaxRng::modadd(myuint_t foo, myuint_t bar)
{
#if defined(__x86_64__) && defined(__GNUC__) && (!defined(__ICC))
#if defined(__x86_64__) && defined(__GNUC__) && (!defined(__ICC))
//#warning Using assembler routine in modadd
myuint_t out;
/* Assembler trick suggested by Andrzej Görlich */
......
......@@ -365,6 +365,14 @@ void RandEngine::flatArray(const int size, double* vect)
vect[i]=flat();
}
RandEngine::operator double() {
return flat();
}
RandEngine::operator float() {
return float( flat() );
}
RandEngine::operator unsigned int() {
return RandEngineBuilder<RAND_MAX>::thirtyTwoRandomBits(seq);
}
......
......@@ -266,6 +266,14 @@ void RanecuEngine::flatArray(const int size, double* vect)
table[index][1] = seed2;
}
RanecuEngine::operator double() {
return flat();
}
RanecuEngine::operator float() {
return float( flat() );
}
RanecuEngine::operator unsigned int() {
const int index = seq;
long seed1 = table[index][0];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment