Range::Range(Poco::UInt32 lowValue, Poco::UInt32 upValue, bool hardLimit): _lower(lowerLimit(lowValue)), _upper(upperLimit(upValue, hardLimit)) { if (lowValue > upValue) throw LimitException("lowerLimit > upperLimit!"); }
UniformNoise* UniformNoise::clone( uint idx ) const { if ( idx >= getDim( ) ) return 0; UniformNoise tmp( Vector(1),Vector(1) ); tmp.Noise::operator=( *this ); tmp.w.init( 1,1 ); tmp.lowerLimit(0) = lowerLimit(idx); tmp.upperLimit(0) = upperLimit(idx); return ( new UniformNoise( tmp ) ); }
UniformNoise::UniformNoise( uint _dim, double _lowerLimit, double _upperLimit ) : Noise( ) { w.init( _dim,1 ); lowerLimit.init(_dim); upperLimit.init(_dim); for( uint i=0; i<_dim; ++i ) { lowerLimit(i) = _lowerLimit; upperLimit(i) = _upperLimit; } }
returnValue UniformNoise::setLimits( double _lowerLimit, double _upperLimit ) { if ( _lowerLimit > _upperLimit ) return ACADOERROR( RET_INVALID_ARGUMENTS ); for( uint i=0; i<getDim( ); ++i ) { lowerLimit(i) = _lowerLimit; upperLimit(i) = _upperLimit; } return SUCCESSFUL_RETURN; }
returnValue UniformNoise::setLimit( uint idx, double _lowerLimit, double _upperLimit ) { if ( idx >= getDim( ) ) return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS ); if ( _lowerLimit > _upperLimit ) return ACADOERROR( RET_INVALID_ARGUMENTS ); lowerLimit(idx) = _lowerLimit; upperLimit(idx) = _upperLimit; return SUCCESSFUL_RETURN; }
returnValue UniformNoise::step( Vector& _w ) { if ( getStatus( ) != BS_READY ) return ACADOERROR( RET_BLOCK_NOT_READY ); if ( getDim( ) != _w.getDim( ) ) return ACADOERROR( RET_VECTOR_DIMENSION_MISMATCH ); if ( w.getNumPoints( ) != 1 ) w.init( 1,getDim() ); for( uint j=0; j<getDim( ); ++j ) w(0,j) = getUniformRandomNumber( lowerLimit(j),upperLimit(j) ); _w = w.getVector( 0 ); return SUCCESSFUL_RETURN; }
returnValue UniformNoise::step( VariablesGrid& _w ) { if ( getStatus( ) != BS_READY ) return ACADOERROR( RET_BLOCK_NOT_READY ); if ( getDim( ) != _w.getNumValues( ) ) return ACADOERROR( RET_VECTOR_DIMENSION_MISMATCH ); if ( w.getNumPoints( ) != _w.getNumPoints( ) ) w.init( getDim(),_w.getNumPoints( ) ); for( uint i=0; i<_w.getNumPoints( ); ++i ) for( uint j=0; j<getDim( ); ++j ) w(i,j) = getUniformRandomNumber( lowerLimit(j),upperLimit(j) ); _w = w; return SUCCESSFUL_RETURN; }
int Spectrum::lowerLimitSample(const int centerFreq, const float octaves, const int samplesLength) { return lowerLimit(centerFreq, octaves) / (Core::Audio()->getFrequencyRate() / samplesLength); }
void procFeeScaleFromTier(std::string &line,std::vector<FeeScaleXML*> &FeeSclaeList) { FeeScaleXML * xml = new FeeScaleXML(); std::string name(line, 0, 10); std::string firstPos(line, 32, 7); std::string secondPos(line, 32, 7); std::string lowerLimit(line, 10, 5); std::string upperLimit(line, 15, 5); std::string FirstValue(line, 20, 8); std::string SecondValue(line, 28, 8); std::string val="0"; if (FirstValue != "0000.00") { val = FirstValue; } else if (SecondValue != "0000.00"){ val = SecondValue; } if (FeeSclaeList.size() != 0){ interval feeInterval; feeInterval.value = val; feeInterval.upperLimit = upperLimit; std::vector<FeeScaleXML*>::iterator it = FeeSclaeList.end(); --it; if (name.compare((*it)->name) != 0) { //New Fee tier ,set upper limit of last fee as "true" std::vector<interval>::iterator feeIt = (*it)->intervals.end(); --feeIt; feeIt->upperLimit = "true"; feeInterval.lowerLimit = "true"; xml->name = name; xml->description = "description"; xml->currency = "THB"; xml->baseValue = "F"; xml->calculationBase = "A"; xml->calculationMethod = "L"; xml->orderEstimationMode = "F"; xml->overlappingIntervals = "N"; xml->intervals.push_back(feeInterval); xml->FeeAggregationScheme="Client Aggregation"; FeeSclaeList.push_back(xml); } else { // Fee existed ,adds more tier std::vector<interval>::iterator feeIt = (*it)->intervals.end(); --feeIt; feeInterval.lowerLimit = lowerLimit; (*it)->intervals.push_back(feeInterval); } } /* */ }