Example #1
0
int main()
{
  try
    {
      symbol k("k"),q("q"),p("p"),p1("p1"),p2("p2"),p3("p3"),ms("ms"),l("l"),s("s"),m1s("m1s"),m2s("m2s"),m3s("m3s");
      symbol l1("l1"),l2("l2"),l3("l3"),l4("l4"),t("t"),p4("p4"),p5("p5"),p6("p6"),tp("tp"),v1("v1"),v2("v2"),l5("l5");
      symbol k1("k1"),k2("k2"),k3("k3"),k4("k4"),k5("k5"),ms1("ms1"),ms2("ms2"),ms3("ms3"),ms4("ms4");
      symbol s12("s12"),s23("s23"),s34("s34"),s45("s45"),s51("s51"),s13("s13"),s15("s15"),s56("s56"),s16("s16"),s123("s123"),s234("s234"),s345("s345");
      lst inv_l;
      inv_l.append(p1*p1 == 0);
      inv_l.append( p2*p2 == 0);inv_l.append( p3*p3  ==  0);inv_l.append( p4*p4  ==  0);inv_l.append( p5*p5  ==  0);inv_l.append( p6*p6  ==  0);
      inv_l.append(p1* p2  ==  s12/2);inv_l.append( p2* p3  ==  s23/2);inv_l.append( p3* p4  ==  s34/2);inv_l.append( p4* p5  ==  s45/2);
      inv_l.append(p5* p6  ==  s56/2);inv_l.append( p1* p6  ==  s16/2);inv_l.append( p1* p3  ==  (-s12 + s123 - s23)/2);
      inv_l.append(p2* p4  ==  (-s23 + s234 - s34)/2);
      inv_l.append( p3* p5  ==  (-s34 + s345 - s45)/2);
      inv_l.append(p1* p4  ==  (-s123 + s23 - s234 + s56)/2);
      inv_l.append(p1* p5  ==  (-s16 + s234 - s56)/2);
      inv_l.append( p2* p5  ==  (s16 - s234 + s34 - s345)/2);
      inv_l.append( p2* p6  ==  (-s12 - s16 + s345)/2);
      inv_l.append( p3* p6  ==  (s12 - s123 - s345 + s45)/2);
      inv_l.append( p4* p6  ==  (s123 - s45 - s56)/2);
      
      
      RoMB_loop_by_loop hexag(lst(k1),
                              lst(-pow(p1 + k1,2),-pow(p1 + p2 + k1,2),
                                  -pow(p1 + p2 + p3 + k1,2),
                                  -pow(p1 + p2 + p3 + p4 + k1,2),
                                  -pow(p1+p2+p3+p4+p5+k1,2),-pow(k1,2)),
                              inv_l,
                              lst(1,1,1,1,1,1),true);
      hexag.integrate_map(lst(s12 == -1, s23 == -2, s34 == -3, s45 == -4, s56 == -5, s16 == -6, s123 == -7, s234 == -8, s345 == -9));
/*

 FRESULT for parameters: {s12==-1,s23==-2,s34==-3,s45==-4,s56==-5,s16==-6,s123==-7,s234==-8,s345==-9}
 
  FRESULT anl :           = -0.1955084880526298663-1/240*log(8)*log(6)+947/60480*log(2)^2-1/480*log(6)*log(4)+1/1080*log(3)*log(7)+131/7560*log(9)*log(2)+19/1260*log(9)^2-1/560*log(8)*log(4)+523/60480*log(3)^2-1/1080*log(7)*log(5)+41/4320*log(3)*log(5)-1/48*log(8)*log(5)-1/1080*log(7)*log(4)+22/945*log(6)*log(7)+19/3780*log(3)*log(4)+493/30240*Pi^2+43/1008*eps^(-2)+49/8640*log(5)^2-641/30240*log(2)*log(6)+1/1080*log(9)*log(5)-22/945*log(2)*log(7)+271/60480*log(4)^2-3/112*log(8)*log(3)-19/3780*log(9)*log(4)+1/1080*log(4)*log(5)-61/2520*log(9)*log(7)+61/5040*log(7)^2+1/168*log(3)*log(2)+1/168*log(8)*log(9)+13/3360*log(2)*log(4)-1/30240*(-1132.7960047725738361+576*log(8)-163*log(3)+264*log(9)+533*log(2)-479*log(6)-444*log(7)+271*log(4)-287*log(5))*eps^(-1)+47/1680*log(8)^2-17/1680*log(8)*log(2)+767/60480*log(6)^2-22/945*log(9)*log(6)-13/1890*log(3)*log(9)
   FRESULT num:           = 1.9907333428263254975E-4+(0.032177795803854872908)*eps^(-1)+(0.04265873015873015873)*eps^(-2)
    eps^-2 term: 43/1008 +/- 0
     eps^-1 term: 0.03746018534300839405-2/105*log(8)+163/30240*log(3)-11/1260*log(9)-533/30240*log(2)+479/30240*log(6)+37/2520*log(7)-271/30240*log(4)+41/4320*log(5) +/- 9.022403780167233619E-6
      eps^0 term: -0.1955084880526298663-1/240*log(8)*log(6)+947/60480*log(2)^2-1/480*log(6)*log(4)+1/1080*log(3)*log(7)+131/7560*log(9)*log(2)+19/1260*log(9)^2-1/560*log(8)*log(4)+523/60480*log(3)^2-1/1080*log(7)*log(5)+41/4320*log(3)*log(5)-1/48*log(8)*log(5)-1/1080*log(7)*log(4)+22/945*log(6)*log(7)+19/3780*log(3)*log(4)+493/30240*Pi^2+49/8640*log(5)^2-641/30240*log(2)*log(6)+1/1080*log(9)*log(5)-22/945*log(2)*log(7)+271/60480*log(4)^2-3/112*log(8)*log(3)-19/3780*log(9)*log(4)+1/1080*log(4)*log(5)-61/2520*log(9)*log(7)+61/5040*log(7)^2+1/168*log(3)*log(2)+1/168*log(8)*log(9)+13/3360*log(2)*log(4)+47/1680*log(8)^2-17/1680*log(8)*log(2)+767/60480*log(6)^2-22/945*log(9)*log(6)-13/1890*log(3)*log(9) +/- 1.04620404922048185285E-4
      */

    }
  catch(std::exception &p)
    {
      std::cerr<<"******************************************************************"<<endl;
      std::cerr<<"   >>>ERROR:  "<<p.what()<<endl;
      std::cerr<<"******************************************************************"<<endl;
      return 1;
    }
  return 0;
}
Example #2
0
bealab::function<double(double)> makefun( const ex& fun, const symbol& x )
{
	FUNCP_CUBA fp;
	ex fun1 = fun.subs( Pi==pi );
	compile_ex( lst(fun1), lst(x), fp );
	return [fp]( double x )
	{
		int ndim  = 1;
		int ncomp = 1;
		double res;
		fp( &ndim, &x, &ncomp, &res );
		return res;
	};
}
Example #3
0
void PlayerController::CheckPlayerState()
{
RWsSession* iSession=new RWsSession();
iSession->Connect();
TApaTaskList lst(*iSession);
TApaTask tsk=lst.FindApp(KMusicPlayerAppUid);
TApaTask tsk2=lst.FindApp(KRadioUid);

if (tsk.Exists()){emit playerStarted(true);qDebug()<<"player started";}
if (tsk2.Exists())
{
    radioLaunched=true;
    emit playerStarted(false);
    qDebug()<<"radio started";
    int aValue;
    RProperty::Get(KFMRadioPSUid, KFMRadioPSDataFrequency,aValue);
    float freq=aValue/1e6;
    iStation.freq=freq;
    TBuf<255> name,rds,type;
    RProperty::Get(KFMRadioPSUid, KFMRadioPSDataChannelName,name);
    RProperty::Get(KFMRadioPSUid, KFMRadioPSDataRDSRadioText,rds);
    iStation.name=QString::fromRawData(reinterpret_cast<const QChar*>(name.Ptr()),name.Length());
    iStation.rds=QString::fromRawData(reinterpret_cast<const QChar*>(rds.Ptr()),rds.Length());
    QString line;
    if (iStation.name.length()>0) line=QString::fromUtf8(iStation.name.toUtf8().data());
    else if (iStation.rds.length()>0) line=QString::fromUtf8(iStation.rds.toUtf8().data());
    else line=QString::fromUtf8("FM Radio");
    changeTrackInfo(line,QString::number(iStation.freq,'f',2)+" MHz");
}
iSession->Close();
}
Example #4
0
void DirectoryView::setDir( const QString &s )
{
  QListViewItemIterator it( this );
  ++it;
  for ( ; it.current(); ++it ) {
    it.current()->setOpen( false );
  }

  QStringList lst( QStringList::split( "/", s ) );
  QListViewItem *item = firstChild();
  QStringList::Iterator it2 = lst.begin();
  for ( ; it2 != lst.end(); ++it2 ) {
    while ( item ) {
      if ( item->text( 0 ) == *it2 ) {
        item->setOpen( true );
        break;
      }
      item = item->itemBelow();
    }
  }

  if ( item ){
    setSelected( item, true );
    setCurrentItem( item );
  }
}
Example #5
0
int main(int argc, char **argv) {
	int ia[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 55, 89};
	std::vector<int> ivec(ia, ia + 11);
	std::list<int> lst(ia, ia + 11);
	std::vector<int>::iterator iter_vec;
	for (iter_vec = ivec.begin(); iter_vec != ivec.end(); ++iter_vec)
		if (*iter_vec % 2 == 0) {
			ivec.erase(iter_vec);
			--iter_vec;
		}
	std::list<int>::iterator iter_list;
	for (iter_list = lst.begin(); iter_list != lst.end(); ++iter_list)
		if (*iter_list % 2 != 0) {
			lst.erase(iter_list);
			--iter_list;
		}

	iter_vec = ivec.begin();
	while (iter_vec != ivec.end()) {
		std::cout << *iter_vec << " ";
		++iter_vec;
	}
	std::cout << std::endl;

	iter_list = lst.begin();
	while (iter_list != lst.end()) {
		std::cout << *iter_list << " ";
		++iter_list;
	}
	std::cout << std::endl;
}
Example #6
0
void MarkLiberties::leftClick(QGo::goban_sp goban, uint8_t x, uint8_t y)
{
    Goban::type_set_point group = goban->computeLiberties(x, y);
    if(group.empty()) return;
    std::list<Point> lst(group.begin(), group.end());
    iMainWindow::instance().markGroup(lst);
}
/**
    \fn writeLegacyIndex
*/
bool aviIndexOdml::writeLegacyIndex()
{
   
    // 3-write legacy index
    uint64_t pos;
    pos=_masterList->Tell();
    ADM_info("Writting legacy index at %" PRIx64"\n",pos);
    //---
    AviListAvi lst("idx1",_masterList->getFile());
    lst.Begin();

    int n=legacyIndexCount;
    ADMMemio memIo(4*4);
    #define ix32(a)  memIo.write32(legacyIndex[i].a)
    uint32_t base=LMovie->TellBegin()+8; // movi tag
    for(int i=0;i<n;i++)
    {
        memIo.reset();
        ix32(fcc);ix32(flags);memIo.write32(legacyIndex[i].offset-base);ix32(len);
        lst.WriteMem (memIo);
    }
    lst.End();    
    delete [] legacyIndex;
    legacyIndex=NULL;
    return true;
}
FLQuant7_base<T>::FLQuant7_base(SEXP lst_sexp){
    //Rprintf("In FLQuant7_base<T> SEXP constructor\n");
    Rcpp::List lst(lst_sexp);
    Rcpp::List::iterator lst_iterator;
    for (lst_iterator = lst.begin(); lst_iterator != lst.end(); ++ lst_iterator){
        data.push_back(*lst_iterator);
    }
}
Example #9
0
// just use this right now
std::vector<flexible_type> rcpplambda_evaluator::bulk_eval_dict(size_t lambda_hash,
        const std::vector<std::string>& keys,
        const std::vector<std::vector<flexible_type>>& values,
        bool skip_undefined, int seed) {

    std::vector<flexible_type> res(1);

    std::vector<Rcpp::Function> fun_lst = m_lambda_hash[lambda_hash];

    std::vector<std::string> fun_names = m_lambda_name_hash[lambda_hash];

    for (size_t i = 0; i < fun_lst.size(); i++) {
        (*R_ptr)[fun_names[i]] = fun_lst[i];
    }

    std::vector<flexible_type> row = values[0];

    // parse a row into a Rcpp::List and evaluate teh function
    Rcpp::List lst(row.size());
    for (size_t i = 0; i < row.size(); i++) {
        flex_type_enum type = row[i].get_type();
        switch(type) {
        case flex_type_enum::STRING: {
            lst[i] = Rcpp::wrap(row[i].to<flex_string>());
            break;
        }
        case flex_type_enum::FLOAT: {
            lst[i] = Rcpp::wrap(row[i].to<flex_float>());
            break;
        }
        case flex_type_enum::INTEGER: {
            lst[i] = Rcpp::wrap(row[i].to<flex_int>());
            break;
        }
        case flex_type_enum::UNDEFINED: {
            lst[i] = NA_REAL;
            break;
        }
        }
    }

    if (keys.size() > 0 ) {
        lst.attr("names") = keys;
        (*R_ptr)["lst"] = lst;

        R_ptr->parseEvalQ(m_lambda_lib_hash[lambda_hash]);
        SEXP t = R_ptr->parseEval(fun_names[fun_lst.size() - 1] + "(lst)");
        res[0] = Rcpp::as<flexible_type>(t);
        return res;
    } else {
        (*R_ptr)["lst"] = lst[0];
        R_ptr->parseEvalQ(m_lambda_lib_hash[lambda_hash]);
        SEXP t = R_ptr->parseEval(fun_names[fun_lst.size() - 1] + "(lst)");
        res[0] = Rcpp::as<flexible_type>(t);
        return res;
    }

}
Example #10
0
void LFunctionLreduce::
DoApply(int paramsc, const SReference paramsv[], IntelibContinuation& lf) const
{
    SReference ini(paramsc == 3 ? paramsv[2] : paramsv[1].Car());
    SReference lst(paramsc == 3 ? paramsv[1] : paramsv[1].Cdr());
    SReference fun(paramsv[0]);
    SReference iter(new LExpressionLreduceIterator(fun, ini, lst));
    lf.PushTodo(IntelibContinuation::generic_iteration, iter);
}
void Foam::SortableList<T>::sort()
{
    sortedOrder(*this, indices_);

    List<T> lst(this->size());
    forAll(indices_, i)
    {
        lst[i] = this->operator[](indices_[i]);
    }
Example #12
0
 types::list<types::str> file::readlines(int sizehint)
 {
   // Official python doc specifies that sizehint is used as a max of chars
   // But it has not been implemented in the standard python interpreter...
   types::str str;
   types::list<types::str> lst(0);
   while ((str = readline()))
     lst.push_back(str);
   return lst;
 }
Example #13
0
/*!
  Resolves the globally qualified name of \name, including
  package / class / function resolution.
*/
QString QSCheckData::globalName( const QString &name ) const
{
    QStringList lst(name);
    QSScopeResolutionList::const_iterator it = scopeStack.begin();
    while( it!=scopeStack.end() ) {
	lst.prepend( (*it).name() );
	it++;
    }
    return lst.join( QString::fromLatin1(".") );
}
    //-----------------------------------------------------------------------
    FileInfoListPtr UnicodeFileSystemArchive::listFileInfo(bool _recursive, bool _dirs)
    {
		// Note that we have to tell the SharedPtr to use OGRE_DELETE_T not OGRE_DELETE by passing category
		FileInfoListPtr lst(OGRE_NEW_T(FileInfoList, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T);
		
		FileFinder fileFinder(this, mWName, getIgnoreHidden());
		fileFinder.run(L"*", _recursive, _dirs, nullptr, lst.getPointer());
        
		return lst;
    }
Example #15
0
int
main(int argc, char *argv[])
{
  std::vector<int> lst(argc-1);
  int i;
  for(i=1;i<argc;i++) lst[i-1] = atoi(argv[i]);
  mergesort(lst.begin(), lst.end());
  std::for_each( &lst[0], &lst[argc-1], print<int>);
  std::cout << std::endl;
}
    //-----------------------------------------------------------------------
    StringVectorPtr UnicodeFileSystemArchive::list(bool _recursive, bool _dirs)
    {
		// directory change requires locking due to saved returns
		// Note that we have to tell the SharedPtr to use OGRE_DELETE_T not OGRE_DELETE by passing category
		StringVectorPtr lst(OGRE_NEW_T(StringVector, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T);
		
		FileFinder fileFinder(this, mWName, getIgnoreHidden());
		fileFinder.run(L"*", _recursive, _dirs, lst.getPointer(), nullptr);
        
		return lst;
    }
Example #17
0
void perfTest(int n) {
	list<int> lst(n);
	int perm[n+1];
	Util::genPerm(n,perm);

	cout << "perfTest " << n << endl;

	uint32_t t0 = Util::getTime();
	for (int i = 0; i < n; i++) lst.push_back(i);
	uint32_t t1= Util::getTime();
	double addBack = ((double) t1 - (double) t0)/n;
	cout << "appending to end: " << addBack << " us per operation\n";

	t0= Util::getTime();
	for (int i = 0; i < n; i++) lst.pop_front();
	t1= Util::getTime();
	double removeFront = ((double) t1 - (double) t0)/n;
	cout << "removing from front: " << removeFront << " us per operation\n";

	t0 = Util::getTime();
	for (int i = 0; i < n; i++) lst.push_back(1+perm[i]);
	t1= Util::getTime();
	double addBackRand = ((double) t1 - (double) t0)/n;
	cout << "appending to end in random order: " << addBack
	     << " us per operation\n";

	t0= Util::getTime();
	for (int i = 1; i <= n; i++) lst.pop_front();
	t1= Util::getTime();
	removeFront = ((double) t1 - (double) t0)/n;
	cout << "removing from front: " << removeFront << " us per operation\n";

	list<int>::iterator p;
	if (n <= 10000) {
		for (int i = 0; i < n; i++) lst.push_back(1+perm[i]);
		t0= Util::getTime();
		for (int i = 1; i <= n; i++) { lst.remove(i); }
		t1= Util::getTime();
		double removeByValue = ((double) t1 - (double) t0)/n;
		cout << "removing by value: " << removeByValue
		     << " us per operation\n";
	}

	for (int i = 0; i < n; i++) lst.push_back(1+perm[i]);
	int sum = 0;
	t0= Util::getTime();
	for (p = lst.begin(); p != lst.end(); p++) sum += *p;
	t1= Util::getTime();
	double sumInOrder = ((double) t1 - (double) t0)/n;
	cout << "summing in order: " << sumInOrder << " us per operation "
	     << sum << "\n";

	cout << endl;
}
Example #18
0
void* Foam::sigFpe::mallocNan(size_t size)
{
    // Call the low-level GLIBC malloc function
    void * result = __libc_malloc(size);

    // Initialize to signalling NaN
    UList<scalar> lst(reinterpret_cast<scalar*>(result), size/sizeof(scalar));
    sigFpe::fillNan(lst);

    return result;
}
Example #19
0
std::vector<std::string>
Condition::portnames() const
{
    std::vector<std::string> lst(m_list.size());

    std::transform(m_list.begin(),
                   m_list.end(),
                   lst.begin(),
                   [](const value_type& v) { return v.first; });

    return lst;
}
    //-----------------------------------------------------------------------
    FileInfoListPtr UnicodeFileSystemArchive::findFileInfo(const String& _pattern, 
        bool _recursive, bool _dirs) const
    {
		// Note that we have to tell the SharedPtr to use OGRE_DELETE_T not OGRE_DELETE by passing category
		FileInfoListPtr lst(OGRE_NEW_T(FileInfoList, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T);

		WString wpattern = toWString(_pattern);
		FileFinder fileFinder(const_cast<UnicodeFileSystemArchive*>(this), mWName, getIgnoreHidden());
		fileFinder.run(wpattern, _recursive, _dirs, nullptr, lst.getPointer());

        return lst;
    }
Example #21
0
	SizeString::SizeString(const SizeString& sz)
	{
		StringList lst(sz.explode('x'));
		if(lst.size() >= 2) {
			m_first = lst.at(0).toInt();
			m_second = lst.at(1).toInt();
		}
		else {
			m_first = 0;
			m_second = 0;
		}
	}
Example #22
0
MetaData::MetaData (Rcpp::List md)
/*
 * Construct meta data from the R list of meta data.
 *
 * Used for prediction.
 *
 * Format:
 * [[0]] ---- Number of variables
 * [[1]] ---- Index of target variable
 * [[2]] ---- Target variable name
 * [[3]] ---- Variable name vector
 * [[4]] ---- Variable type vector
 * [[5]] ---- Discrete variable value list
 */
{

    nvars_         = Rcpp::as<int>(md[NVARS]);
    var_types_     = type_vec(Rcpp::as<vector<int> >(md[VAR_TYPES]));

    feature_vars_ = idx_vec(nvars_);
    var_names_    = name_vec(nvars_);

    Rcpp::CharacterVector varnames((SEXP)(md[VAR_NAMES]));
    for (int vindex = 0; vindex < nvars_; vindex++) {
        string name = Rcpp::as<string>((SEXPREC*)varnames[vindex]);
        var_names_[vindex] = name;
    }

    Rcpp::List valuenames((SEXP)(md[VAL_NAMES]));
    for (int i = 0; i < valuenames.size(); i++) {
        Rcpp::List lst(valuenames[i]);
        int vindex = Rcpp::as<int>((SEXPREC*)lst[0]);
        Rcpp::CharacterVector levels(lst[1]);
        int nlevels = levels.size();

        name_vec levnames(nlevels);
        name_value_map namevals;
        for (int lindex = 0; lindex < nlevels; lindex++) {
            string name = Rcpp::as<string>((SEXPREC*)levels[lindex]);
            namevals.insert(name_value_map::value_type(name, lindex));
            levnames[lindex] = name;
        }
        var_values_[vindex].swap(namevals);
        val_names_[vindex].swap(levnames);
    }

    for (int i = 0; i < nvars_; ++i)
        feature_vars_[i] = i;

    nlabels_ = val_names_[nvars_].size();

}
Example #23
0
QStringList MetaDataBase::changedProperties( QObject *o )
{
    setupDataBase();
    MetaDataBaseRecord *r = db->find( (void*)o );
    if ( !r ) {
        qWarning( "No entry for %p (%s, %s) found in MetaDataBase",
                  o, o->name(), o->className() );
        return QStringList();
    }

    QStringList lst( r->changedProperties );
    return lst;
}
Example #24
0
static void zeta2_print_latex(const ex& m_, const ex& s_, const print_context& c)
{
	lst m;
	if (is_a<lst>(m_)) {
		m = ex_to<lst>(m_);
	} else {
		m = lst(m_);
	}
	lst s;
	if (is_a<lst>(s_)) {
		s = ex_to<lst>(s_);
	} else {
		s = lst(s_);
	}
	c.s << "\\zeta(";
	auto itm = m.begin();
	auto its = s.begin();
	if (*its < 0) {
		c.s << "\\overline{";
		(*itm).print(c);
		c.s << "}";
	} else {
		(*itm).print(c);
	}
	its++;
	itm++;
	for (; itm != m.end(); itm++, its++) {
		c.s << ",";
		if (*its < 0) {
			c.s << "\\overline{";
			(*itm).print(c);
			c.s << "}";
		} else {
			(*itm).print(c);
		}
	}
	c.s << ")";
}
Example #25
0
User::ListPtr
User::find(Yb::Session &session,
           const Yb::Expression &filter, const Yb::Expression &order_by)
{
    User::ListPtr lst(new User::List());
    Yb::ObjectList rows;
    session.load_collection(rows, Yb::Expression(_T("T_USER")), filter, order_by);
    if (rows.size()) {
        Yb::ObjectList::iterator it = rows.begin(), end = rows.end();
        for (; it != end; ++it)
            lst->push_back(User(*it));
    }
    return lst;
}
Example #26
0
int main()
{
    // use find to search an array
    int ia[6] = {27, 210, 12, 47, 109, 83};
    int search_value = 83;

    int *result = find(ia, ia + 6, search_value);

    cout << "The value " << search_value
         << (result == ia + 6
               ? " is not present" : " is present")
         << endl;

    // use find to search a vector
{
    // initialize the vector with some values
    int ia[6] = {27, 210, 12, 47, 109, 83};
    vector<int> vec(ia, ia+6);

    // value we'll look for
    int search_value = 42;

    // call find to see if that value is present
    vector<int>::const_iterator result =
            find(vec.begin(), vec.end(), search_value);

    // report the result
    cout << "The value " << search_value
         << (result == vec.end()
               ? " is not present" : " is present")
         << endl;
}

    // use find to search a list
{
    list<int> lst(ia, ia+6);

    int search_value = 47;

    // call find to look through elements in a list
    list<int>::const_iterator result =
             find(lst.begin(), lst.end(), search_value);

    cout << "The value " << search_value
         << (result == lst.end()
               ? " is not present" : " is present")
         << endl;
}
    return 0;
}
ScheduleGroup::ListPtr
ScheduleGroup::find(Yb::Session &session,
        const Yb::Expression &filter, const Yb::Expression &order_by)
{
    ScheduleGroup::ListPtr lst(new ScheduleGroup::List());
    Yb::ObjectList rows;
    session.load_collection(rows, Yb::Expression(_T("T_SCHEDULE_GROUP")), filter, order_by);
    if (rows.size()) {
        Yb::ObjectList::iterator it = rows.begin(), end = rows.end();
        for (; it != end; ++it)
            lst->push_back(ScheduleGroup(*it));
    }
    return lst;
}
int main()
{
  Node lst(11);
  Node two(22), thr(33), fou(44);
  lst.add_node(&two);
  lst.add_node(&thr);
  lst.add_node(&fou);
  lst.traverse();
  lst.remove_node(44);
  lst.traverse();
  lst.remove_node(22);
  lst.traverse();
  lst.remove_node(11);
  lst.traverse();
}
Example #29
0
void PlayerController::Close(TUid aUid)
{
    RWsSession* iSession=new RWsSession();
    iSession->Connect();
    if (aUid==KRadioUid)
    {
    radioLaunched=false;
    qDebug()<<"radio closed";
    if (!playerLaunched){emit playerClosed();}
    }
    TApaTaskList lst(*iSession);
    TApaTask tsk=lst.FindApp(aUid);
    if(tsk.Exists()){tsk.EndTask();}
    iSession->Close();
}
Example #30
0
void lu(Array<T> &lower, Array<T> &upper, Array<int> &pivot, const Array<T> &in)
{
    dim4 iDims = in.dims();
    int M = iDims[0];
    int N = iDims[1];

    Array<T> in_copy = copyArray<T>(in);

    //////////////////////////////////////////
    // LU inplace
    int *pivotPtr  = pinnedAlloc<int>(min(M, N));
    T   *inPtr     = pinnedAlloc<T>  (in_copy.elements());
    copyData(inPtr, in);

    getrf_func<T>()(AF_LAPACK_COL_MAJOR, M, N,
                    inPtr, in_copy.strides()[1],
                    pivotPtr);

    convertPivot(&pivotPtr, M, min(M, N));

    pivot = createHostDataArray<int>(af::dim4(M), pivotPtr);
    //////////////////////////////////////////

    // SPLIT into lower and upper
    dim4 ldims(M, min(M, N));
    dim4 udims(min(M, N), N);

    T *lowerPtr = pinnedAlloc<T>(ldims.elements());
    T *upperPtr = pinnedAlloc<T>(udims.elements());

    dim4 lst(1, ldims[0], ldims[0] * ldims[1], ldims[0] * ldims[1] * ldims[2]);
    dim4 ust(1, udims[0], udims[0] * udims[1], udims[0] * udims[1] * udims[2]);

    lu_split<T>(lowerPtr, upperPtr, inPtr, ldims, udims, iDims,
                lst, ust, in_copy.strides());

    lower = createHostDataArray<T>(ldims, lowerPtr);
    upper = createHostDataArray<T>(udims, upperPtr);

    lower.eval();
    upper.eval();

    pinnedFree(lowerPtr);
    pinnedFree(upperPtr);
    pinnedFree(pivotPtr);
    pinnedFree(inPtr);
}