本文整理汇总了C++中c1函数的典型用法代码示例。如果您正苦于以下问题:C++ c1函数的具体用法?C++ c1怎么用?C++ c1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了c1函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: getGoalPercept
void GoalDetector::execute()
{
getGoalPercept().reset();
//if there is no field percept, then, there is also no goal ?!
/*
if(!theFieldPercept.isValid())
{
return;
}
*/
// estimate the horizon
Vector2<double> p1(getArtificialHorizon().begin());
Vector2<double> p2(getArtificialHorizon().end());
int heightOfHorizon = (int)((p1.y + p2.y) * 0.5 + 0.5);
// image over the horizon
if(heightOfHorizon > (int)getImage().cameraInfo.resolutionHeight-10) return;
// clamp the scanline
p1.y = Math::clamp((int)p1.y, 10, (int)getImage().cameraInfo.resolutionHeight-10);
p2.y = Math::clamp((int)p2.y, 10, (int)getImage().cameraInfo.resolutionHeight-10);
// calculate the post candidates along of the horizon
Candidate candidates[maxNumberOfCandidates];
int numberOfCandidates = scanForCandidates(p1, p2, candidates);
// fallback: try to scan along the center of the image
if(numberOfCandidates == 0)
{
Vector2<double> c1(0,getImage().cameraInfo.getOpticalCenterY());
Vector2<double> c2(getImage().cameraInfo.resolutionWidth-1,getImage().cameraInfo.getOpticalCenterY());
numberOfCandidates = scanForCandidates(c1, c2, candidates);
}//end if
// try once again...
if(numberOfCandidates == 0)
{
Vector2<double> c1(0,getImage().cameraInfo.resolutionHeight/3);
Vector2<double> c2(getImage().cameraInfo.resolutionWidth-1,getImage().cameraInfo.resolutionHeight/3);
numberOfCandidates = scanForCandidates(c1, c2, candidates);
}//end if
// estimate the post base points
vector<GoalPercept::GoalPost> postvector;
estimatePostsByScanlines(candidates, numberOfCandidates, postvector);
//estimatePostsByBlobs(candidates, numberOfCandidates, postvector);
if(postvector.empty()) return;
// sort the posts by height in the image
// the first is the biggest
GoalPercept::GoalPost post; // only for comparison
sort(postvector.begin(), postvector.end(), post);
// minimal height (in px) of an accepted goal post
int minimalHeightOfAGoalPost = 20;
int numberOfPostsFound = 0;
// we are searching for two goal posts
GoalPercept::GoalPost postOne;
GoalPercept::GoalPost postTwo;
int distToBottomImage = getImage().cameraInfo.resolutionHeight - max(postOne.basePoint.y, postTwo.basePoint.y) - 1;
// look max 5 pixel down
Vector2<int> extraBase(0, min(distToBottomImage,5));
// if the longest post is to short
if(postvector.begin()->seenHeight < minimalHeightOfAGoalPost)
{
return;
}
// index of the first found post
unsigned int idxFirst = 0;
// search for the first goal post candidate
for(idxFirst = 0; idxFirst < postvector.size(); idxFirst++)
{
if(postvector[idxFirst].seenHeight >= minimalHeightOfAGoalPost)
// consider the field percept ONLY if it is valid
//&& theFieldPercept.getLargestValidPoly(getCameraMatrix().horizon).isInside(postvector[idxFirst].basePoint + extraBase))
{
numberOfPostsFound = 1;
break;
}
}//end for
// if a post were found search for the second one
if(numberOfPostsFound > 0)
{
// at least one post was seen
postOne = postvector[idxFirst];
//.........这里部分代码省略.........
开发者ID:IntelligentRoboticsLab,项目名称:DNT2013,代码行数:101,代码来源:GoalDetector.cpp
示例2: tc_libcxx_containers_unord_map_swap_member
int tc_libcxx_containers_unord_map_swap_member(void)
{
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
C c1(0, Hash(1), Compare(1), Alloc(1, 1));
C c2(0, Hash(2), Compare(2), Alloc(1, 2));
c2.max_load_factor(2);
c1.swap(c2);
LIBCPP_ASSERT(c1.bucket_count() == 0);
TC_ASSERT_EXPR(c1.size() == 0);
TC_ASSERT_EXPR(c1.hash_function() == Hash(2));
TC_ASSERT_EXPR(c1.key_eq() == Compare(2));
TC_ASSERT_EXPR(c1.get_allocator().get_id() == 1);
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
TC_ASSERT_EXPR(c1.max_load_factor() == 2);
LIBCPP_ASSERT(c2.bucket_count() == 0);
TC_ASSERT_EXPR(c2.size() == 0);
TC_ASSERT_EXPR(c2.hash_function() == Hash(1));
TC_ASSERT_EXPR(c2.key_eq() == Compare(1));
TC_ASSERT_EXPR(c2.get_allocator().get_id() == 2);
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
TC_ASSERT_EXPR(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a2[] =
{
P(10, "ten"),
P(20, "twenty"),
P(30, "thirty"),
P(40, "forty"),
P(50, "fifty"),
P(60, "sixty"),
P(70, "seventy"),
P(80, "eighty"),
};
C c1(0, Hash(1), Compare(1), Alloc(1, 1));
C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(1, 2));
c2.max_load_factor(2);
c1.swap(c2);
TC_ASSERT_EXPR(c1.bucket_count() >= 8);
TC_ASSERT_EXPR(c1.size() == 8);
TC_ASSERT_EXPR(c1.at(10) == "ten");
TC_ASSERT_EXPR(c1.at(20) == "twenty");
TC_ASSERT_EXPR(c1.at(30) == "thirty");
TC_ASSERT_EXPR(c1.at(40) == "forty");
TC_ASSERT_EXPR(c1.at(50) == "fifty");
TC_ASSERT_EXPR(c1.at(60) == "sixty");
TC_ASSERT_EXPR(c1.at(70) == "seventy");
TC_ASSERT_EXPR(c1.at(80) == "eighty");
TC_ASSERT_EXPR(c1.hash_function() == Hash(2));
TC_ASSERT_EXPR(c1.key_eq() == Compare(2));
TC_ASSERT_EXPR(c1.get_allocator().get_id() == 1);
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(c1.begin(), c1.end())) == c1.size());
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(c1.cbegin(), c1.cend())) == c1.size());
TC_ASSERT_EXPR(c1.max_load_factor() == 2);
LIBCPP_ASSERT(c2.bucket_count() == 0);
TC_ASSERT_EXPR(c2.size() == 0);
TC_ASSERT_EXPR(c2.hash_function() == Hash(1));
TC_ASSERT_EXPR(c2.key_eq() == Compare(1));
TC_ASSERT_EXPR(c2.get_allocator().get_id() == 2);
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(c2.begin(), c2.end())) == c2.size());
TC_ASSERT_EXPR(static_cast<std::size_t>(std::distance(c2.cbegin(), c2.cend())) == c2.size());
TC_ASSERT_EXPR(c2.max_load_factor() == 1);
}
{
typedef test_hash<std::hash<int> > Hash;
typedef test_compare<std::equal_to<int> > Compare;
typedef test_allocator<std::pair<const int, std::string> > Alloc;
typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
typedef std::pair<int, std::string> P;
P a1[] =
{
P(1, "one"),
P(2, "two"),
P(3, "three"),
P(4, "four"),
P(1, "four"),
P(2, "four"),
};
C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1, 1));
C c2(0, Hash(2), Compare(2), Alloc(1, 2));
c2.max_load_factor(2);
c1.swap(c2);
LIBCPP_ASSERT(c1.bucket_count() == 0);
TC_ASSERT_EXPR(c1.size() == 0);
//.........这里部分代码省略.........
开发者ID:drashti304,项目名称:TizenRT,代码行数:101,代码来源:swap_member.pass.cpp
示例3: main
int main(int argc, char *argv[])
{
Pooma::initialize(argc, argv);
Pooma::Tester tester(argc, argv);
Interval<1> n1(1,5);
Interval<1> n2(4,8);
Interval<1> n3(10,20);
Interval<2> a(n1,n2);
Interval<3> b(n1,n2,n3);
Range<1> r1(1,5);
Range<1> r2(4,8,2);
Range<1> r3(5,9,2);
Range<1> r4(10,20,5);
Range<2> ra(r1,r2);
Range<2> rb(r1,r3);
Range<3> rc(r1,r2,r3);
tester.out() << "1: touches(" << a[0] << "," << a[1] << ") ? ";
tester.out() << touches(a[0], a[1]) << std::endl;
tester.check( touches(a[0], a[1]) );
tester.out() << "0: touches(" << a[0] << "," << b[2] << ") ? ";
tester.out() << touches(a[0], b[2]) << std::endl;
tester.check( touches(a[0], b[2])==0);
tester.out() << "1: touches(" << a[0] << "," << ra[0] << ") ? ";
tester.out() << touches(a[0], ra[0]) << std::endl;
tester.check(touches(a[0], ra[0]));
tester.out() << "1: touches(" << ra[0] << "," << ra[1] << ") ? ";
tester.out() << touches(ra[0], ra[1]) << std::endl;
tester.check( touches(ra[0], ra[1]));
tester.out() << "0: touches(" << r2 << "," << r3 << ") ? ";
tester.out() << touches(r2, r3) << std::endl;
tester.check( touches(r2, r3)==0);
tester.out() << "0: touches(" << ra << "," << rb << ") ? ";
tester.out() << touches(ra, rb) << std::endl;
tester.check( touches(ra, rb) ==0);
tester.out() << "1: touches(" << rc << "," << rc << ") ? ";
tester.out() << touches(rc, rc) << std::endl;
tester.check( touches(rc, rc) );
tester.out() << "------------------------------------" << std::endl;
tester.check(" touches ", true);
Interval<1> c1(1,10);
Interval<1> c2(3,8);
Interval<1> c3(5,15);
Interval<2> ca(c1, c1);
Interval<2> cb(c1, c2);
Range<1> cr1(2,20,2);
Range<1> cr2(4,16,4);
Range<1> cr3(3,15,2);
Range<1> cr4(5,15,5);
tester.out() << "1: contains(" << c1 << "," << c2 << ") ? ";
tester.out() << contains(c1,c2) << std::endl;
tester.check(contains(c1,c2));
tester.out() << "0: contains(" << c2 << "," << c1 << ") ? ";
tester.out() << contains(c2,c1) << std::endl;
tester.check(contains(c2,c1)==0);
tester.out() << "0: contains(" << c1 << "," << c3 << ") ? ";
tester.out() << contains(c1,c3) << std::endl;
tester.check(contains(c1,c3)==0);
tester.out() << "1: contains(" << ca << "," << cb << ") ? ";
tester.out() << contains(ca,cb) << std::endl;
tester.check(contains(ca,cb));
tester.out() << "0: contains(" << cb << "," << ca << ") ? ";
tester.out() << contains(cb,ca) << std::endl;
tester.check(contains(cb,ca)==0);
tester.out() << "1: contains(" << cr1 << "," << cr2 << ") ? ";
tester.out() << contains(cr1,cr2) << std::endl;
tester.check( contains(cr1,cr2));
tester.out() << "0: contains(" << cr1 << "," << cr3 << ") ? ";
tester.out() << contains(cr1,cr3) << std::endl;
tester.check(contains(cr1,cr3)==0);
tester.out() << "1: contains(" << c3 << "," << cr4 << ") ? ";
tester.out() << contains(c3,cr4) << std::endl;
tester.check(contains(c3,cr4));
tester.out() << "0: contains(" << cr4 << "," << c3 << ") ? ";
tester.out() << contains(cr4,c3) << std::endl;
tester.check(contains(cr4,c3)==0);
tester.out() << "------------------------------------" << std::endl;
Interval<2> s1, s2;
Range<2> sr1, sr2;
split(cb, s1, s2);
tester.out() << "split(" << cb << ") = " << s1 << " and " << s2 << std::endl;
tester.check(s1==Interval<2>(Interval<1>(1,5),Interval<1>(3,5)));
tester.check(s2==Interval<2>(Interval<1>(6,10),Interval<1>(6,8)));
split(rb, sr1, sr2);
tester.out() << "split(" << rb << ") = " << sr1 << " and " << sr2 << std::endl;
tester.check(sr1==Range<2>(Range<1>(1,2),Range<1>(5,5,2)));
tester.check(sr2==Range<2>(Range<1>(3,5),Range<1>(7,9,2)));
tester.out() << "------------------------------------" << std::endl;
//.........这里部分代码省略.........
开发者ID:pathscale,项目名称:freepooma-testsuite,代码行数:101,代码来源:domaincalc.C
示例4: main
int main()
{
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef test_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A(5));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(5));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(A(5));
c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == A(5));
}
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef test_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A(5));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(5));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(A(6));
c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() != 0);
assert(c3.get_allocator() == A(6));
}
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef other_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A(5));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(5));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(A(6));
c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == A(5));
}
{
int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
int* an = ab + sizeof(ab)/sizeof(ab[0]);
typedef min_allocator<MoveOnly> A;
std::deque<MoveOnly, A> c1(A{});
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A{});
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(A{});
c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == A());
}
}
开发者ID:CaseyCarter,项目名称:libcxx,代码行数:67,代码来源:move_assign.pass.cpp
示例5: six
void VariableTestFixture::testSimpleExpression() {
Datum six(M_INTEGER, 6);
ConstantVariable c1(six);
Datum five(M_INTEGER, 5);
ConstantVariable c2(five);
// boolean expressions
shared_ptr<ExpressionVariable> e;
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_EQUAL));
CPPUNIT_ASSERT(!e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c2, M_IS_EQUAL));
CPPUNIT_ASSERT(e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_NOT_EQUAL));
CPPUNIT_ASSERT(e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_NOT_EQUAL));
CPPUNIT_ASSERT(!e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_GREATER_THAN));
CPPUNIT_ASSERT(e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_GREATER_THAN));
CPPUNIT_ASSERT(!e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_GREATER_THAN));
CPPUNIT_ASSERT(!e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_GREATER_THAN_OR_EQUAL));
CPPUNIT_ASSERT(e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_GREATER_THAN_OR_EQUAL));
CPPUNIT_ASSERT(!e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_GREATER_THAN_OR_EQUAL));
CPPUNIT_ASSERT(e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_LESS_THAN));
CPPUNIT_ASSERT(!e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_LESS_THAN));
CPPUNIT_ASSERT(e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_LESS_THAN));
CPPUNIT_ASSERT(!e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_IS_LESS_THAN_OR_EQUAL));
CPPUNIT_ASSERT(!e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c2, &c1, M_IS_LESS_THAN_OR_EQUAL));
CPPUNIT_ASSERT(e->getValue().getBool());
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c1, M_IS_LESS_THAN_OR_EQUAL));
CPPUNIT_ASSERT(e->getValue().getBool());
// arithmatic expressions
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_PLUS));
CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six + five));
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_MINUS));
CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six - five));
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_TIMES));
CPPUNIT_ASSERT(e->getValue().getFloat() == (float)(six * five));
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_DIVIDE));
CPPUNIT_ASSERT(e->getValue().getFloat() == (double)(six / five));
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_MOD));
CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six % five));
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_INCREMENT));
CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six + Datum(M_FLOAT,1)));
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, &c2, M_DECREMENT));
CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six - Datum(M_FLOAT,1)));
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, NULL, M_INCREMENT));
CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six + Datum(M_FLOAT,1)));
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c1, NULL, M_DECREMENT));
CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(six - Datum(M_FLOAT,1)));
Datum seven(M_INTEGER, 0x7);
ConstantVariable c3(seven);
Datum eight(M_INTEGER, 0x8);
ConstantVariable c4(eight);
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, &c4, M_AND));
CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(seven && eight));
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, &c4, M_OR));
CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(seven || eight));
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, &c4, M_NOT));
CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(!seven));
e = shared_ptr<ExpressionVariable>(new ExpressionVariable(&c3, NULL, M_NOT));
CPPUNIT_ASSERT(e->getValue().getInteger() == (long)(!seven));
//.........这里部分代码省略.........
开发者ID:davidcox,项目名称:mworks,代码行数:101,代码来源:VariableTest.cpp
示例6: main
int main() {
ic::Plot::SetHTTStyle();
std::string dir="/vols/cms04/pjd12/invcmssws/CMSSW_7_1_5/src/HiggsAnalysis/CombinedLimit/exocombcards/";
std::vector<Scan> scans;
// scans.push_back({"higgsCombinefullScan.MultiDimFit.mH125.root", "Observed", 1, nullptr});
// scans.push_back({"higgsCombineexpected.MultiDimFit.mH125.root", "Exp. for SM H", 32, nullptr});
// scans.push_back({"higgsCombinenoBBBScan.MultiDimFit.mH125.root", "no bbb syst.", 38, nullptr});
scans.push_back({dir+"higgsCombineCombExp.MultiDimFit.mH125.root", "Exp. for SM H", 1, nullptr});
scans.push_back({dir+"higgsCombineCombObs.MultiDimFit.mH125.root", "Obs. for SM H", 1, nullptr});
TCanvas c1("canvas","canvas");
std::vector<TLine *> lines;
TLegend *leg = new TLegend(0.65,0.75,0.9,0.9,"","brNDC");
unsigned counter = 0;
for (auto & sc : scans) {
TFile f1(sc.file.c_str());
TTree *t1 = dynamic_cast<TTree*>(f1.Get("limit"));
double best1 = 0.0;
TString res;
sc.gr = new TGraph(ExtractGraph(t1, best1));
if(counter==1){
auto x1 = GetCrossings(*(sc.gr), 1.0);
auto x2 = GetCrossings(*(sc.gr), 3.84);
lines.push_back(new TLine(x1[0],0,x1[0],1.0));
lines.back()->SetLineColor(2);
lines.back()->SetLineWidth(2);
lines.push_back(new TLine(x2[0],0,x2[0],3.84));
lines.back()->SetLineColor(2);
lines.back()->SetLineWidth(2);
}
sc.gr->SetLineColor(sc.color);
sc.gr->SetLineWidth(3);
sc.gr->Draw(counter ? "LSAME" : "AL");
TString leg_text = "#splitline{"+sc.label+"}{"+res+"}";
leg->AddEntry(sc.gr, leg_text, "L");
counter++;
}
// c1.cd();
// // g1.Print();
// g1.SetLineColor(1);
// g1.SetLineWidth(2);
// // g1.SetMarkerColor(7);
// g1.Draw("AC");
scans[0].gr->SetMaximum(9);
scans[0].gr->SetMinimum(0.);
scans[0].gr->GetXaxis()->SetRangeUser(0., 0.9);
scans[0].gr->GetXaxis()->SetTitle("BR_{inv}");
scans[0].gr->GetXaxis()->SetTitleOffset(1.1);
scans[0].gr->GetXaxis()->SetNdivisions(1005,true);
scans[0].gr->GetXaxis()->SetLabelSize(0.05);
scans[0].gr->GetYaxis()->SetLabelSize(0.05);
scans[0].gr->GetXaxis()->SetLabelOffset(0.02);
scans[0].gr->GetYaxis()->SetLabelOffset(0.02);
scans[0].gr->GetYaxis()->SetTitle("-2 #Delta ln L");
scans[0].gr->SetLineStyle(2);
scans[0].gr->SetLineColor(1);
leg->SetBorderSize(1);
leg->SetTextFont(42);
leg->SetTextSize(0.03);
leg->SetLineColor(1);
leg->SetLineStyle(1);
leg->SetLineWidth(1);
leg->SetFillColor(0);
leg->SetFillStyle(1001);
leg->Draw();
lines.push_back(new TLine(0.,1,0.9,1.0));
lines.back()->SetLineColor(2);
lines.push_back(new TLine(0.,3.84,0.9,3.84));
lines.back()->SetLineColor(2);
// for (auto l : lines) l->Draw();
DrawCMSLogoTest(&c1,"CMS","preliminary",10);
TLatex lat = TLatex();
lat.SetNDC();
lat.SetTextSize(0.04);
lat.SetTextFont(42);
TLatex lat2 = TLatex();
lat2.SetNDC();
lat2.SetTextSize(0.03);
lat2.SetTextFont(42);
lat.DrawLatex(0.2,0.73,"Combination of all");
lat.DrawLatex(0.2,0.68,"H#rightarrow inv. channels");
c1.Update();
c1.SaveAs("scan.pdf");
return 0;
}
开发者ID:ajgilbert,项目名称:ICHiggsTauTau,代码行数:97,代码来源:Plot1DScan.cpp
示例7: main
int main(int argc, char* argv[]) {
Matrix G;
Matrix Y;
Matrix Cov;
LoadMatrix("input.mt.g", G);
LoadMatrix("input.mt.y", Y);
LoadMatrix("input.mt.cov", Cov);
Cov.SetColumnLabel(0, "c1");
Cov.SetColumnLabel(1, "c2");
Y.SetColumnLabel(0, "y1");
Y.SetColumnLabel(1, "y2");
Y.SetColumnLabel(2, "y3");
FormulaVector tests;
{
const char* tp1[] = {"y1"};
const char* tc1[] = {"c1"};
std::vector<std::string> p1(tp1, tp1 + 1);
std::vector<std::string> c1(tc1, tc1 + 1);
tests.add(p1, c1);
}
{
const char* tp1[] = {"y2"};
const char* tc1[] = {"c2"};
std::vector<std::string> p1(tp1, tp1 + 1);
std::vector<std::string> c1(tc1, tc1 + 1);
tests.add(p1, c1);
}
{
const char* tp1[] = {"y2"};
const char* tc1[] = {"c1", "c2"};
std::vector<std::string> p1(tp1, tp1 + 1);
std::vector<std::string> c1(tc1, tc1 + 2);
tests.add(p1, c1);
}
{
const char* tp1[] = {"y1"};
const char* tc1[] = {"1"};
std::vector<std::string> p1(tp1, tp1 + 1);
std::vector<std::string> c1(tc1, tc1 + 1);
tests.add(p1, c1);
}
AccurateTimer t;
{
FastMultipleTraitLinearRegressionScoreTest mt(1024);
bool ret = mt.FitNullModel(Cov, Y, tests);
if (ret == false) {
printf("Fit null model failed!\n");
exit(1);
}
ret = mt.AddGenotype(G);
if (ret == false) {
printf("Add covariate failed!\n");
exit(1);
}
ret = mt.TestCovariateBlock();
if (ret == false) {
printf("Test covariate block failed!\n");
exit(1);
}
const Vector& u = mt.GetU(0);
printf("u\t");
Print(u);
printf("\n");
const Vector& v = mt.GetV(0);
printf("v\t");
Print(v);
printf("\n");
const Vector& pval = mt.GetPvalue(0);
printf("pval\t");
Print(pval);
printf("\n");
}
return 0;
}
开发者ID:marisacgarre,项目名称:rvtests,代码行数:84,代码来源:testFastMultipleTraitScoreTest.cpp
示例8: p1
void tst_QPixmapCache::insert()
{
QPixmap p1(10, 10);
p1.fill(Qt::red);
QPixmap p2(10, 10);
p2.fill(Qt::yellow);
// Calcuate estimated num of items what fits to cache
int estimatedNum = (1024 * QPixmapCache::cacheLimit())
/ ((p1.width() * p1.height() * p1.depth()) / 8);
// Mare sure we will put enough items to reach the cache limit
const int numberOfKeys = estimatedNum + 1000;
// make sure it doesn't explode
for (int i = 0; i < numberOfKeys; ++i)
QPixmapCache::insert("0", p1);
// ditto
for (int j = 0; j < numberOfKeys; ++j)
QPixmapCache::insert(QString::number(j), p1);
int num = 0;
for (int k = 0; k < numberOfKeys; ++k) {
if (QPixmapCache::find(QString::number(k)))
++num;
}
if (QPixmapCache::find("0"))
++num;
QVERIFY(num <= estimatedNum);
QPixmap p3;
QPixmapCache::insert("null", p3);
QPixmap c1(10, 10);
c1.fill(Qt::yellow);
QPixmapCache::insert("custom", c1);
QVERIFY(!c1.isDetached());
QPixmap c2(10, 10);
c2.fill(Qt::red);
QPixmapCache::insert("custom", c2);
//We have deleted the old pixmap in the cache for the same key
QVERIFY(c1.isDetached());
//The int part of the API
// make sure it doesn't explode
QList<QPixmapCache::Key> keys;
for (int i = 0; i < numberOfKeys; ++i)
keys.append(QPixmapCache::insert(p1));
num = 0;
for (int k = 0; k < numberOfKeys; ++k) {
if (QPixmapCache::find(keys.at(k), &p2))
++num;
}
estimatedNum = (1024 * QPixmapCache::cacheLimit())
/ ((p1.width() * p1.height() * p1.depth()) / 8);
QVERIFY(num <= estimatedNum);
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:62,代码来源:tst_qpixmapcache.cpp
示例9: c
int FacilityLocation::createConsFacilityActivation(int)
{
int numCons = 0;
VariableHash::iterator vit;
Row::ROWSENSE sense = Row::LESS;
int maxnnz = 2;
double rhs = 0.0;
int colVarX, colVarY, colVarZ;
for (vit = vHash[Variable::V_X].begin(); vit != vHash[Variable::V_X].end(); ++vit)
{
colVarX = vit->second;
Arc arc = vit->first.getArc();
Vertex router = vit->first.getArc().getHead();
Vertex client = vit->first.getArc().getTail();
Constraint c(maxnnz, sense, rhs);
c.setType(Constraint::C_FACILITY_ACTIVATION);
c.setClass(1);
c.setArc(arc);
Variable y;
y.setType(Variable::V_Y);
y.setVertex1(router);
VariableHash::iterator aux = vHash[Variable::V_Y].find(y);
if (aux != vHash[Variable::V_Y].end())
{
colVarY = aux->second;
c.rowAddVar(colVarX, 1.0);
c.rowAddVar(colVarY, -1.0);
}
if (c.getRowNnz() > 0)
{
bool isInserted = addRow(&c);
if (isInserted)
{
c.setRowIdx(getNRows() - 1);
cHash[c] = c.getRowIdx();
numCons++;
}
}
}
for (vit = vHash[Variable::V_Z].begin(); vit != vHash[Variable::V_Z].end(); ++vit)
{
colVarZ = vit->second;
Arc arc = vit->first.getArc();
Vertex head = vit->first.getArc().getHead();
Vertex tail = vit->first.getArc().getTail();
Constraint c1(maxnnz, sense, rhs);
c1.setType(Constraint::C_FACILITY_ACTIVATION);
c1.setClass(2);
c1.setArc(arc);
Variable yHead;
yHead.setType(Variable::V_Y);
yHead.setVertex1(head);
VariableHash::iterator aux = vHash[Variable::V_Y].find(yHead);
if (aux != vHash[Variable::V_Y].end())
{
colVarY = aux->second;
c1.rowAddVar(colVarZ, 1.0);
c1.rowAddVar(colVarY, -1.0);
}
if (c1.getRowNnz() > 0)
{
bool isInserted = addRow(&c1);
if (isInserted)
{
c1.setRowIdx(getNRows() - 1);
cHash[c1] = c1.getRowIdx();
numCons++;
}
}
Constraint c2(maxnnz, sense, rhs);
c2.setType(Constraint::C_FACILITY_ACTIVATION);
c2.setClass(2);
c2.setArc(arc.reverse());
Variable yTail;
yTail.setType(Variable::V_Y);
yTail.setVertex1(tail);
aux = vHash[Variable::V_Y].find(yTail);
if (aux != vHash[Variable::V_Y].end())
{
colVarY = aux->second;
c2.rowAddVar(colVarZ, 1.0);
c2.rowAddVar(colVarY, -1.0);
}
if (c2.getRowNnz() > 0)
//.........这里部分代码省略.........
开发者ID:phliguori,项目名称:vpn,代码行数:101,代码来源:FacilityLocation.cpp
示例10: main
int main()
{
{
std::vector<int> v(100);
std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
assert(v.size() == 105);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
int j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
for (; j < 15; ++j)
assert(v[j] == 1);
for (++j; j < 105; ++j)
assert(v[j] == 0);
}
{
std::vector<int, stack_allocator<int, 300> > v(100);
std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 5, 1);
assert(v.size() == 105);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
int j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
for (; j < 15; ++j)
assert(v[j] == 1);
for (++j; j < 105; ++j)
assert(v[j] == 0);
}
#if _LIBCPP_DEBUG >= 1
{
std::vector<int> c1(100);
std::vector<int> c2;
std::vector<int>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
assert(false);
}
#endif
#if __cplusplus >= 201103L
{
std::vector<int, min_allocator<int>> v(100);
std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
assert(v.size() == 105);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
int j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
for (; j < 15; ++j)
assert(v[j] == 1);
for (++j; j < 105; ++j)
assert(v[j] == 0);
}
{
std::vector<int, min_allocator<int>> v(100);
std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
assert(v.size() == 105);
assert(is_contiguous_container_asan_correct(v));
assert(i == v.begin() + 10);
int j;
for (j = 0; j < 10; ++j)
assert(v[j] == 0);
for (; j < 15; ++j)
assert(v[j] == 1);
for (++j; j < 105; ++j)
assert(v[j] == 0);
}
#if _LIBCPP_DEBUG >= 1
{
std::vector<int, min_allocator<int>> c1(100);
std::vector<int, min_allocator<int>> c2;
std::vector<int, min_allocator<int>>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
assert(false);
}
#endif
#endif
}
开发者ID:0xDEC0DE8,项目名称:ndk,代码行数:77,代码来源:insert_iter_size_value.pass.cpp
示例11: main
int main(int argc, char *argv[]) {
long seed = time(NULL);
srand48(seed);
SetSeed(to_ZZ(seed));
unsigned p = 2027;
unsigned g = 3;
unsigned logQ = 120;
FHEcontext context(p-1, logQ, p, g);
activeContext = &context;
context.SetUpSIContext();
FHESISecKey secretKey(context);
const FHESIPubKey &publicKey(secretKey);
KeySwitchSI keySwitch(secretKey);
long phim = context.zMstar.phiM();
long numSlots = context.GetPlaintextSpace().GetTotalSlots();
long rotAmt = rand() % numSlots;
long rotDeg = 1;
for (int i = 0; i < rotAmt; i++) {
rotDeg *= context.Generator();
rotDeg %= context.zMstar.M();
}
KeySwitchSI automorphKeySwitch(secretKey, rotDeg);
Plaintext p0, p1, p2, p3;
randomizePlaintext(p0, phim, p);
randomizePlaintext(p1, phim, p);
randomizePlaintext(p2, phim, p);
randomizePlaintext(p3, phim, p);
Plaintext const1, const2;
randomizePlaintext(const1, phim, p);
randomizePlaintext(const2, phim, p);
Ciphertext c0(publicKey);
Ciphertext c1(publicKey);
Ciphertext c2(publicKey);
Ciphertext c3(publicKey);
publicKey.Encrypt(c0, p0);
publicKey.Encrypt(c1, p1);
publicKey.Encrypt(c2, p2);
publicKey.Encrypt(c3, p3);
p1 *= p2;
p0 += const1;
p2 *= const2;
p3 >>= rotAmt;
p1 *= -1;
p3 *= p2;
p0 -= p3;
c1 *= c2;
keySwitch.ApplyKeySwitch(c1);
c0 += const1.message;
c2 *= const2.message;
c3 >>= rotDeg;
automorphKeySwitch.ApplyKeySwitch(c3);
c1 *= -1;
c3 *= c2;
keySwitch.ApplyKeySwitch(c3);
Ciphertext tmp(c3);
tmp *= -1;
c0 += tmp;
Plaintext pp0, pp1, pp2, pp3;
secretKey.Decrypt(pp0, c0);
secretKey.Decrypt(pp1, c1);
secretKey.Decrypt(pp2, c2);
secretKey.Decrypt(pp3, c3);
if (!(pp0 == p0)) cerr << "oops 0" << endl;
if (!(pp1 == p1)) cerr << "oops 1" << endl;
if (!(pp2 == p2)) cerr << "oops 2" << endl;
if (!(pp3 == p3)) cerr << "oops 3" << endl;
cout << "All tests finished." << endl;
}
开发者ID:dwu4,项目名称:fhe-si,代码行数:86,代码来源:Test_General.cpp
示例12: GFXDEBUGEVENT_SCOPE
void EditTSCtrl::renderCameraAxis()
{
GFXDEBUGEVENT_SCOPE( Editor_renderCameraAxis, ColorI::WHITE );
static MatrixF sRotMat(EulerF( (M_PI_F / -2.0f), 0.0f, 0.0f));
MatrixF camMat = mLastCameraQuery.cameraMatrix;
camMat.mul(sRotMat);
camMat.inverse();
MatrixF axis;
axis.setColumn(0, Point3F(1, 0, 0));
axis.setColumn(1, Point3F(0, 0, 1));
axis.setColumn(2, Point3F(0, -1, 0));
axis.mul(camMat);
Point3F forwardVec, upVec, rightVec;
axis.getColumn( 2, &forwardVec );
axis.getColumn( 1, &upVec );
axis.getColumn( 0, &rightVec );
Point2I pos = getPosition();
F32 offsetx = pos.x + 20.0;
F32 offsety = pos.y + getExtent().y - 42.0; // Take the status bar into account
F32 scale = 15.0;
// Generate correct drawing order
ColorI c1(255,0,0);
ColorI c2(0,255,0);
ColorI c3(0,0,255);
ColorI tc;
Point3F *p1, *p2, *p3, *tp;
p1 = &rightVec;
p2 = &upVec;
p3 = &forwardVec;
if(p3->y > p2->y)
{
tp = p2; tc = c2;
p2 = p3; c2 = c3;
p3 = tp; c3 = tc;
}
if(p2->y > p1->y)
{
tp = p1; tc = c1;
p1 = p2; c1 = c2;
p2 = tp; c2 = tc;
}
PrimBuild::begin( GFXLineList, 6 );
//*** Axis 1
PrimBuild::color(c1);
PrimBuild::vertex3f(offsetx, offsety, 0);
PrimBuild::vertex3f(offsetx+p1->x*scale, offsety-p1->z*scale, 0);
//*** Axis 2
PrimBuild::color(c2);
PrimBuild::vertex3f(offsetx, offsety, 0);
PrimBuild::vertex3f(offsetx+p2->x*scale, offsety-p2->z*scale, 0);
//*** Axis 3
PrimBuild::color(c3);
PrimBuild::vertex3f(offsetx, offsety, 0);
PrimBuild::vertex3f(offsetx+p3->x*scale, offsety-p3->z*scale, 0);
PrimBuild::end();
}
开发者ID:souxiaosou,项目名称:OmniEngine.Net,代码行数:65,代码来源:editTSCtrl.cpp
示例13: test_basic_template
void test_basic_template(
ForwardIterator first,ForwardIterator last
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Flyweight))
{
typedef typename Flyweight::value_type value_type;
ForwardIterator it;
for(it=first;it!=last;++it){
/* construct/copy/destroy */
Flyweight f1(*it);
Flyweight f2;
Flyweight c1(f1);
const Flyweight c2(static_cast<const Flyweight&>(f2));
value_type v1(*it);
boost::value_initialized<value_type> v2;
BOOST_TEST(f1.get_key()==*it);
BOOST_TEST((f1==f2)==(f1.get()==v2.data()));
BOOST_TEST(f1==c1);
BOOST_TEST(f2==c2);
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
Flyweight cr1(std::move(c1));
Flyweight cr2(std::move(c2));
BOOST_TEST(f1==cr1);
BOOST_TEST(f2==cr2);
#endif
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
/* testcase for https://svn.boost.org/trac/boost/ticket/10439 */
Flyweight f3={};
BOOST_TEST(f3==f2);
#endif
f1=f1;
BOOST_TEST(f1==f1);
c1=f2;
BOOST_TEST(c1==f2);
c1=f1;
BOOST_TEST(c1==f1);
/* convertibility to underlying type */
BOOST_TEST(f1.get()==v1);
/* identity of reference */
BOOST_TEST(&f1.get()==&c1.get());
/* modifiers */
f1.swap(f1);
BOOST_TEST(f1==c1);
f1.swap(f2);
BOOST_TEST(f1==c2);
BOOST_TEST(f2==c1);
boost::flyweights::swap(f1,f2);
BOOST_TEST(f1==c1);
BOOST_TEST(f2==c2);
/* specialized algorithms */
std::ostringstream oss1;
oss1<<f1;
std::ostringstream oss2;
oss2<<f1.get();
BOOST_TEST(oss1.str()==oss2.str());
#if !defined(BOOST_FLYWEIGHT_DISABLE_HASH_SUPPORT)
/* hash support */
BOOST_TEST(boost::hash<Flyweight>()(f1)==boost::hash<Flyweight>()(c1));
BOOST_TEST(boost::hash<Flyweight>()(f1)==
boost::hash<const value_type*>()(&f1.get()));
#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
BOOST_TEST(std::hash<Flyweight>()(f1)==std::hash<Flyweight>()(c1));
BOOST_TEST(std::hash<Flyweight>()(f1)==
std::hash<const value_type*>()(&f1.get()));
#endif
#endif
}
}
开发者ID:Kirozen,项目名称:winmerge-v2,代码行数:90,代码来源:test_basic_template.hpp
示例14: while
//.........这里部分代码省略.........
x = num[0] + offsetX;
num++;
count--;
path.lineTo(x, y);
}
break;
case 'H': {
x = num[0];
num++;
count--;
path.lineTo(x, y);
}
break;
case 'v': {
y = num[0] + offsetY;
num++;
count--;
path.lineTo(x, y);
}
break;
case 'V': {
y = num[0];
num++;
count--;
path.lineTo(x, y);
}
break;
case 'c': {
if (count < 6) {
num += count;
count = 0;
break;
}
QPointF c1(num[0] + offsetX, num[1] + offsetY);
QPointF c2(num[2] + offsetX, num[3] + offsetY);
QPointF e(num[4] + offsetX, num[5] + offsetY);
num += 6;
count -= 6;
path.cubicTo(c1, c2, e);
ctrlPt = c2;
x = e.x();
y = e.y();
break;
}
case 'C': {
if (count < 6) {
num += count;
count = 0;
break;
}
QPointF c1(num[0], num[1]);
QPointF c2(num[2], num[3]);
QPointF e(num[4], num[5]);
num += 6;
count -= 6;
path.cubicTo(c1, c2, e);
ctrlPt = c2;
x = e.x();
y = e.y();
break;
}
case 's': {
if (count < 4) {
num += count;
count = 0;
break;
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:67,代码来源:qquicksvgparser.cpp
示例15: plot
//.........这里部分代码省略.........
fsn_site2->Add(fsn[i]);
amc_site2->Add(amc[i]);
afn_site2->Add(afn[i]);
}
for (int i=3; i<6; i++) {
data_site3->Add(data[i]);
pred_site3->Add(predOsc[i]);
acc_site3->Add(acc[i]);
li9_site3->Add(li9[i]);
fsn_site3->Add(fsn[i]);
amc_site3->Add(amc[i]);
afn_site3->Add(afn[i]);
}
hs_site1->Add(fsn_site1);
hs_site1->Add(afn_site1);
hs_site1->Add(amc_site1);
hs_site1->Add(li9_site1);
hs_site1->Add(acc_site1);
hs_site2->Add(fsn_site2);
hs_site2->Add(afn_site2);
hs_site2->Add(amc_site2);
hs_site2->Add(li9_site2);
hs_site2->Add(acc_site2);
hs_site3->Add(fsn_site3);
hs_site3->Add(afn_site3);
hs_site3->Add(amc_site3);
hs_site3->Add(li9_site3);
hs_site3->Add(acc_site3);
TCanvas c1("c1", "c1", 800, 800);
TPad *can_1 = new TPad("can_1", "can_1",0, 0.66, 1, 0.99);
TPad *can_2 = new TPad("can_2", "can_2",0, 0.33, 1, 0.66);
TPad *can_3 = new TPad("can_3", "can_3",0, 0, 1, 0.33);
can_1->Draw();
can_1->cd();
can_1->SetBottomMargin(1e-05);
can_1->SetFrameBorderMode(0);
can_1->SetBorderMode(0);
data_site1->Draw();
data_site1->SetTitle("");
hs_site1->Draw("same");
data_site1->Draw("same");
// pred_site1->Draw("same");
data_site1->GetXaxis()->SetLabelSize(0.09);
data_site1->GetYaxis()->SetNdivisions(508);
data_site1->GetYaxis()->SetTitleSize(0.08);
data_site1->GetYaxis()->SetLabe
|
请发表评论