当前位置: 首页>>代码示例>>C++>>正文


C++ Sample类代码示例

本文整理汇总了C++中Sample的典型用法代码示例。如果您正苦于以下问题:C++ Sample类的具体用法?C++ Sample怎么用?C++ Sample使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Sample类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pqueries_per_edge

std::vector<std::vector< Pquery const* >> pqueries_per_edge(
    Sample const& sample,
    bool only_max_lwr_placements
) {
    auto result = std::vector<std::vector< Pquery const* >>();
    result.resize( sample.tree().edge_count() );

    for( auto const& pqry : sample.pqueries() ) {
        if( only_max_lwr_placements ) {

            // If we are only interested in the most probably placement, find it first.
            PqueryPlacement const* max_p = nullptr;
            double max_v = std::numeric_limits<double>::lowest();
            for( auto const& place : pqry.placements() ) {
                if( max_p == nullptr || place.like_weight_ratio > max_v ) {
                    max_v = place.like_weight_ratio;
                    max_p = &place;
                }
            }
            // If there is one, add it to the list for its edge.
            if( max_p ) {
                result[ max_p->edge().index() ].push_back( &pqry );
            }

        } else {
            // If we instead want all placement, simply add them.
            for( auto const& place : pqry.placements() ) {
                result[ place.edge().index() ].push_back( &pqry );
            }
        }
    }

    return result;
}
开发者ID:lczech,项目名称:genesis,代码行数:34,代码来源:helper.cpp

示例2: getMaxGenotypePosterior

    pair<float, bool> getMaxGenotypePosterior(Sample & sample) {

        if (sample.genotypeInfo().empty()) {

            assert(sample.ploidy() == Sample::Ploidy::Zeroploid);
            return make_pair(0, false);            
        }

        assert(sample.ploidy() != Sample::Ploidy::Zeroploid);
        assert(sample.ploidy() != Sample::Ploidy::Polyploid);

        float max_gpp = 0;
        bool has_gpp = false;

        for (auto & info: sample.genotypeInfo()) {

            auto gpp_value = info.getValue<float>("GPP");

            if (gpp_value.second) {

                max_gpp = max(max_gpp, gpp_value.first);
                has_gpp = true;
            }
        }

        assert((max_gpp > 0) or Utils::floatCompare(max_gpp, 0));
        assert((max_gpp < 1) or Utils::floatCompare(max_gpp, 1));
        
        return make_pair(max_gpp, has_gpp);            
    }
开发者ID:bioinformatics-centre,项目名称:BayesTyper,代码行数:30,代码来源:Auxiliaries.cpp

示例3: f_lgt

	ATHENAError Track::GetKeyLength(const SLong & k_id, ULong & length)
	{
		Float f_lgt(0.0F);
		SLong s_id;
		Sample * sample;

		if (ULong(k_id) >= key_c) return ATHENA_ERROR_HANDLE;

		s_id = GetSampleID(s_id);

		if (_sample.IsNotValid(s_id))
		{
			length = 0;
			return ATHENA_OK;
		}

		sample = _sample[s_id];

		TrackKey * key = &key_l[k_id];

		if (key->pitch.interval)
		{
			Float min, max, cur;
			Float size;

			length = sample->length;
			size = Float(length) * (key->loop + 1);

			min = key->pitch.min * sample->format.frequency * key->pitch.interval * 0.001F;
			max = key->pitch.max * sample->format.frequency * key->pitch.interval * 0.001F;

			cur = max;

			while (size > 0.0F)
			{
				f_lgt += key->pitch.interval;
				size -= cur = cur == min ? max : min;
			}

			if (size < 0.0F) f_lgt += key->pitch.interval * (size / cur);

			f_lgt *= 0.5F;
		}
		else
		{
			ULong size, loop;

			sample->GetLength(size);

			loop = (key->loop + 1) / 2;
			f_lgt = (size * loop) * (1.0F / key->pitch.max);
			loop = (key->loop + 1) - loop;
			f_lgt += (size * loop) * (1.0F / key->pitch.min);
		}

		length = key->start + (key->loop + 1) * key->delay_max;
		length += ULong(f_lgt);

		return ATHENA_OK;
	}
开发者ID:tramboi,项目名称:ArxFatalis,代码行数:60,代码来源:Athena_Track.cpp

示例4: while

