Sample Capture::getCameraSample() const { if(!m_VideoBufferCurrent) return Sample(); return Sample(m_VideoBufferCurrent, m_SampleTime); }
unsigned char *CGraphics_OpenGL::Rescale(int Width, int Height, int NewWidth, int NewHeight, int Format, const unsigned char *pData) { unsigned char *pTmpData; int ScaleW = Width/NewWidth; int ScaleH = Height/NewHeight; int Bpp = 3; if(Format == CImageInfo::FORMAT_RGBA) Bpp = 4; pTmpData = (unsigned char *)mem_alloc(NewWidth*NewHeight*Bpp, 1); int c = 0; for(int y = 0; y < NewHeight; y++) for(int x = 0; x < NewWidth; x++, c++) { pTmpData[c*Bpp] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 0, ScaleW, ScaleH, Bpp); pTmpData[c*Bpp+1] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 1, ScaleW, ScaleH, Bpp); pTmpData[c*Bpp+2] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 2, ScaleW, ScaleH, Bpp); if(Bpp == 4) pTmpData[c*Bpp+3] = Sample(Width, Height, pData, x*ScaleW, y*ScaleH, 3, ScaleW, ScaleH, Bpp); } return pTmpData; }
static void SomeCut(This *t, Cut *cut, Bounds *b) { count dim, maxdim; static count nextdim = 0; real xmid[NDIM], ymid, maxdev; for( dim = 0; dim < t->ndim; ++dim ) xmid[dim] = .5*(b[dim].upper + b[dim].lower); ymid = Sample(t, xmid); maxdev = 0; maxdim = 0; for( dim = 0; dim < t->ndim; ++dim ) { real ylower, yupper, dev; creal x = xmid[dim]; xmid[dim] = b[dim].lower; ylower = Sample(t, xmid); xmid[dim] = b[dim].upper; yupper = Sample(t, xmid); xmid[dim] = x; dev = fabs(ymid - .5*(ylower + yupper)); if( dev >= maxdev ) { maxdev = dev; maxdim = dim; } } if( maxdev > 0 ) nextdim = 0; else maxdim = nextdim++ % t->ndim; cut->i = Upper(maxdim); cut->save = b[maxdim].upper; b[maxdim].upper = xmid[maxdim]; }
TEST(CameraTest, GenerateRay){ Camera c = Camera(vec3(0, 0, 1), vec3(0, 0, 0), vec3(0, 1, 0), 90); Film film = Film(2, 2); Sample sample = Sample(0, 0); Ray *ray = new Ray(vec4(0,0,0,1), vec4(0,0,0,0), 0, 0, 100); c.generateRay(sample, ray, film); EXPECT_EQ(ray->pos.x, 0); EXPECT_EQ(ray->pos.y, 0); EXPECT_EQ(ray->pos.z, 1); // dir vec3 dir = glm::normalize(vec3(-1,1,-1)); EXPECT_EQ(ray->dir.x, dir.x); EXPECT_EQ(ray->dir.y, dir.y); EXPECT_EQ(ray->dir.z, dir.z); // another point Sample sample2 = Sample(2,0); c.generateRay(sample2, ray, film); vec3 dir2 = glm::normalize(vec3(1,1,-1)); EXPECT_EQ(ray->dir.x, dir2.x); EXPECT_EQ(ray->dir.y, dir2.y); EXPECT_EQ(ray->dir.z, dir2.z); }
result_type result(Args const &args) const { std::size_t cnt = count(args); std::size_t n = static_cast<std::size_t>( std::ceil( cnt * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) ) ); // If n is in a valid range, return result, otherwise return NaN or throw exception if (n <= static_cast<std::size_t>(tail(args).size())) return numeric::average( std::accumulate( tail(args).begin() , tail(args).begin() + n , Sample(0) ) , n ); else { if (std::numeric_limits<result_type>::has_quiet_NaN) { return std::numeric_limits<result_type>::quiet_NaN(); } else { std::ostringstream msg; msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; boost::throw_exception(std::runtime_error(msg.str())); return Sample(0); } } }
peaks_over_threshold_prob_impl(Args const &args) : mu_(sign::value * numeric::average(args[sample | Sample()], (std::size_t)1)) , sigma2_(numeric::average(args[sample | Sample()], (std::size_t)1)) , threshold_probability_(args[pot_threshold_probability]) , fit_parameters_(boost::make_tuple(0., 0., 0.)) , is_dirty_(true) { }
void BenchCli(char ch1, char ch2, const char * cmd) { char * at; int requestSize; int responseSize; int packetSize; int contribSize; int count; int i; long startTime; long transTime; Sampler readSamp; Sampler writeSamp; Sampler sizeSamp; if (sock == -1) { printf("# socket is not open\n"); Where(); return; } if (sscanf(cmd, "%d %d %d", &requestSize, &responseSize, &count) != 3) { Usage(ch1, ch2); return; } InitSampler(&readSamp); InitSampler(&writeSamp); InitSampler(&sizeSamp); write(sock, cmd, strlen(cmd)); read(sock, BenchBuf, 1); startTime = LMGetTicks(); for (i=0; i++<count; ) { transTime = LMGetTicks(); write(sock, BenchBuf, requestSize); Sample(&writeSamp, LMGetTicks()-transTime); packetSize = 0; transTime = LMGetTicks(); do { contribSize = read(sock, BenchBuf, 8192); packetSize += contribSize; Sample(&sizeSamp, contribSize); } while (packetSize < responseSize); Sample(&readSamp, LMGetTicks()-transTime); } printf("# Test took %d ticks.\n", LMGetTicks() - startTime); printf("# Read min: %2d max: %2d avg: %2.1f\n", readSamp.min, readSamp.max, ((double)readSamp.sum) / readSamp.count); printf("# Size min: %2d max: %2d avg: %2.1f\n", sizeSamp.min, sizeSamp.max, ((double)sizeSamp.sum) / sizeSamp.count); printf("# Write min: %2d max: %2d avg: %2.1f\n", writeSamp.min, writeSamp.max, ((double)writeSamp.sum) / writeSamp.count); }
weighted_peaks_over_threshold_prob_impl(Args const &args) : sign_((is_same<LeftRight, left>::value) ? -1 : 1) , mu_(sign_ * numeric::average(args[sample | Sample()], (std::size_t)1)) , sigma2_(numeric::average(args[sample | Sample()], (std::size_t)1)) , threshold_probability_(args[pot_threshold_probability]) , fit_parameters_(boost::make_tuple(0., 0., 0.)) , is_dirty_(true) { }
int main(int argc, char* argv[]) { int Error = 0; sample Sample(argc, argv); Error += Sample(); return Error; }
// protected functions: CColor CRenderingCore::Sample(float x, float y, int curDepth) { CColor colArray[5]; CColor finalCol; int colCount = 1; double dXFraction; double dYFraction; /******************************************************************* STRATEGY: 1. First compute the color for the central pixel. 2. Check if we have to dive further into the oversampling recursion. 3. Average the colors. 4. Return the color. *******************************************************************/ // 1. /*********************************************************** SUB_STEPS: 1.1. Calculate the x and y fractions. 1.2. Get the corresponding ray from the camera. 1.3. Test the scene to see which object intersects the ray. 1.4. Query the object for teh color of the point. ***********************************************************/ // 1.1. dYFraction = (double)y / (double)m_iPixelY; dXFraction = (double)x / (double)m_iPixelX; // 1.2. CRay ray = m_pcamCurrent->GetRay(dXFraction, dYFraction); // 1.3. CIntersectionInfo hitInfo = g_objScene.TestRayForClosest(ray); // 1.4. colArray[0] = hitInfo.GetShape()->ShadePoint(hitInfo); // 2. if (curDepth < m_iSupersampleDepth) { colCount = 5; float inc = 1.0f / (float) pow(2.0f, (float)curDepth); colArray[1] = Sample (x + inc, y, curDepth + 1); colArray[2] = Sample (x - inc, y, curDepth + 1); colArray[3] = Sample (x, y + inc, curDepth + 1); colArray[4] = Sample (x, y - inc, curDepth + 1); } // 3. finalCol = CColor::Average(colArray, colCount); // 4. return finalCol; }
Sample Channel::generateNextSample() { double output = moduleChain_.output() * volume_; moduleChain_.input(ModuleChain::NEW_NOTE) = 0; if(pan_ <= 0) { return Sample(output * (pan_ + 1), output); } else { return Sample(output, output * (-pan_ + 1) ); } }
Sample Apply(Sample in) const { static const Coeff ONE(1); static const Coeff ZERO(0); if (Level == ONE) { return in; } else if (Level == ZERO) { return Sample(); } return Sample((Level * in.Left()).Round(), (Level * in.Right()).Round()); }
Sample SampleRes::Create(Audio* audio, const String& path) { Sample_Impl* res = new Sample_Impl(); res->m_audio = audio; if(!res->Init(path)) { delete res; return Sample(); } audio->GetImpl()->Register(res); return Sample(res); }
weighted_density_impl(Args const &args) : cache_size(args[density_cache_size]) , cache(cache_size) , num_bins(args[density_num_bins]) , samples_in_bin(num_bins + 2, 0.) , bin_positions(num_bins + 2) , histogram( num_bins + 2 , std::make_pair( numeric::fdiv(args[sample | Sample()],(std::size_t)1) , numeric::fdiv(args[sample | Sample()],(std::size_t)1) ) ) , is_dirty(true) { }
weighted_sum_impl(Args const &args) : weighted_sum_( args[parameter::keyword<Tag>::get() | Sample()] * numeric::one<Weight>::value ) { }
result_type result(Args const &args) const { std::size_t cnt = count(args); std::size_t n = static_cast<std::size_t>( std::ceil( cnt * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) ) ); // If n is in a valid range, return result, otherwise return NaN or throw exception if ( n < static_cast<std::size_t>(tail(args).size())) { // Note that the cached samples of the left are sorted in ascending order, // whereas the samples of the right tail are sorted in descending order return *(boost::begin(tail(args)) + n - 1); } else { if (std::numeric_limits<result_type>::has_quiet_NaN) { return std::numeric_limits<result_type>::quiet_NaN(); } else { std::ostringstream msg; msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; boost::throw_exception(std::runtime_error(msg.str())); return Sample(0); } } }
// The raytracing process void CRenderingCore::RenderPixelBuffer() { /************************************************************** STRATEGY: 1. Run nested loop for the entire screen. **************************************************************/ m_pcamCurrent->Describe(); // 1. for (int y = 0; y < m_iPixelY; y++) { for (int x = 0; x < m_iPixelX; x++) { CColor colToUse; /**************************************************************** NESTED LOOP LOGIC: Calculate the X fraction Get the pixel ray for this screen coordinate fromt the camera Get the color for this ray. Plot the pixel with this color. ****************************************************************/ colToUse = Sample ((float)x, (float)y, 1); m_ppPixelBuffer[0][x][y] = ((float) (int)(colToUse.GetRed() * 1000.0f)) / 1000.0f; m_ppPixelBuffer[1][x][y] = ((float) (int)(colToUse.GetGreen() * 1000.0f)) / 1000.0f; m_ppPixelBuffer[2][x][y] = ((float) (int)(colToUse.GetBlue() * 1000.0f)) / 1000.0f; } } }
void AutonomousDrumMachine::load_samples() { QString dir_name = QFileDialog::getExistingDirectory(this, "Load sample directory:"); if(dir_name!="") { QDir dir(dir_name); if(!dir.exists()) { qDebug() << "folder does not exist"; qDebug() << "ERROR: this line should never be reached"; return; } qDebug() << "Loading samples..."; dir.setSorting(QDir::LocaleAware); dir.setFilter(QDir::Files); samples.clear(); ui->_wSampleList->clear(); for(auto file_info : dir.entryInfoList()) { QString file_name = file_info.fileName(); QFile file(dir.filePath(file_name)); samples.push_back(Sample()); auto & buffer = samples.back().buffer; auto & sound = samples.back().sound; if(!buffer.loadFromFile(file.fileName().toStdString())) { qDebug() << "could not load file" << file_name; samples.pop_back(); } else { ui->_wSampleList->addItem(QString("(%1) %2").arg(samples.size()-1).arg(file_name)); sound.setBuffer(buffer); sound.play(); qDebug() << "loaded" << file_name; } } sample_features.assign(samples.size(),std::set<Feature>()); } else { qDebug() << "no file selected"; } }
void CSource::Sample(std::mt19937_64 &gen, CParticleState* p_ParticleState) { std::uniform_real_distribution<> real_dis(0,1); std::vector<double> randoms; for ( int i = 0 ; i < 10 ; i++ ) { randoms.push_back(real_dis(gen)); } real_dis(gen); Sample(randoms,p_ParticleState); /* //std::cout<<"In CSource::Sample(gen, CParticleState)"<<std::endl; std::vector<double>::iterator iter_low; std::uniform_real_distribution<> real_dis(0, m_v_dRelativeAbundances.back()); iter_low = std::lower_bound(m_v_dRelativeAbundances.begin(), m_v_dRelativeAbundances.end(), real_dis(gen) ); m_v_p_Spectra[iter_low - m_v_dRelativeAbundances.begin() - 1]->Sample(gen, p_ParticleState); //std::cout<<p_ParticleState->GetParticleID()<<" "<<p_ParticleState->GetEnergy()<<" "<<p_ParticleState->GetWeight()<<std::endl; // //If biased run by weight take care of spectral weight here // //p_ParticleState->SetWeight(p_ParticleState->GetWeight()/m_dAbundanceSum);?? // // //Now take care of spatial distribution: // if(m_p_Spatial != 0x0) { m_p_Spatial->Sample(gen); p_ParticleState->SetPosition(m_p_Spatial->GetPosition()); p_ParticleState->SetDirection(m_p_Spatial->GetDirection()); } */ //std::cout<<p_ParticleState->GetParticleID()<<" "<<p_ParticleState->GetEnergy()<<" "<<p_ParticleState->GetWeight()<<std::endl; }
void CImageProcess::ANN_Region() { char path[512] = {0}; float obj[MAX_TRAIN_COLS] = {0}; Sample("./sources/0 (1).bmp", obj, MAX_TRAIN_COLS); CvANN_MLP bpANN; CvANN_MLP_TrainParams param; param.term_crit = cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,5000,0.01); param.train_method = CvANN_MLP_TrainParams::BACKPROP; param.bp_dw_scale = 0.1; param.bp_moment_scale = 0.1; Mat layerSize = (Mat_<int>(1,3)<<MAX_TRAIN_COLS ,MAX_OBJ_COLS,MAX_OBJ_COLS); bpANN.create(layerSize, CvANN_MLP::SIGMOID_SYM); //m_bpANN.load("./sources/mlp.xml"); Mat input(1, MAX_TRAIN_COLS, CV_32FC1, obj); float _obj[MAX_OBJ_COLS] ={0}; Mat out(1, MAX_OBJ_COLS, CV_32FC1, _obj); //Mat out; bpANN.predict(input,out); int i=0; i+=i; }
static void TilesetBorderfix(int w, int h, CPixel *pSrc, CPixel *pDest) { int TileW = w/16; int TileH = h/16; mem_zero(pDest, sizeof(CPixel)*w*h); for(int ty = 0; ty < 16; ty++) { for(int tx = 0; tx < 16; tx++) { for(int y = 0; y < TileH-2; y++) { for(int x = 0; x < TileW-2; x++) { float u = 0.5f/TileW + x/(float)(TileW-2); float v = 0.5f/TileH + y/(float)(TileH-2); int k = (ty*TileH+1+y)*w + tx*TileW+x+1; pDest[k] = Sample(tx*TileW, ty*TileH, TileW, TileH, pSrc, w, u, v); if(x == 0) pDest[k-1] = pDest[k]; if(x == TileW-2-1) pDest[k+1] = pDest[k]; if(y == 0) pDest[k-w] = pDest[k]; if(y == TileH-2-1) pDest[k+w] = pDest[k]; if(x == 0 && y == 0) pDest[k-w-1] = pDest[k]; if(x == TileW-2-1 && y == 0) pDest[k-w+1] = pDest[k]; if(x == 0 && y == TileH-2-1) pDest[k+w-1] = pDest[k]; if(x == TileW-2-1 && y == TileH-2-1) pDest[k+w+1] = pDest[k]; } } } } }
bool Sphere::Sample(const Interaction &ref, const Point2f &sample, Interaction *it) const { // Compute coordinate system for sphere sampling Point3f pCenter = (*ObjectToWorld)(Point3f(0, 0, 0)); Point3f pOrigin = OffsetRayOrigin(ref.p, ref.pError, ref.n, pCenter - ref.p); Vector3f wc = Normalize(pCenter - ref.p); Vector3f wcX, wcY; CoordinateSystem(wc, &wcX, &wcY); // Sample uniformly on sphere if $\pt{}$ is inside it if (DistanceSquared(pOrigin, pCenter) <= 1.0001f * radius * radius) return Sample(sample, it); // Sample sphere uniformly inside subtended cone Float sinThetaMax2 = radius * radius / DistanceSquared(ref.p, pCenter); Float cosThetaMax = std::sqrt(std::max((Float)0., (Float)1. - sinThetaMax2)); SurfaceInteraction isectSphere; Float tHit; Ray r = ref.SpawnRay(UniformSampleCone(sample, cosThetaMax, wcX, wcY, wc)); if (!Intersect(r, &tHit, &isectSphere)) return false; *it = isectSphere; if (ReverseOrientation) it->n *= -1.f; return true; }
result_type result(Args const &args) const { float_type threshold = sum_of_weights(args) * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); std::size_t n = 0; Weight sum = Weight(0); while (sum < threshold) { if (n < static_cast<std::size_t>(tail_weights(args).size())) { sum += *(tail_weights(args).begin() + n); n++; } else { if (std::numeric_limits<result_type>::has_quiet_NaN) { return std::numeric_limits<result_type>::quiet_NaN(); } else { std::ostringstream msg; msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; boost::throw_exception(std::runtime_error(msg.str())); return Sample(0); } } } // Note that the cached samples of the left are sorted in ascending order, // whereas the samples of the right tail are sorted in descending order return *(boost::begin(tail(args)) + n - 1); }
void NFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iterator end, bool positiveOnly) { Complex ci; qint16 sample; Real a, b, s, demod; double meansqr = 1.0; for(SampleVector::const_iterator it = begin; it < end; ++it) { Complex c(it->real() / 32768.0, it->imag() / 32768.0); c *= m_nco.nextIQ(); if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &ci)) { s = ci.real() * ci.real() + ci.imag() * ci.imag(); meansqr += s; m_movingAverage.feed(s); if(m_movingAverage.average() >= m_squelchLevel) m_squelchState = m_sampleRate / 50; a = m_scale * m_this.real() * (m_last.imag() - ci.imag()); b = m_scale * m_this.imag() * (m_last.real() - ci.real()); m_last = m_this; m_this = Complex(ci.real(), ci.imag()); demod = m_volume * m_lowpass.filter(b - a); sample = demod * 30000; // Display audio spectrum to 12kHz if (++m_framedrop & 1) m_sampleBuffer.push_back(Sample(sample, sample)); if(m_squelchState > 0) m_squelchState--; else sample = 0; { m_audioBuffer[m_audioBufferFill].l = sample; m_audioBuffer[m_audioBufferFill].r = sample; ++m_audioBufferFill; if(m_audioBufferFill >= m_audioBuffer.size()) { uint res = m_audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 1); if(res != m_audioBufferFill) qDebug("lost %u samples", m_audioBufferFill - res); m_audioBufferFill = 0; } } m_sampleDistanceRemain += (Real)m_sampleRate / 48000.0; } } if(m_audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill, 0) != m_audioBufferFill) ;//qDebug("lost samples"); m_audioBufferFill = 0; if(m_sampleSink != NULL) m_sampleSink->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), true); m_sampleBuffer.clear(); // TODO: correct levels m_scale = ( end - begin) * m_sampleRate / 48000 / meansqr; }
f32 SphericalRectangle::Integrate( const vec3f & integrationNrm, u32 sampleCount, std::vector<f32>& shvals, int nBand ) const { // Construct a Spherical Rectangle from the point integrationPos const f32 area = S; // spherical rectangle area/solidangle const int nCoeff = nBand * nBand; std::vector<f32> shtmp( nCoeff ); // Sample the spherical rectangle for ( u32 i = 0; i < sampleCount; ++i ) { const vec2f randV( Random::GlobalPool.Next(), Random::GlobalPool.Next() ); //const vec2f randV = Random::Vec2f(); vec3f rayDir = Sample( randV.x, randV.y ) - o; const f32 rayLenSq = Dot( rayDir, rayDir ); rayDir = Normalize( rayDir ); SHEval( nBand, rayDir.x, rayDir.z, rayDir.y, &shtmp[0] ); for ( int j = 0; j < nCoeff; ++j ) { shvals[j] += shtmp[j]; } } return area / (f32) sampleCount; }
Point Sphere::Sample(const Point &p, float u1, float u2, Normal *ns) const { // Compute coordinate system for sphere sampling Point Pcenter = (*ObjectToWorld)(Point(0,0,0)); Vector wc = Normalize(Pcenter - p); Vector wcX, wcY; CoordinateSystem(wc, &wcX, &wcY); // Sample uniformly on sphere if $\pt{}$ is inside it if (DistanceSquared(p, Pcenter) - radius*radius < 1e-4f) return Sample(u1, u2, ns); // Sample sphere uniformly inside subtended cone float sinThetaMax2 = radius*radius / DistanceSquared(p, Pcenter); float cosThetaMax = sqrtf(max(0.f, 1.f - sinThetaMax2)); DifferentialGeometry dgSphere; float thit, rayEpsilon; Point ps; Ray r(p, UniformSampleCone(u1, u2, cosThetaMax, wcX, wcY, wc), 1e-3f); if (!Intersect(r, &thit, &rayEpsilon, &dgSphere)) thit = Dot(Pcenter - p, Normalize(r.d)); ps = r(thit); *ns = Normal(Normalize(ps - Pcenter)); if (ReverseOrientation) *ns *= -1.f; return ps; }
result_type result(Args const &args) const { float_type threshold = sum_of_weights(args) * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ); std::size_t n = 0; Weight sum = Weight(0); while (sum < threshold) { if (n < static_cast<std::size_t>(tail_weights(args).size())) { sum += *(tail_weights(args).begin() + n); n++; } else { if (std::numeric_limits<float_type>::has_quiet_NaN) { std::fill( this->tail_means_.begin() , this->tail_means_.end() , std::numeric_limits<float_type>::quiet_NaN() ); } else { std::ostringstream msg; msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; boost::throw_exception(std::runtime_error(msg.str())); } } } std::size_t num_variates = tail_variate(args).begin()->size(); this->tail_means_.clear(); this->tail_means_.resize(num_variates, Sample(0)); this->tail_means_ = std::inner_product( tail_variate(args).begin() , tail_variate(args).begin() + n , tail_weights(args).begin() , this->tail_means_ , numeric::functional::plus<array_type const, array_type const>() , numeric::functional::multiply_and_promote_to_double<VariateType const, Weight const>() ); float_type factor = sum * ( (is_same<Impl, relative>::value) ? non_coherent_weighted_tail_mean(args) : 1. ); std::transform( this->tail_means_.begin() , this->tail_means_.end() , this->tail_means_.begin() , std::bind2nd(numeric::functional::divides<typename array_type::value_type const, float_type const>(), factor) ); return make_iterator_range(this->tail_means_); }
BluetoothReceiver::BluetoothReceiver() : bandpassFilter(BPLENGTH), differentiatorFilter(DIFFLENGTH) { m_bitrate = 1; m_bitDelay = BITDELAYBT; // Compute Bandpass filter coefficients and const double h0 = sqrt(2.0) * Br; const double kexp = -twopi * Br * Br; for (int i=0; i<bandpassFilter.size(); ++i) { double temp = i - (BPLENGTH *1.)/2.+.5; temp /= Ns; double hreal = h0 * exp(kexp * temp * temp); bandpassFilter[i] = Sample(hreal,0.0); } // Set Differentiator filter coefficients differentiatorFilter[0] = Sample(-0.0062, 0.0); differentiatorFilter[1] = Sample(0.0372, 0.0); differentiatorFilter[2] = Sample(-0.4566, 0.0); differentiatorFilter[3] = Sample(0.4566, 0.0); differentiatorFilter[4] = Sample(-0.0372, 0.0); differentiatorFilter[5] = Sample(0.0062, 0.0); }
result_type result(Args const &args) const { std::size_t cnt = count(args); std::size_t n = static_cast<std::size_t>( std::ceil( cnt * ( ( is_same<LeftRight, left>::value ) ? args[quantile_probability] : 1. - args[quantile_probability] ) ) ); std::size_t num_variates = tail_variate(args).begin()->size(); this->tail_means_.clear(); this->tail_means_.resize(num_variates, Sample(0)); // If n is in a valid range, return result, otherwise return NaN or throw exception if (n < static_cast<std::size_t>(tail(args).size())) { this->tail_means_ = std::accumulate( tail_variate(args).begin() , tail_variate(args).begin() + n , this->tail_means_ , numeric::plus ); float_type factor = n * ( (is_same<Impl, relative>::value) ? non_coherent_tail_mean(args) : 1. ); std::transform( this->tail_means_.begin() , this->tail_means_.end() , this->tail_means_.begin() #ifdef BOOST_NO_CXX98_BINDERS , std::bind(std::divides<float_type>(), std::placeholders::_1, factor) #else , std::bind2nd(std::divides<float_type>(), factor) #endif ); } else { if (std::numeric_limits<float_type>::has_quiet_NaN) { std::fill( this->tail_means_.begin() , this->tail_means_.end() , std::numeric_limits<float_type>::quiet_NaN() ); } else { std::ostringstream msg; msg << "index n = " << n << " is not in valid range [0, " << tail(args).size() << ")"; boost::throw_exception(std::runtime_error(msg.str())); } } return make_iterator_range(this->tail_means_); }
covariance_impl(Args const &args) : cov_( numeric::outer_product( numeric::fdiv(args[sample | Sample()], (std::size_t)1) , numeric::fdiv(args[parameter::keyword<VariateTag>::get() | VariateType()], (std::size_t)1) ) ) { }