bool StateVectorLimiter<StateType>::testState(const StateVector<StateType> &_stateVec) const { bool result = true; if((_stateVec.size() != mUpper.size()) |(_stateVec.size() != mLower.size())) { std::cout << "incompatible dimensions. can't evaluate state limits\n"; return false; } for(unsigned i=0; i < _stateVec.size(); i++) { bool valid = ((mLower(i) <= _stateVec[i]) & (mUpper(i) >= _stateVec[i])); result &= valid; std::string msg = valid ? "ok" : "error"; std::cout << i << ". value=" << _stateVec[i] << "[" << mLower(i) << " ; " << mUpper(i) << msg << "\n"; } return result; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ EvaluateInt // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ TTBInteger CRandomFunction::EvaluateInt( CProgram &ioState) { SInt32 t; TTBInteger lower=mLower(ioState),higher=mHigher(ioState),temp; if (lower>higher) SwapValues(lower,higher,temp); // this implementation is assuming a 32 bit random number generator // if it's a 16 bit one, then passing a min max with a span > 16 bits will not yield a full spread COMPILE_TIME_ASSERT(RAND_MAX==0x7fffffff); UInt32 diff=higher-lower+1; TTBInteger rand; rand=std::rand()%diff+lower; return rand; }