void Mixer::play(QString name)
{
    Sample *sample;
    int offset;
    bool playing = false;
    QHash<QString, Sample*>::const_iterator i = samples.constBegin();
    while (i != samples.constEnd()) {
        sample = (Sample *)i.value();
        if (sample->playing && sample->loops!=0) {
            playing = true;
            break;
        }
        i++;
    }
    sample = samples[name];
    if (playing) {
        offset = nframes % sample->size;
    }
    else {
        nframes = 0;
        offset = 0;
    }
    if (sample->loops && sample->playing)
        sample->pause();
    else
        sample->play(offset);
}
开发者ID:rrerolle,项目名称:poumtchak,代码行数:27,代码来源:Mixer.cpp

示例5: copySampleList

    void SamplesWidget::getSamples() {
        bool ok;
        unsigned numSamples = sampleAmount->text().toUInt(&ok,10);

        if (ok) {
            Sample *sample;
            int numFree = 0;

            if (collection == NEW && sampleSet->getSize() > 1) {
                copySampleList();
            }

            for (uint i = 0; i < numSamples; ++i) {
                sample = sampler->nextSample();
                sample->setFree(!prob->wSpace()->collisionCheck(sample));
                if (sample->isFree()) {
                    ++numFree;
                    sampleSet->add(sample);
                } else {
                    delete sample;
                }
            }

            QString text = sampleAmount->text() + " samples were generated, "
                    + QString::number(numFree) + " samples are free.";
            writeGUI(text.toUtf8().constData());
            sampleAmount->setText("");
            updateSampleList();
        } else {
            writeGUI("Please, enter a valid amount of samples.");
        }
    }
开发者ID:iocroblab,项目名称:kautham,代码行数:32,代码来源:sampleswidget.cpp

示例6: UpdateFeatureVector

void HsvFeatures::UpdateFeatureVector(const Sample &s)
{
    IntRect rect = s.GetROI();
    cv::Rect roi(rect.XMin(), rect.YMin(), rect.Width(), rect.Height());

    m_featVec.setZero();
    cv::Mat hsv_img = s.GetImage().GetHsvImage()(roi);

    int height = rect.Height();
    int width = rect.Width();

    // continuous?
    if(hsv_img.isContinuous())
    {
        width *= height;
        height = 1;
    }

    int ix, iy;
    uchar *p;
    for(iy=0; iy < height; ++iy)
    {
        p = hsv_img.ptr<uchar>(iy);

        for(ix=0; ix < width; ++ix)
        {
            cv::Vec3b pixel(p[3*ix+0], p[3*ix+1], p[3*ix+2]);
            auto bin_idx = compBinIdx(pixel);
            m_featVec[bin_idx]++;
        }
    }

    m_featVec /= rect.Area();

}
开发者ID:duxiaofei283,项目名称:struck-1,代码行数:35,代码来源:HsvFeatures.cpp

示例7: ajoute_mots_associes

RESULT PPRFA::ajoute_mots_associes (set <Word, ordre_mot> &W,
                                    const Word & v,
                                    const Sample & S,
                                    int maxmots) const
{
    list < Word > L;		// une liste de mot qui sert pour calculer W
    Alphabet::const_iterator b;	// pour enumerer toutes les lettres
    Word w;				// Le mot courant
	
	
    w.clear();			// on initialise avec w <-- epsilon
						// On ajoute tous les successeurs de v
    L.push_back (w);		// et L = { eps }
    while ((!L.empty ()) && (maxmots != 0))
    {				// tant que L n'est pas vide
        w = L.front ();
        L.pop_front ();		// w = min(L) et L=L\{w}
		if (W.find(w) == W.end()) {
			--maxmots;
			W.insert (w);
		}
        for (b = Sigma.begin (); b != Sigma.end (); b++)
        {
            w += *b;  // w <-- wb
			//W.insert(w);
            if (S.find (v+w) != S.end ()) // si p_n(w)>0
            {
                L.push_back (w);
            }
            w.erase (--w.end());	//w.pop_back ();  // wb <-- w
        }
    }
	
    return VAL (0);
}
开发者ID:yogsototh,项目名称:DEES,代码行数:35,代码来源:pprfa_dees.cpp

示例8: main

int main(){
    Sample s;
    s.a = 1;
    s.b =2;
    s.func1();
    s.func2();
}
开发者ID:usgy,项目名称:univ-c-,代码行数:7,代码来源:list3-1_main.cpp

示例9: clearSamples

