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


C++ boost::array类代码示例

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


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

示例1: evaluate_odd_polynomial

inline V evaluate_odd_polynomial(const boost::array<T,N>& a, const V& z)
{
   typedef mpl::int_<N-1> tag_type;
   return a[0] + z * detail::evaluate_polynomial_c_imp(static_cast<const T*>(a.data()) + 1, V(z*z), static_cast<tag_type const*>(0));
}
开发者ID:3DJ,项目名称:ofxOgre,代码行数:5,代码来源:rational.hpp

示例2: buffer

inline mutable_buffer_container_1 buffer(boost::array<Pod_Type, N>& data)
{
  return mutable_buffer_container_1(
      mutable_buffer(data.c_array(), data.size() * sizeof(Pod_Type)));
}
开发者ID:Sukumi,项目名称:python-libtorrent,代码行数:5,代码来源:buffer.hpp

示例3: test

void test()
{
   std::cout << "Testing type " << typeid(T).name() << std::endl;
   static const boost::array<const char*, 51u> data =
   {{
      "1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
      "9.47747587596218770242116751705184563668845029215054154915126374673142219159548534317576897266130328412495991561490384353e76",
      "8.98225489794452370997623936390755615068333094834545092387689795875746440121970819499035111276893290879203289092353747850e153",
      "8.51291041070124257524798251795398355552294928156627848633073113916721592074889256105483993631579761345100284245144410506e230",
      "8.06809030516483860484254925989129017112482132468761563276276594763374886826841745433660192438855214332469192411759402790e307",
      "7.64651312322841630493169711336894888932951818957138997327518186691187347879142222644283389432604713409023263917264358401e384",
      "7.24696436606255985380192585665173794455118215150711210905481870053193336336731228464367470327868286988180495111406609690e461",
      "6.86829299533155197480610865771404565313986987801060270120621935139741577246731459024227828759564450034267891072352816870e538",
      "6.50940811722948585242669672360741252715012399316164518226061001845519670701239429603657927628755169479689062519606799624e615",
      "6.16927583978348964454665652571294215251327375137123272041877979478545511090085756858225302357977159539777447847855503405e692",
      "5.84691629437043896753869572004324228849833391140408095171257918435296982661233664069534601413835876272500275725690968474e769",
      "5.54140081286660645835370762406928689330724181979654545550204201113926269281603301564114980528619942840737770415885783439e846",
      "5.25184925229805200184933663459660562493261505058724212670923083643709964294855282715531768162298567379648573804433968486e923",
      "4.97742745928448409225535325233998957076879979440190164347796593390995994951755710667491911026476108957070504003155645761e1000",
      "4.71734486697204622371883518659702954552385115723942808636490157561056417525827884479573988899517566587636669779645610803e1077",
      "4.47085221753216236037602345430121605512330975424643767098987010800161616413051148037751552110081034066081309007796182114e1154",
      "4.23723940366531198300986713567588008777043812458400705569721660157434941774066620870256745107265536124077734836797938268e1231",
      "4.01583342289144005397455901781647949754375366066998182220342540048111140676724909947493787596336610499122085983712119281e1308",
      "3.80599643873362813900306284477369187319506389058898599816705625750135796510808933786432614186155972485637939057212164098e1385",
      "3.60712394320959592074309301816510372687695286650188776957291994751966018917404878612237961367128638199290387601511358836e1462",
      "3.41864301533745457066062991907289263038319874930395315315257927161138360206596116102724713069518697248463965164712972907e1539",
      "3.24001067063873569456703204286462007769933831045558617578289414699244767403736057931834775727420762410328297596596814910e1616",
      "3.07071229688386868087623659761166306563170839771162347830514606977592027644137144160294469813988158463967740978461420862e1693",
      "2.91026017157373047094077218552378456052150304677863670611408570458991015300131731261787644801415538043027268185097710615e1770",
      "2.75819205688636078700279174380111581147323147951670302427494196210176478494486073721584055059489736040565979466551070179e1847",
      "2.61406986804110104534167739704643351039975992759905579635058824027507742375380077276380178376470686987855503581867681046e1924",
      "2.47747841124391945459619002346303925269640785743990333362087223895627681769816204236257960940497519376881830373722711456e2001",
      "2.34802418757813746316913800667907927718925648696508255347624141597281474683823345136640610924639820192825966082309575303e2078",
      "2.22533425939475124828943430510333464605535146852848680647615867629953075390889821397228584866395924176189346073006180260e2155",
      "2.10905517593659363154553947631071808925462553114068144748077359132255993441363479041540672158497404660986163617828972963e2232",
      "1.99885195510122536266653916064141606295420554580140619900425370702471778604391774578696867899999534265169574306808906810e2309",
      "1.89440711840917173277691572886942144916664047407963356271198286654087884646102070148271284410118233470318337745546895603e2386",
      "1.79541977639739687088375911648976940254141946934175300605485966288703931992861387257771264702798405630917098672594899744e2463",
      "1.70160476180317540861346545791118106171203487587101437710693054174454895160403997508137760007058856854991413121389834429e2540",
      "1.61269180804119796097157014527479883521656118500417752963675677684343588976915851637637232001139108420659882326614772004e2617",
      "1.52842477060722969066998464046690349841548269556677423378408183476489015878816585045578141383463708674469365281537792914e2694",
      "1.44856088916530600122626623629347336702026699647293500058111037526381692645547938577338582002157148103479049071921438452e2771",
      "1.37287008819265239873777879432333192404914357037749380145412895230166352318128978403808382142784030558123748263528360645e2848",
      "1.30113431416759441771790128053911040907207490879890145597562380328956450092799014856149474809345424672958343296615764490e2925",
      "1.23314690739099822369963411660419632130352733806319401863570442920347696015409870236230656305563674376063778482449716744e3002",
      "1.16871200663155636468514484039368694043851858077879103221831997264419096417014996945143145495038265243932745953706526253e3079",
      "1.10764398487979357804590117089134596938734185016144401218934115168561552640448889215089150481162977776214124397487013110e3156",
      "1.04976691458528698318220729857405616816444374000182094405930946710168752954926612218474430081526312018810817657409158490e3233",
      "9.94914060836531582868347569174220216007647278536863127198023584205669825317884219144692385409156165042162234017403353704e3309",
      "9.42927401023380446961314339401657458785389811652244742482194123119943160577946366372207045050095290781679375214307398844e3386",
      "8.93657169598281164656322298275337750103095739790107943666668184304335665562867744740310577868880098719252549186849812451e3463",
      "8.46961426624835911826517103631490619655296714141872141145089865045804196205328364155921945616925875458926717336478525196e3540",
      "8.02705648870740089929294815816002943860908317454595055392168733404583122074223427054310572378841634984243492063192095337e3617",
      "7.60762342267101369970765191988545810374824800500875923752736467467657167098026707905341603949108433696304383346239333297e3694",
      "7.21010674617694221027190468649359000420209460539838589305387835463807416706224777302997789297329446308541513638035437482e3771",
      "6.83336127500041943234365059231968669406267422759442985746460610830503287734479988530512309065240678799786759250323660701e3848",
   }};

   T pi = static_cast<T>("3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367892590360011330530548820466521384146951941511609");

   unsigned max_err = 0;
   for(unsigned k = 0; k < data.size(); k++)
   {
      T val = exp(sqrt((pi * (100 * k)) * (100 * k)));
      T e = relative_error(val, T(data[k]));
      unsigned err = e.template convert_to<unsigned>();
      if(err > max_err)
      {
         max_err = err;
      }
      val = exp(-sqrt((pi * (100 * k)) * (100 * k)));
      e = relative_error(val, T(1/T(data[k])));
      err = e.template convert_to<unsigned>();
      if(err > max_err)
      {
         max_err = err;
      }
   }
   std::cout << "Max error was: " << max_err << std::endl;
#if defined(BOOST_INTEL) && defined(TEST_FLOAT128)
   BOOST_TEST(max_err < 40000);
#else
   BOOST_TEST(max_err < 5000);
#endif

   static const boost::array<boost::array<T, 2>, 10> exact_data =
   {{
      {{ std::ldexp(1.0, -50), static_cast<T>("1.00000000000000088817841970012562676935794497867573073630970950828771105957980924149923657574337470594698012676100224953") }},
      {{ std::ldexp(1.0, -20), static_cast<T>("1.00000095367477115374544678824955687428365188553281789775169686343569285229334215539516690752571791280462887427635269562") }},
      {{ std::ldexp(1.0, -10), static_cast<T>("1.00097703949241653524284529261160650646585162918174419940186408264916250428896869173656853690882467186075613761065459261") }},
      {{ 0.25, static_cast<T>("1.28402541668774148407342056806243645833628086528146308921750729687220776586723800275330641943955356890166283174967968731") }},
      {{ 0.5, static_cast<T>("1.64872127070012814684865078781416357165377610071014801157507931164066102119421560863277652005636664300286663775630779700") }},
      {{ 0.75, static_cast<T>("2.11700001661267466854536981983709561013449158470240342177913303081098453336401282000279156026661579821888590471901551426") }},
      {{ 10, static_cast<T>("22026.4657948067165169579006452842443663535126185567810742354263552252028185707925751991209681645258954515555010924578367") }},
      {{ 10.5, static_cast<T>("36315.5026742466377389120269013166179689315579671275857607480190550842856628099187749764427758174866310742771977376827512") }},
      {{ 25, static_cast<T>("7.20048993373858725241613514661261579152235338133952787362213864472320593107782569745000325654258093194727871848859163684e10") }},
      {{ 31.25, static_cast<T>("3.72994612957188849046766396046821396700589012875701157893019118883826370993674081486706667149871508642909416337810227575e13") }},
   }};

   max_err = 0;
//.........这里部分代码省略.........
开发者ID:AntonBikineev,项目名称:multiprecision,代码行数:101,代码来源:test_exp.cpp

示例4: trigger_path_names

using namespace edm;

typedef std::vector< std::vector<bool> > Answers;

typedef std::vector<std::string> Strings;
typedef std::vector<Strings> VStrings;
typedef std::vector<bool> Bools;
typedef std::vector<Bools> VBools;

// Name all our paths. We have as many paths as there are trigger
// bits.

size_t const num_trig_paths = 8;
boost::array<char const*, num_trig_paths> cpaths = 
      {{      
              "ap1", "ap2", "aq1", "aq2", 
              "bp1", "bp2", "bq1", "bq2",
      }};
Strings trigger_path_names(cpaths.begin(),cpaths.end());


struct PathSpecifiers {
  Strings path;
  PathSpecifiers (std::string const & s0,
  		  std::string const & s1 = "",
  		  std::string const & s2 = "",
  		  std::string const & s3 = "",
  		  std::string const & s4 = "",
  		  std::string const & s5 = "",
  		  std::string const & s6 = "",
  		  std::string const & s7 = "",
开发者ID:12345ieee,项目名称:cmg-cmssw,代码行数:31,代码来源:EventSelOverlap_t.cpp

示例5: array

 array(const boost::array<T, N> &array,
       const context &context = system::default_context())
     : m_buffer(context, sizeof(T) * N)
 {
     boost::compute::copy(array.begin(), array.end(), begin());
 }
开发者ID:2bbb,项目名称:compute,代码行数:6,代码来源:array.hpp

示例6: test

void test()
{
   std::cout << "Testing type " << typeid(T).name() << std::endl;
   static const boost::array<const char*, 101u> data =
   {{
         "-2.37609908807915949996042688873953402912174184373388399043229539427530802169622688886435380890546981798452174137747437590e-1",
         "8.03406366226813589517543567844755380935198206635917017883860879215939165740799963435747185200486086864198723786516760875e-1",
         "8.60219386510802105228997694366289682807721120146423711696179175800635220710279361583231346318224971127450760223168489952e-1",
         "-1.36768951513839774357595871594675554406872039078811749027554673949684004409484639336417431285061889554892096426752261915e-1",
         "-9.66210139195431691033548069227792927999642647449593184440815029076272297050360196975341458076547426373476590671462150981e-1",
         "-6.12007278553856790723803948280976098970972124581361775428331444376106018942231526074915731012122426588769327127413045994e-1",
         "4.91927698740873688392439262912409276430264703350691359723802294639643655296838880236042651349290074585311025856549893171e-1",
         "9.93232596718899824059271235487971663771012607519717340071654721877802691370866768064059943491135925674950430467047724563e-1",
         "2.77789911520199551017947550534057049374212876971194676010301098598339529915403722848373365985645657342475739669568931563e-1",
         "-7.77955945956221239101360662190442739163791527953499629555756394261998892874934847131138921705713935365505245406994428077e-1",
         "-8.80676278306736581575818642341143682410874043182925227659938804267878718513212454821032629378618345485453587099696563832e-1",
         "9.54652155963865007116798560589970996367213754762169439269792747771200843006278637115722685610960738675814993576019945344e-2",
         "9.54658201427917718824191302196929158303422390793460018465335986921801519149657723689322277773550748806000948225466432438e-1",
         "6.44358700620889799575033272322899136331490664925359198096632560532437137894857803619177106562399406351419810452110265174e-1",
         "-4.55304635273050571206400777159475409897339683148730716647371922365967582339285347105376503917296765204188604297021364549e-1",
         "-9.97202532932553753622481171186283382950122646390227670693679248197349800205205290898290539070732778341271049474946533154e-1",
         "-3.17489525058325500707686194437148362752290391406825231198381521862930317513649081353670386166519524315810546189268634469e-1",
         "7.51160186640147504067744846462384089742696250681200524524912647858645140367792164416711871535116761744380912486921554617e-1",
         "8.99610194168373157174515848193119670768490559799348397680196213249921436405001710937402190319584272526657508442591319630e-1",
         "-5.39963892484342940823660554048696208293700871414984387094529796385334086703752106515008832585578915389731907422242902573e-2",
         "-9.41455348900839346761557896365239742769987576963330061702397697388879776230596944312519157729410022380228287314835345969e-1",
         "-6.75595816763857390859268297670835380459024839344154743310231115864242050771191159334664874097564054770066166961642073448e-1",
         "4.17894201894880415042381733708896725748531223743344790054523182948440843948904650988733732381978194392219295696279423635e-1",
         "9.99447981389824371458566861195586395552622718284098766856978062347139060489410032781030191080200904443096549587568037683e-1",
         "3.56640095868759075150409032448421838265699043643228482503057299699740924345262819242042067863780263400092250418388628640e-1",
         "-7.23065426868134142613141384486526262450487633432466529798821958977732347646832059032382447792655111641456570392189752211e-1",
         "-9.16988391192434436877664999042786024703848714036221388727578305299843547352325574309860356272561772723624753484063972217e-1",
         "1.24341855683226931265962750806821531283439413068694552738675989282017066737438591268502070364982899342633928417210588531e-2",
         "9.26624413643579136646620112107410908114766812511471130116341925013001661546817531064974089666536893346764523464250445838e-1",
         "7.05664607841658050248613256866289182754229289446384595719719495272020558391145537620968819401219414243210529013148958366e-1",
         "-3.79761093422301890838671114556341706055562482358183402807224298533060188038450560241345615647754569347252101282386222173e-1",
         "-9.99965058979463689113370264378210962384824970050865061898892508056811665771886385589295806419278045318841717598003331419e-1",
         "-3.95173919871548266286836251448043149039940610894391718791244019288314418437411707835924620250473697245151743147215758686e-1",
         "6.93720251624319621941983929806434090162802383400620564454074825718151625795576680427510026452063593762417421561201654156e-1",
         "9.32780816819880202610269817418700102084277332259524791943833699964920012022753227823298655560837271746316929623378078695e-1",
         "2.91495208658083070508005579692813621670878962971611104453227900103973434149303469066898102622556226584993895360896300290e-2",
         "-9.10191043170480685360743788297835112117551819731152897291272407935139876953384666161532187572493791297095784055525159185e-1",
         "-7.34513075127503122343910106816656237074878218180284276449954797048122379869002663646507706411949095015624141821039453971e-1",
         "3.40971254411713599427147477626159847871020791931107106418841144080445813896332252160005593096670674809345703079384115052e-1",
         "9.98752871506016936810666998588493462933191829230756181478046320353377054175122206889047094521687205093218701141334147081e-1",
         "4.33024359542714849537532946954507232835434973891665238942502273464321666207117525270650546741831354943253652514490075246e-1",
         "-6.63175408268187738636594884921931867786416057472876635147295424128144233911929585327601381618059327766986981109409782838e-1",
         "-9.46960160806563725719808910991708075372282242401645009270517113290439792088443109178772446465191984149998211903724560065e-1",
         "-7.06828182905581345108929510344440443421290640066613022421187316650733628538705972455891575947230299102119854983197703150e-2",
         "8.92183656127948379886438402777950080111433733329436790239129260607557296960582455582584117031260710927499215646838011844e-1",
         "7.62091330231640362984555508176991632755732840163230620595759320390970951235395195394649584713540498911356433919369698423e-1",
         "-3.01591765120371930643555588643712101466544136366607065361801475091335195383846047491935017919396438040414024941341524187e-1",
         "-9.95813515236177554177387795413035497724212540625760091518605741283184405719984044075159457509720410668598540884613985023e-1",
         "-4.70125959152223022135690700550251564040118601846181392455764893020377582359429013073566263451488554529709131439092909247e-1",
         "6.31483718775865440843182928017874708719203714677143270278178885379757350754752477512514449375355491054871712891789652146e-1",
         "1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
         "3.87481045630097871028201331640164477694000480353342897357083794605539506785023570062767753819472037935010414476627195076e-1",
         "-6.99716878554812023132822640034166338740077082416915046841339368979161296335086955803240899441098534898926193252558848693e-1",
         "-9.29735101124991407032113033015438177585645722877060262785796302722011806301680288369763295777635760805579255008366302180e-1",
         "-2.07925797310208845709174899248298159909010721767168338004516304026594885686024530923209628704670627250569637267490913462e-2",
         "9.13621640053945104047985280883096238900189007462190433514805702721127019097915088259906184736442916334750420359005079959e-1",
         "7.28814716527795995795780587639833705107995825167970668466246348938821997240383021826681253777014938636567626203524137506e-1",
         "-3.48817863192357573536083313907744269588018702862402502601699983054718835012048372083235768555953613790431700360695537918e-1",
         "-9.99135337256258278958854200595331742602280601557283993231562055717063052179292021052372510863057206152466386086657442382e-1",
         "-4.25474147219713305654097901385832164424798803616095278869643928816776198489330071073326518019520590535564717523756486665e-1",
         "6.69409002349720857726983952566596052122726437391092096671257338244059819036586172017092390651026654050631669646310910927e-1",
         "9.44240747589054266930136705015787520728797286842746645573763175559132491628984502333043316023599487896169049499868916865e-1",
         "6.23417820549832676844933182722733277887833220127638406914080428946880981800946578131712749910941183940944526141109771339e-2",
         "-8.95928229794837090592434136137683839101829890460754766346170956577979909285084363961363023377587044303560652568203578379e-1",
         "-7.56652196635835430995109388017590459596111729342964992503572530290981857981790620732129221157071082788019187787999930361e-1",
         "3.09551461133309219674309651201007026752336319933918953736299690287371505733386433918863300129026763968979930342098019300e-1",
         "9.96542844308353945757715814452637400116215448012622700698887257177706625278927018059066920597035660000571997275705962011e-1",
         "4.62731465522276407764000677957978862104808823938378826581864482071733508960062598574638347814740748458034065235894523010e-1",
         "-6.37943500095315456672541800050589670140910744260281868746767523730582697622604545933849801882909439609368258115114388202e-1",
         "-9.57113494461990955768932962010819183910065445494138937651443249061391692258872250121438832853873660881630205561168895590e-1",
         "-1.03783175146302830356973378710923690121182237844646430783773333188328606275124873219756415071202025673009660963930966273e-1",
         "8.76685468012988943166112725030293740012198666616661362437433807594683780986916439696374569274720383546275206733493672834e-1",
         "7.83181178815072182812568575402104911406191663934571600092749188502783771503475038116599065276589122015600004250624262132e-1",
         "-2.69749743842835294071354429049113807280228918034124159074991560056663623624511602063409428877143567459307323934051784210e-1",
         "-9.92227004420417932443416371636723983768124774541445787394585828303853075015733744933294181104002649816119116502663362907e-1",
         "-4.99188570507651271652464431008309802023236218596632956064119419694573621896525872847587264755853127438644874992889777436e-1",
         "6.05374785886620830935500306718810628353011877048386199574451402773468315797082901705593423724389976967865835641164117478e-1",
         "9.68331080574540181354402420018944004334504868848934676984951546671476956051983469715128604348963016773169794077158289730e-1",
         "1.45045093347669933436797325432376656017480150281100519869038554695618054318368975927557872948037203212941966706926758604e-1",
         "-8.55926631706799584065153976496431313099942493164544290051315786450857575707615522517293656706329757352795226750189755758e-1",
         "-8.08355785820466703104647317116964786017731181599256098405978700298563758509572188640629418770593008092680980412866065299e-1",
         "2.29481541445091823694157468006983283649885473964756916206813927875661041834620526229807744443043682778028709792615798955e-1",
         "9.86195281084368344446227722442335005500018635181693920385626820970119467136148305491035657795704047666385553672680209923e-1",
         "5.34782415974986828906369231191245075731384342252264783019973387059318216570499447505623911253042567598873910043381675873e-1",
         "-5.71759181631212640256161075896307515511612057247572886814941945052483422285718810088660759708176904381865453799197101481e-1",
         "-9.77874107069129472007009478090869879295520839405452365411822873037906082086100232576241983901051327761231156641104065497e-1",
         "-1.86056181372276495846711248156316208757691570931906856005697361080864028851991674077024223201008430626166447144444086146e-1",
         "8.33687619660983803179149188531271900120055171980951416163724579833511897001564116810390933587615557717585362295882429826e-1",
         "8.32132482562487183916482822112362004641509381783438374175226355792137053285527706239574867923387554339582561002247202518e-1",
         "-1.88816490768820368180947188938258919466912959009058295775702554895970560887437777994365295452696990115940651570073217522e-1",
         "-9.78458105113103660973458641126689066610890753079836635611789969774219913050456840122278188955139015473252491612410972950e-1",
         "-5.69451448580118869157805059117807250106203230622762838051154208713065707949727035884250775206017528612930773233017928006e-1",
         "5.37154819650306918873973169624898539483418364490295996462663218848771864764982600193558748568095521886456306061269765631e-1",
         "9.85726070946814004698231423834505649751779161578718404221294527194525251740198034173542003704080544827976936213857653517e-1",
         "2.26745517700332138489400566746499809209783385009289423848083137846668382711005704387134606000570923556980021574851618566e-1",
//.........这里部分代码省略.........
开发者ID:cpascal,项目名称:af-cpp,代码行数:101,代码来源:test_cos.cpp

示例7: assert

  BlockType NoPreviewBlockChooser::GetNext
	  (const Well *well, const Queue &q)
  {

	    assert(q.empty());
		
		boost::array<long,7> finalScores;
    

		for(int t=0;t<7;++t)
		{

			BestScoreVisitor v;


			Searcher searcher
				(BlockType(t),
				 well,
				 BlockPosition(),
				 &v
				);


			finalScores[t] = v.GetScore();
    
		}



    
		//perturbes scores to randomize tie handling
    
		
		BOOST_FOREACH
			(long &i, finalScores)
				i+=(rand()%100);

    
		//sorts
    
		boost::array<long,7> temp(finalScores);

    
		sort(temp.begin(),temp.end());


    
		//returns the pos-th block, where pos is random
    
		static const boost::array<int,7> blockPercentages = 
		{

			{
				80,
				92,
				98,
				100,
				100,
				100,
				100
			}
		
		};
    
			
			
		int pos = find_if
			(
			
				blockPercentages.begin(),
			
				blockPercentages.end(),
			
				bind2nd( greater_equal<int>(), rand()%100 )
				
			)
			- blockPercentages.begin();
   
		
		
		assert(pos>=0 && pos<7);

    
		int chosenBlock = find
			(
			
				finalScores.begin(),
			
				finalScores.end(),
			
				temp[pos]
			
			) - finalScores.begin();



    return BlockType(chosenBlock);

  }
开发者ID:stavrossk,项目名称:BasTet,代码行数:99,代码来源:BastetBlockChooser.cpp

示例8: BOOST_FOREACH

  BlockType BastetBlockChooser::GetNext
	  (const Well *well, const Queue &q)
  {

		boost::array<long,7> mainScores = ComputeMainScores
			(well,q.front());
    
		boost::array<long,7> finalScores=mainScores;

    
		//perturbes scores to randomize tie handling
    
		BOOST_FOREACH(long &i, finalScores)
			i+=(rand()%100);


		//prints the final scores, for debugging convenience
    
		for(int i=0;i<7;++i)
		{

			//mvprintw(i,1,"%c: %d",GetChar(BlockType(i)),finalScores[i]);
    
		}


		
		
		//the mainScores alone would give rise to many repeated blocks (e.g., in the case in which only one type of block does not let you clear a line, you keep getting that). This is bad, since it would break the "plausibility" of the sequence you get. We need a correction.
    
		boost::array<long,7> temp(finalScores);
    
		sort(temp.begin(),temp.end());

    
		//always returns the worst block if it's different from the last one
    
		int worstblock=find
			(

				finalScores.begin(),
			
				finalScores.end(),
			
				temp[0]
		
			)
			-finalScores.begin();
    
		
		
		
			if(BlockType(worstblock) != q.front()) 
				return BlockType(worstblock);
    


    
			//otherwise, returns the pos-th block, where pos is random
    
			static const boost::array<int,7> blockPercentages = 
			{
				{80, 92, 98, 100, 100, 100, 100}
			};
    
			
			int pos=find_if
				(
					blockPercentages.begin(),
					blockPercentages.end(),
					bind2nd(greater_equal<int>(),rand()%100)
				)
				- blockPercentages.begin();
    
			assert(pos>=0 && pos<7);


    
			int chosenBlock=find
				(

					finalScores.begin(),
					finalScores.end(),
					temp[pos]
				
				)
				-finalScores.begin();
    

			return BlockType(chosenBlock);
    
   
			//return BlockType(min_element(finalScores.begin(),finalScores.end())-finalScores.begin());
    
			//return BlockType(rand()%7);
  
  }
开发者ID:stavrossk,项目名称:BasTet,代码行数:97,代码来源:BastetBlockChooser.cpp

示例9: evaluate_rational

inline V evaluate_rational(const boost::array<T,N>& a, const boost::array<U,N>& b, const V& z)
{
   return detail::evaluate_rational_c_imp(a.data(), b.data(), z, static_cast<mpl::int_<N>*>(0));
}
开发者ID:3DJ,项目名称:ofxOgre,代码行数:4,代码来源:rational.hpp

示例10: showClassQuestionDialog

    void CharacterCreation::showClassQuestionDialog()
    {
        if (mGenerateClassStep == 10)
        {
            static boost::array<ClassPoint, 23> classes = { {
                {"Acrobat",     {6, 2, 2}},
                {"Agent",       {6, 1, 3}},
                {"Archer",      {3, 5, 2}},
                {"Archer",      {5, 5, 0}},
                {"Assassin",    {6, 3, 1}},
                {"Barbarian",   {3, 6, 1}},
                {"Bard",        {3, 3, 3}},
                {"Battlemage",  {1, 3, 6}},
                {"Crusader",    {1, 6, 3}},
                {"Healer",      {3, 1, 6}},
                {"Knight",      {2, 6, 2}},
                {"Monk",        {5, 3, 2}},
                {"Nightblade",  {4, 2, 4}},
                {"Pilgrim",     {5, 2, 3}},
                {"Rogue",       {3, 4, 3}},
                {"Rogue",       {4, 4, 2}},
                {"Rogue",       {5, 4, 1}},
                {"Scout",       {2, 5, 3}},
                {"Sorcerer",    {2, 2, 6}},
                {"Spellsword",  {2, 4, 4}},
                {"Spellsword",  {5, 1, 4}},
                {"Witchhunter", {2, 3, 5}},
                {"Witchhunter", {5, 0, 5}}
            } };

            int match = -1;
            for (unsigned i = 0; i < classes.size(); ++i)
            {
                if (mGenerateClassSpecializations[0] == classes[i].points[0] &&
                    mGenerateClassSpecializations[1] == classes[i].points[1] &&
                    mGenerateClassSpecializations[2] == classes[i].points[2])
                {
                    match = i;
                    mGenerateClass = classes[i].id;
                    break;
                }
            }

            if (match == -1)
            {
                if (mGenerateClassSpecializations[0] >= 7)
                    mGenerateClass = "Thief";
                else if (mGenerateClassSpecializations[1] >= 7)
                    mGenerateClass = "Warrior";
                else if (mGenerateClassSpecializations[2] >= 7)
                    mGenerateClass = "Mage";
                else
                {
                    std::cerr << "Failed to deduce class from chosen answers in generate class dialog" << std::endl;
                    mGenerateClass = "Thief";
                }
            }

            MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassResultDialog);
            mGenerateClassResultDialog = 0;

            mGenerateClassResultDialog = new GenerateClassResultDialog();
            mGenerateClassResultDialog->setClassId(mGenerateClass);
            mGenerateClassResultDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassBack);
            mGenerateClassResultDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onGenerateClassDone);
            mGenerateClassResultDialog->setVisible(true);
            return;
        }

        if (mGenerateClassStep > 10)
        {
            MWBase::Environment::get().getWindowManager()->popGuiMode();
            MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class);
            return;
        }

        MWBase::Environment::get().getWindowManager()->removeDialog(mGenerateClassQuestionDialog);
        mGenerateClassQuestionDialog = 0;

        mGenerateClassQuestionDialog = new InfoBoxDialog();

        InfoBoxDialog::ButtonList buttons;
        mGenerateClassQuestionDialog->setText(sGenerateClassSteps(mGenerateClassStep).mText);
        buttons.push_back(sGenerateClassSteps(mGenerateClassStep).mButtons[0]);
        buttons.push_back(sGenerateClassSteps(mGenerateClassStep).mButtons[1]);
        buttons.push_back(sGenerateClassSteps(mGenerateClassStep).mButtons[2]);
        mGenerateClassQuestionDialog->setButtons(buttons);
        mGenerateClassQuestionDialog->eventButtonSelected += MyGUI::newDelegate(this, &CharacterCreation::onClassQuestionChosen);
        mGenerateClassQuestionDialog->setVisible(true);

        MWBase::Environment::get().getSoundManager()->say(sGenerateClassSteps(mGenerateClassStep).mSound);
    }
开发者ID:ace13,项目名称:openmw,代码行数:92,代码来源:charactercreation.cpp

示例11: filter

/** @brief make the band pass filter mask in Fourier space
    \param radiiMin Real space mimimum radiii in each dimension, supposed in row major order
    \param radiiMax Real space maximum radiii in each dimension, supposed in row major order
*/
void Tracker::makeBandPassMask(const boost::array<double,3> &radiiMin, const boost::array<double,3> &radiiMax)
{
    if(!quiet)
    {
    	cout << "making the band-pass filter (";
		copy(FFTmask.shape(),FFTmask.shape()+FFTmask.num_dimensions(),ostream_iterator<size_t>(cout,","));
		cout<<") ... ";
    }

    if(!equal(radiiMin.begin(),radiiMin.end(),radiiMax.begin(),less<double>()))
		throw invalid_argument("For each dimension we must have radiusMin < radiusMax ");

    boost::array<double,3> freqMax, freqMin;
    transform(centersMap.shape(),centersMap.shape()+centersMap.num_dimensions(),radiiMin.begin(), freqMax.begin(), divides<double>());
    transform(centersMap.shape(),centersMap.shape()+centersMap.num_dimensions(),radiiMax.begin(), freqMin.begin(), divides<double>());
    transform(freqMax.begin(), freqMax.end(), freqMax.begin(), bind2nd(divides<double>(), 2.0));
    transform(freqMin.begin(), freqMin.end(), freqMin.begin(), bind2nd(divides<double>(), 2.0));
    if(!quiet)
    {
        cout << "Size min (";
		copy(radiiMin.begin(),radiiMin.end(),ostream_iterator<double>(cout,","));
		cout<<") ... ";
		cout << "Size max (";
		copy(radiiMax.begin(),radiiMax.end(),ostream_iterator<double>(cout,","));
		cout<<") ... ";
    	cout << "Freq max (";
		copy(freqMax.begin(),freqMax.end(),ostream_iterator<double>(cout,","));
		cout<<") ... ";
		cout << "Freq min (";
		copy(freqMin.begin(),freqMin.end(),ostream_iterator<double>(cout,","));
		cout<<") ... ";
    }

    //The spectrum output of FFT is centered on (0,0,0), not in the center of the image.
    //The last dimension is only (n/2+1), with n the last dimension of the real-space image
    //So the band pass mask is half on a 3D-ellipsoidal shell centered on (0,0,0).
    //Moreover, the symetry planes allow to draw only 1/2^d th of the mask and then mirror it.

    //get a view of 1/2^d th of the mask

    boost::array<size_t,3> halfdims;
    for(int d=0;d<3;++d)
		halfdims[d] = centersMap.shape()[d] / 2 + 1;
    array_type_b::array_view<3>::type portion = FFTmask[
		boost::indices[range(0,halfdims[0])][range(0,halfdims[1])][range(0,halfdims[2])]
		];
	if(!quiet)
    {
    	cout<<"portion (";
		copy(portion.shape(),portion.shape()+portion.num_dimensions(),ostream_iterator<size_t>(cout,","));
		cout<<") ... ";
    }
    //boost::multi_array_ref<bool, 3>portion(data, halfdims);
    double imin, imax, jmin, jmax;
    size_t di=0,dj=0;
    //array_type_b::array_view<3>::type::array_view<1>::type line;

	//draw a 1/2^d th of the mask
	//not the best efficiency if z is flat, but then the number of pixels is small so no problem
	for(array_type_b::iterator i = portion.begin();i!=portion.end();++i)
	{
		dj=0;
		imin = pow(di / freqMin[0], 2.0);
		imax = pow(di / freqMax[0], 2.0);
		for(array_type_b::value_type::iterator j = i->begin();j!=i->end();++j)
		{
		    //cout<<(j-i->begin())<<endl;
		    jmin = pow(dj / freqMin[1], 2.0);
		    jmax = pow(dj / freqMax[1], 2.0);
			size_t kmin = min(
				j->size(),
				(imin+jmin>1.0)?0:
				(size_t)(1+freqMin[2]*sqrt(1.0 - imin - jmin))
				);
			size_t kmax = min(
				j->size(),
				(imax+jmax>1.0)?kmin:
				(size_t)(1+freqMax[2]*sqrt(1.0 - imax - jmax))
				);
			//cout<<imin<<","<<imax<<","<<jmin<<","<<jmax<<","<<kmin<<","<<kmax;//<<endl;
			//cout<<" 0->"<<kmin;
			fill_n(j->begin(), kmin, false);
			//cout<<"->"<<kmax;
			fill(j->begin() + kmin, j->begin() + kmax, true);
			//cout<<"->"<<j->size()<<endl;
			fill(j->begin() + kmax, j->end(), false);
			dj++;
		}
		di++;
	}

	this->mirrorMask();

	if(view) displayMask();
}
开发者ID:MathieuLeocmach,项目名称:colloids,代码行数:99,代码来源:tracker.cpp

示例12: SFb

double BTagWeight::getBScaleFactor(const Jet& jet, std::string MCSampleTag, double uncertaintyFactor) const {
	double SFb(0);
	double sf_error(0);
	//these numbers are for CSVM only
	double pt = getSmearedJetPtScale(jet, 0)*jet.pt();
	double eta = jet.eta();

	if (MCSampleTag == "Summer12") { // 2012 btag scale factors
		// From https://twiki.cern.ch/twiki/pub/CMS/BtagPOG/SFb-pt_WITHttbar_payload_EPS13.txt,
		// which is linked from https://twiki.cern.ch/twiki/bin/viewauth/CMS/BtagPOG#2012_Data_and_MC_EPS13_prescript
		const boost::array<double, 16> SFb_error = { { 0.0415707,
				0.0204209,
				0.0223227,
				0.0206655,
				0.0199325,
				0.0174121,
				0.0202332,
				0.0182446,
				0.0159777,
				0.0218531,
				0.0204688,
				0.0265191,
				0.0313175,
				0.0415417,
				0.0740446,
				0.0596716 } };

		//2012 pt bins low edges
		const boost::array<double, 16> ptbins = { { 20, 30, 40, 50, 60, 70, 80, 100, 120, 160, 210, 260, 320, 400, 500, 600 } };

		if (pt < 20) {
			SFb = (0.938887 + (0.00017124 * 20)) + (-2.76366e-07 * (20 * 20));
			//use twice the uncertainty
			sf_error = 2 * SFb_error[0];

		} else if (pt > 800) {
			SFb = (0.938887 + (0.00017124 * 800)) + (-2.76366e-07 * (800 * 800));
			//use twice the uncertainty
			sf_error = 2 * SFb_error[SFb_error.size() - 1];

		} else {
			SFb = (0.938887 + (0.00017124 * pt)) + (-2.76366e-07 * (pt * pt));
			unsigned int ptbin(0);
			for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) {
				double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 800.;
				double lowerCut = ptbins.at(bin);

				if (pt > lowerCut && pt <= upperCut) {
					ptbin = bin;
					break;
				}
			}
			sf_error = SFb_error.at(ptbin);

			//use twice the uncertainty if outside the 0 to 2.4 eta range
			if (2.4 < eta && eta <= 2.6) {
				sf_error = 2 * SFb_error.at(ptbin);
			}
		}
	} else if (MCSampleTag == "Summer11Leg") { // 2011 btag scale factors
		// https://twiki.cern.ch/twiki/pub/CMS/BtagPOG/SFb-mujet_payload.txt
		const boost::array<double, 14> SFb_error = { { 0.0295675,
				0.0295095,
				0.0210867,
				0.0219349,
				0.0227033,
				0.0204062,
				0.0185857,
				0.0256242,
				0.0383341,
				0.0409675,
				0.0420284,
				0.0541299,
				0.0578761,
				0.0655432 } };

		//2011 pt bins low edges
		const boost::array<double, 14> ptbins = { { 30, 40, 50, 60, 70, 80, 100, 120, 160, 210, 260, 320, 400, 500 } };

		if (pt < 30) {
			SFb = 0.6981 * ((1. + (0.414063 * pt)) / (1. + (0.300155 * 30)));
			//absolute uncertainty of +/-0.12
			sf_error = 0.12;

		} else if (pt > 670) {
			SFb = 0.6981 * ((1. + (0.414063 * 670)) / (1. + (0.300155 * 670)));
			//use twice the uncertainty
			sf_error = 2 * SFb_error[SFb_error.size() - 1];

		} else {
			SFb = 0.6981 * ((1. + (0.414063 * pt)) / (1. + (0.300155 * pt)));

			unsigned int ptbin(0);
			for (unsigned int bin = 0; bin < ptbins.size() + 1; ++bin) {
				double upperCut = bin + 1 < ptbins.size() ? ptbins.at(bin + 1) : 670.;
				double lowerCut = ptbins.at(bin);

				if (pt > lowerCut && pt <= upperCut) {
					ptbin = bin;
					break;
//.........这里部分代码省略.........
开发者ID:isildakbora,项目名称:NTupleProduction,代码行数:101,代码来源:BTagWeight.cpp

示例13: toBools

Bools toBools( boost::array<bool,nb> const & t ) 
{
  Bools b;
  b.insert (b.end(), t.begin(), t.end());
  return b;
}
开发者ID:12345ieee,项目名称:cmg-cmssw,代码行数:6,代码来源:EventSelOverlap_t.cpp

示例14: mini

 mini(FILE *bin)
     : enemy(0, bin, MASS, RADIUS, SPRING, DAMP, ACCEL, RESPONSIVENESS),
       color(colors[rand() % colors.size()]) { }
开发者ID:jckarter,项目名称:BattleMints,代码行数:3,代码来源:dramatis_personae.hpp

示例15:

 virtual vec4 sphere_color(float)
     { return colors[board::current()->tick_count() % colors.size()]; }
开发者ID:jckarter,项目名称:BattleMints,代码行数:2,代码来源:dramatis_personae.hpp


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