void SphereSampler::generateSamples(float, float)
{
	clearSamples();
	increaseSampleCount();
	Sample tempSample;
	bool rejectionSampling = false;
	bool sampleFound = false;
	float x = 0.0f;
	float y = 0.0f;
	float z = 0.0f;
	float r = 0.0f;
	
	for (int i = 0; i < getCurrentSampleCount(); i++)
	{
		if (rejectionSampling)
		{
			while (true)
			{
				x = 2.0f * getRandomNumber(0,1) - 1.0f;
				y = 2.0f * getRandomNumber(0,1) - 1.0f;
				z = 2.0f * getRandomNumber(0,1) - 1.0f;
				if ((x*x + y*y + z*z) <= 1)
					break;
			}
			x *= radius;
			y *= radius;
			z *= radius;
			/*while (!sampleFound)
			{
				x = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
				y = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
				z = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
				if ((x*x + y*y + z*z) <= (radius *radius))
					sampleFound = true;;
			}
			sampleFound = false;*/
			tempSample.setOffset(Point3(x, y, z));
		}
		
		/*	? = 2?r1
			? = acos(1 – 2r2)
			x = cx + 2Rcos(2?r1) r2(1 – r2)
			y = cy + 2Rsin(2?r1) r2(1 – r2)
			z = cz + R(1 – 2r2)
		*/
		else
		{
			float r1 = getRandomNumber(0, 1);
			float r2 = getRandomNumber(0, 1);
			/*float phi = 2 * M_PI * r1;
			float theta = acos(1 - (2 * r2));*/
			Point3 offset;
			offset.x = 2 * radius * cos(2 * M_PI * r1) * sqrt(r2*(1 - r2));
			offset.y = 2 * radius * sin(2 * M_PI * r1) * sqrt(r2*(1 - r2));
			offset.z = radius * (1 - (2 * r2));
			tempSample.setOffset(offset);
		}
		addSampleToList(tempSample);
	}
}
开发者ID:amitprakash07,项目名称:Renderer,代码行数:60,代码来源:SphereSampler.cpp

示例10: decomposeProperty

    void decomposeProperty(const Sample<T>& sample, PropertyBag& targetbag)
    {
        std::string tname = detail::DataSourceTypeInfo<T>::getType();
        targetbag.setType("Sample");
        //std::string str;

        assert( targetbag.empty() );

        bool result =true;
        //std::stringstream out;
        //out << i+1;
        //str = out.str();

        Property<PropertyBag>* el_bag = new Property<PropertyBag>("SampleValue", "Sample Value"); 
        Property<T> el("SampleValue" , "Sample value ",sample.ValueGet())  ;
        if(    el.getTypeInfo()->decomposeType(el.getDataSource(),el_bag->value()) )
        {
            //log(Debug)<<"Element type "<<el.getType()<<" is a bag"<<endlog();
            targetbag.add( el_bag ); // Put variables in the bag
        }
        else
        {
            //log(Debug)<<"Element type "<<el.getType()<<" is not a bag"<<endlog();
            //For Property
            targetbag.add( new Property<T>("SampleValue" ,"Sample Value",sample.ValueGet() )); // Put variables in the bag
        }
    };
开发者ID:jeljaik,项目名称:orocos-bfl-berdy,代码行数:27,代码来源:SampleComposition.hpp

示例11: Sample

  //! Retunrs an interpolated sample as a fraction of the distance to smp.
  //! Aditional, if the sample has a mapped configuration, it returns the 
  //! interpolated configuration in the same proportion as the fraction.
  Sample* Sample::interpolate(Sample* smp, KthReal fraction){
    Sample *tmp = new Sample(smp->getDim());
    //Sample tmp(smp->getDim());

	
    // Interpolation in sample space.
    vector<KthReal>& other = smp->getCoords();
    for(unsigned int i = 0; i < _coords.size(); i++)
        tmp->_coords.at(i) = _coords.at(i) + fraction*(other.at(i) - _coords.at(i));


    if(_config.size() > 0){
      // Interpolation in configuration space if it exists.
      //RobConf tmpRobConf;
      vector<RobConf> tmpVec;

	  for(unsigned int i = 0; i < _config.size(); i++){
        //tmpRobConf = _config.at(i).interpolate(smp->getMappedConf().at(i));
        tmpVec.push_back(_config.at(i).interpolate(smp->getMappedConf().at(i), fraction));
	  }

      tmp->setMappedConf(tmpVec);
    }
	
	

	
    return tmp;
  }
开发者ID:iocroblab,项目名称:kautham,代码行数:32,代码来源:sample.cpp

示例12: OFloatGeomParam

//-*****************************************************************************
void OCurvesSchema::createWidthProperty( const Sample &iSamp )
{
    std::vector<float> emptyVals;
    std::vector<Util::uint32_t> emptyIndices;
    OFloatGeomParam::Sample empty;

    if ( iSamp.getWidths().getIndices() )
    {
        empty = OFloatGeomParam::Sample( Abc::FloatArraySample( emptyVals ),
            Abc::UInt32ArraySample( emptyIndices ),
            iSamp.getWidths().getScope() );

        // widths are indexed for some weird reason which is
        // technically ok, just wasteful
        m_widthsParam = OFloatGeomParam( this->getPtr(), "width", true,
                                         iSamp.getWidths().getScope(),
                                         1, this->getTimeSampling() );
    }
    else
    {
        empty = OFloatGeomParam::Sample( Abc::FloatArraySample( emptyVals ),
                                         iSamp.getWidths().getScope() );

        // widths are not indexed
        m_widthsParam = OFloatGeomParam( this->getPtr(), "width", false,
                                         iSamp.getWidths().getScope(), 1,
                                         this->getTimeSampling() );
    }

    // set all the missing samples
    for ( size_t i = 0; i < m_numSamples; ++i )
    {
        m_widthsParam.set( empty );
    }
}
开发者ID:AndyHuang7601,项目名称:EpicGames-UnrealEngine,代码行数:36,代码来源:OCurves.cpp

示例13: Error

////////////////////////////////////////////////////////////////////////////////
// A helper function for loading an Allegro dat file where samples are
// supposed to be stored.
MAS::Error MAS::Skin::LoadSamples(ALLEGRO_PATH *dir) {
   if (!dir || !al_is_path_present(dir))
      return Error(Error::NO_FILE);

   int i;

   const char *sampleName[] = {
      "SAMPLE_ACTIVATE",
      "SAMPLE_CLOSE",
      "SAMPLE_GOTFOCUS",
      "SAMPLE_KEY",
      "SAMPLE_LOSTFOCUS",
      "SAMPLE_OPEN",
      "SAMPLE_SCROLL"
   };

   // Look for each sample inside the dat file and load it if it exists
   for (i=0; i<nSamples; i++) {
      al_set_path_filename(dir, sampleName[i]);
	  al_set_path_extension(dir, ".wav");
      const char *fullPath = al_path_cstr(dir, ALLEGRO_NATIVE_PATH_SEP);
      Sample spl;
      if (spl.Load(fullPath) == Error::NONE) {
         smpList[i]->Set(spl, true);
      }
   }

   al_set_path_filename(dir, "");

   return Error(Error::NONE);
}
开发者ID:bambams,项目名称:ma5king,代码行数:34,代码来源:skin.cpp

示例14: Sample

bool Audio::Load(std::string filename, std::string name)
{
    if (filename.length() == 0 || name.length() == 0) return false;

    Sample *sample = new Sample();
    sample->setName(name);

    try {
        FMOD_RESULT res;
        res = FMOD_System_CreateSound(
                  system, 			//FMOD system
                  filename.c_str(), 	//filename
                  FMOD_DEFAULT, 		//default audio
                  NULL, 				//n/a
                  &sample->sample);	//pointer to sample

        if (res != FMOD_OK) {
            return false;
        }
    } catch (...) {
        return false;
    }
    samples.push_back(sample);

    return true;
}
开发者ID:narc0tiq,项目名称:Unnamed-Train-Game,代码行数:26,代码来源:audio.cpp

示例15: setResultExamples

void FirstLayerNets::setResultExamples(std::vector<Sample> * samples)
{
    Sample * resultSample = &(samples->at(samples->size() - 1));
    for (int i = 0; i < resultSample->getExamplesCount(); i++ ) {
        int num = resultSample->getExamplesNum()[i];

        int posInEnter = 0;
        int posInNeur = resultSample->enterCount;

        for (int j = 0; j < Nets.size(); j++) {
            Sample * sample = &samples->at(j);
            Perceptron * net = Nets[j];
            double * exam = sample->examples[num];
            for (int k = 0; k < net->getNeironsNum().size(); k++) {
                double value = net->getFunctionValue(k, exam);
                if (net->teachExamples.neironsToNextLevel[k]) {
                    resultSample->setEnter(i, posInEnter, value);
                    posInEnter ++;
                }  else {
                    resultSample->setEnter(i, posInNeur, value);
                }
                posInNeur ++;
            }
        }
        posInEnter = 0;
    }
}
开发者ID:dieza13,项目名称:GMDH1,代码行数:27,代码来源:firstlayernets.cpp


注:本文中的Sample类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。