void compute_vector(void) { x = x - a; a = c1 - w1; if (x <= 0.0) { if (a > 0.0) { c1 = 3.0; sub2(); return; } else { c1 = 5.0; sub1(); return; } } else if (a < 0.0) { c1 = 7.0; sub2(); return; } else { c1 = 1.0; sub1(); return; } }
TEST( NorOp, MatchesThreeClauses ) { BSONObj baseOperand1 = BSON( "$gt" << 10 ); BSONObj baseOperand2 = BSON( "$lt" << 0 ); BSONObj baseOperand3 = BSON( "b" << 100 ); auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", ComparisonMatchExpression::GT, baseOperand1[ "$gt" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", ComparisonMatchExpression::LT, baseOperand2[ "$lt" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> sub3( new ComparisonMatchExpression() ); ASSERT( sub3->init( "b", ComparisonMatchExpression::EQ, baseOperand3[ "b" ] ).isOK() ); NorMatchExpression norOp; norOp.add( sub1.release() ); norOp.add( sub2.release() ); norOp.add( sub3.release() ); ASSERT( !norOp.matches( BSON( "a" << -1 ), NULL ) ); ASSERT( !norOp.matches( BSON( "a" << 11 ), NULL ) ); ASSERT( norOp.matches( BSON( "a" << 5 ), NULL ) ); ASSERT( !norOp.matches( BSON( "b" << 100 ), NULL ) ); ASSERT( norOp.matches( BSON( "b" << 101 ), NULL ) ); ASSERT( norOp.matches( BSONObj(), NULL ) ); ASSERT( !norOp.matches( BSON( "a" << 11 << "b" << 100 ), NULL ) ); }
int main(void) { printf("hello main\n"); sub1(); return 0; }
TEST( AndOp, MatchesThreeClauses ) { BSONObj baseOperand1 = BSON( "$gt" << 1 ); BSONObj baseOperand2 = BSON( "$lt" << 10 ); BSONObj baseOperand3 = BSON( "$lt" << 100 ); auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", ComparisonMatchExpression::GT, baseOperand1[ "$gt" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", ComparisonMatchExpression::LT, baseOperand2[ "$lt" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> sub3( new ComparisonMatchExpression() ); ASSERT( sub3->init( "b", ComparisonMatchExpression::LT, baseOperand3[ "$lt" ] ).isOK() ); AndMatchExpression andOp; andOp.add( sub1.release() ); andOp.add( sub2.release() ); andOp.add( sub3.release() ); ASSERT( andOp.matches( BSON( "a" << 5 << "b" << 6 ), NULL ) ); ASSERT( !andOp.matches( BSON( "a" << 5 ), NULL ) ); ASSERT( !andOp.matches( BSON( "b" << 6 ), NULL ) ); ASSERT( !andOp.matches( BSON( "a" << 1 << "b" << 6 ), NULL ) ); ASSERT( !andOp.matches( BSON( "a" << 10 << "b" << 6 ), NULL ) ); }
int main(void) { printf("add1(%d) = %d\n",7,add1(7)); printf("sub1(%d) = %d\n",7,sub1(7)); printf( return 0; }
TEST( AndOp, MatchesElementThreeClauses ) { BSONObj baseOperand1 = BSON( "$lt" << "z1" ); BSONObj baseOperand2 = BSON( "$gt" << "a1" ); BSONObj match = BSON( "a" << "r1" ); BSONObj notMatch1 = BSON( "a" << "z1" ); BSONObj notMatch2 = BSON( "a" << "a1" ); BSONObj notMatch3 = BSON( "a" << "r" ); auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", ComparisonMatchExpression::LT, baseOperand1[ "$lt" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "a", ComparisonMatchExpression::GT, baseOperand2[ "$gt" ] ).isOK() ); auto_ptr<RegexMatchExpression> sub3( new RegexMatchExpression() ); ASSERT( sub3->init( "a", "1", "" ).isOK() ); AndMatchExpression andOp; andOp.add( sub1.release() ); andOp.add( sub2.release() ); andOp.add( sub3.release() ); ASSERT( andOp.matches( match ) ); ASSERT( !andOp.matches( notMatch1 ) ); ASSERT( !andOp.matches( notMatch2 ) ); ASSERT( !andOp.matches( notMatch3 ) ); }
int main(void) { int n= 10; sub1(n); return 0; }
int main() { struct mine { char* a ; char x[20] ; float z ; } i; union crazy { float a ; char b ; int s ; } a ; char x[50] ; spray_paint( (char *) &i, sizeof(i), 0xd1, "main.i" ) ; spray_paint( (char *) &a, sizeof(a), 0xd2, "main.a" ) ; spray_paint( (char *) &x, sizeof(x), 0xd3, "main.x" ) ; sub1() ; return 0 ; }
TEST( AndOp, ElemMatchKey ) { BSONObj baseOperand1 = BSON( "a" << 1 ); BSONObj baseOperand2 = BSON( "b" << 2 ); auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", ComparisonMatchExpression::EQ, baseOperand1[ "a" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "b", ComparisonMatchExpression::EQ, baseOperand2[ "b" ] ).isOK() ); AndMatchExpression andOp; andOp.add( sub1.release() ); andOp.add( sub2.release() ); MatchDetails details; details.requestElemMatchKey(); ASSERT( !andOp.matches( BSON( "a" << BSON_ARRAY( 1 ) ), &details ) ); ASSERT( !details.hasElemMatchKey() ); ASSERT( !andOp.matches( BSON( "b" << BSON_ARRAY( 2 ) ), &details ) ); ASSERT( !details.hasElemMatchKey() ); ASSERT( andOp.matches( BSON( "a" << BSON_ARRAY( 1 ) << "b" << BSON_ARRAY( 1 << 2 ) ), &details ) ); ASSERT( details.hasElemMatchKey() ); // The elem match key for the second $and clause is recorded. ASSERT_EQUALS( "1", details.elemMatchKey() ); }
main() { REC a = {16, 90.0}, b[] = {16, 90.0}; sub1(a); printf("A) %d, %5.1lf\n", a.num, a.mark); sub2(b); printf("B) %d, %5.1lf\n", b[0].num, b[0].mark); }
void sub1 (int n) { if (n > 0){ sub1(n - 1); printf("n = %d\n",n); } }
int main(int argc, char **argv) { char my_char = 'y'; param_test('y', 'z'); sub0(); sub1(&my_char); return 0; }
void map() { int* arr; double dt = 0.01; int N = 100000; Quadrotor* r = new Quadrotor(dt, N); VQPoles(r); int choices = 5; int repeat = 3; //int len = pow(choices, repeat); product(choices, repeat, arr); //double center[] = {10.0, 3.0, 7.0, 3.0}; //double length[] = { 9.9, 2.9, 6.9, 2.9}; double center[] = {-10.0, -10.0, -00.0}; double length[] = { 5.0, 5.0, 0.0}; double* coeff = new double[choices * repeat]; printf("map start\n"); for(int b = 0; b < 20; b++) { int a = -1; set_coeff(center, length, choices, repeat, coeff); a = sub1(r, arr, coeff, choices, repeat); if(a == -1) { printf("failed\n"); return; } for(int c = 0; c < repeat; c++) { center[c] = coeff[c*choices + arr[a*repeat + c]]; length[c] = length[c] * 0.8; } printf("center length\n"); print_arr(center, repeat); print_arr(length, repeat); //printf("a %i\n",a); } }
void WordList::mergeSort(vector<string> &subWordList) // recursive merge sort { if (subWordList.size() > 1) { vector<string> sub1(subWordList.begin(), subWordList.begin() + subWordList.size() / 2); mergeSort(sub1); vector<string> sub2(subWordList.begin() + subWordList.size() / 2, subWordList.end()); mergeSort(sub2); merge(subWordList, sub1, sub2); } }
int main () { typedef struct { int c[22]; }c; if (sub1 (20, 3) != sizeof (c)*3) abort (); return 0; }
void program_prog( int argc, char const* argv[]) { common cmn(argc, argv); common_write write(cmn); int num = fem::int0; sub1(num); write(6, star), "num after sub1:", num; int n = 1; sub2(num, n); write(6, star), "num after sub2", num; arr_1d<2, int> nums(fem::fill0); sub1(nums); write(6, star), "nums after sub1:", nums(1), nums(2); n = 2; sub2(nums, n); write(6, star), "nums after sub2:", nums(1), nums(2); sub3(nums, n); write(6, star), "nums after sub3:", nums(1), nums(2); }
void testTortureExecute (void) { if (sub1 (20) != 35) ASSERT (0); if (sub2 (20) != 45) ASSERT (0); if (sub3 (20) != -5) ASSERT (0); if (sub4 (20) != 5) ASSERT (0); return; }
main() { if (sub1 (0x80000000ULL)) abort (); if (sub2 (0x80000000ULL)) abort (); if (sub3 (0x80000000ULL)) abort (); if (sub4 (0x80000000ULL)) abort (); exit (0); }
void testTortureExecute (void) { #if !defined(__SDCC_ds390) && !defined(__SDCC_pic14) && !defined(__SDCC_pic16) if (sub1 (0x80000000ULL)) ASSERT (0); if (sub2 (0x80000000ULL)) ASSERT (0); if (sub3 (0x80000000ULL)) ASSERT (0); if (sub4 (0x80000000ULL)) ASSERT (0); return; #endif }
int main(){ int n; while(scanf("%s",op1) != EOF){ if(strcmp(op1,"0")==0){ printf("%d\n",1); continue; } rev(op1); sub1(); memcpy(op2,res,PREC); mult(); memcpy(op2,res,PREC); set_op1(2); add(); rev(res); printf("%s\n",res); } return 0; }
static void decasteljau(double tol, std::vector<sortedPoint> &discrete, int pos, const std::vector<SPoint3> &pts, double t0, double te) { int order = (int)pts.size() - 1; double dmax2 = 0; for (int i = 1; i < order ; ++i) dmax2 = std::max(dmax2, sqDistPointSegment(pts[i], pts[0], pts[order])); if(dmax2 < tol * tol) return; std::vector<SPoint3> sub0(pts.size()); std::vector<SPoint3> sub1(pts); for (int l = 0; l < order + 1; ++l) { sub0[l] = sub1[0]; for (int i = 0; i < order - l; ++i) sub1[i] = (sub1[i] + sub1[i + 1]) * 0.5; } double tmid = 0.5 * (t0 + te); int newpos = sortedPointInsert(sub1[0], tmid, discrete, pos); decasteljau(tol, discrete, pos, sub0, t0, tmid); decasteljau(tol, discrete, newpos, sub1, tmid, te); }
void main() { debug(); Describe("RGBAImage<byte>", []() { It("should be able to read data from bmp file", []() { RGBAImage<byte> image("TestResources/rgbw_2x2.bmp"); Expect(image.GetPixel(0, 0)).ToBe(RGBAColor<byte>(255, 0, 0, 255)); Expect(image.GetPixel(1, 0)).ToBe(RGBAColor<byte>(0, 255, 0, 255)); Expect(image.GetPixel(0, 1)).ToBe(RGBAColor<byte>(0, 0, 255, 255)); Expect(image.GetPixel(1, 1)).ToBe(RGBAColor<byte>(255, 255, 255, 255)); }); Describe("when read lena.bmp finished", []() { RGBAImage<byte> image("TestResources/Lena.bmp"); It("should be able to get width and height", [&image]() { Expect(image.Height()).ToBe(512); Expect(image.Width()).ToBe(512); }); It("should be able to get pixel", [&image]() { Expect(image.GetPixel(0, 0)).ToBe(RGBAColor<byte>(225, 138, 128, 255)); }); It("should be able to indexof sub image", [&image]() { RGBAImage<byte> sub1("TestResources/IndexOf/sub1.bmp"); RGBAImage<byte> sub2("TestResources/IndexOf/sub2.bmp"); RGBAImage<byte> sub3("TestResources/IndexOf/sub3.bmp"); Expect(image.IndexOf(sub1)).ToBe(Coord<short>(0, 0)); Expect(image.IndexOf(sub2)).ToBe(Coord<short>(1, 500)); Expect(image.IndexOf(sub3)).ToBe(Coord<short>(122, 237)); }); }); }); Benchmark("read lene.bmp", []() { RGBAImage<byte> image("TestResources/Lena.bmp"); }); Benchmark("indexof lene.bmp", []() { RGBAImage<byte> sub3("TestResources/IndexOf/sub3.bmp"); RGBAImage<byte> image("TestResources/Lena.bmp"); image.IndexOf(sub3); }); }
TEST( NorOp, ElemMatchKey ) { BSONObj baseOperand1 = BSON( "a" << 1 ); BSONObj baseOperand2 = BSON( "b" << 2 ); auto_ptr<ComparisonMatchExpression> sub1( new ComparisonMatchExpression() ); ASSERT( sub1->init( "a", ComparisonMatchExpression::EQ, baseOperand1[ "a" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> sub2( new ComparisonMatchExpression() ); ASSERT( sub2->init( "b", ComparisonMatchExpression::EQ, baseOperand2[ "b" ] ).isOK() ); NorMatchExpression norOp; norOp.add( sub1.release() ); norOp.add( sub2.release() ); MatchDetails details; details.requestElemMatchKey(); ASSERT( !norOp.matches( BSON( "a" << 1 ), &details ) ); ASSERT( !details.hasElemMatchKey() ); ASSERT( !norOp.matches( BSON( "a" << BSON_ARRAY( 1 ) << "b" << BSON_ARRAY( 10 ) ), &details ) ); ASSERT( !details.hasElemMatchKey() ); ASSERT( norOp.matches( BSON( "a" << BSON_ARRAY( 3 ) << "b" << BSON_ARRAY( 4 ) ), &details ) ); // The elem match key feature is not implemented for $nor. ASSERT( !details.hasElemMatchKey() ); }
TEST( OrOp, MatchesThreeClauses ) { BSONObj baseOperand1 = BSON( "$gt" << 10 ); BSONObj baseOperand2 = BSON( "$lt" << 0 ); BSONObj baseOperand3 = BSON( "b" << 100 ); auto_ptr<ComparisonMatchExpression> sub1( new GTMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "$gt" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> sub2( new LTMatchExpression() ); ASSERT( sub2->init( "a", baseOperand2[ "$lt" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> sub3( new EqualityMatchExpression() ); ASSERT( sub3->init( "b", baseOperand3[ "b" ] ).isOK() ); OrMatchExpression orOp; orOp.add( sub1.release() ); orOp.add( sub2.release() ); orOp.add( sub3.release() ); ASSERT( orOp.matchesBSON( BSON( "a" << -1 ), NULL ) ); ASSERT( orOp.matchesBSON( BSON( "a" << 11 ), NULL ) ); ASSERT( !orOp.matchesBSON( BSON( "a" << 5 ), NULL ) ); ASSERT( orOp.matchesBSON( BSON( "b" << 100 ), NULL ) ); ASSERT( !orOp.matchesBSON( BSON( "b" << 101 ), NULL ) ); ASSERT( !orOp.matchesBSON( BSONObj(), NULL ) ); ASSERT( orOp.matchesBSON( BSON( "a" << 11 << "b" << 100 ), NULL ) ); }
TEST( OrOp, ElemMatchKey ) { BSONObj baseOperand1 = BSON( "a" << 1 ); BSONObj baseOperand2 = BSON( "b" << 2 ); auto_ptr<ComparisonMatchExpression> sub1( new EqualityMatchExpression() ); ASSERT( sub1->init( "a", baseOperand1[ "a" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> sub2( new EqualityMatchExpression() ); ASSERT( sub2->init( "b", baseOperand2[ "b" ] ).isOK() ); OrMatchExpression orOp; orOp.add( sub1.release() ); orOp.add( sub2.release() ); MatchDetails details; details.requestElemMatchKey(); ASSERT( !orOp.matchesBSON( BSONObj(), &details ) ); ASSERT( !details.hasElemMatchKey() ); ASSERT( !orOp.matchesBSON( BSON( "a" << BSON_ARRAY( 10 ) << "b" << BSON_ARRAY( 10 ) ), &details ) ); ASSERT( !details.hasElemMatchKey() ); ASSERT( orOp.matchesBSON( BSON( "a" << BSON_ARRAY( 1 ) << "b" << BSON_ARRAY( 1 << 2 ) ), &details ) ); // The elem match key feature is not implemented for $or. ASSERT( !details.hasElemMatchKey() ); }
int main(int argc, char* argv[]) { std::shared_ptr<Empty> blank; std::shared_ptr<Program> prg(new Program()); std::shared_ptr<SharedDecl> shDecl1(new SharedDecl("y", blank)); prg->Add(shDecl1); std::shared_ptr<Node> initX(new Atom("2")); std::shared_ptr<SharedDecl> shDecl2(new SharedDecl("x", initX)); prg->Add(shDecl2); std::shared_ptr<Sub> sub1(new Sub("Main")); sub1->AddParam("a"); sub1->AddParam("b"); prg->Add(sub1); std::shared_ptr<Atom> atomA(new Atom("a")); std::shared_ptr<Atom> atomB(new Atom("b")); std::shared_ptr<BinaryOp> initRes(new BinaryOp("add", atomA, atomB)); std::shared_ptr<VarDecl> resDecl(new VarDecl("res", initRes)); sub1->Add(resDecl); std::shared_ptr<Atom> atom3i(new Atom("3")); std::shared_ptr<Atom> atom5i(new Atom("5")); std::shared_ptr<BinaryOp> newParam(new BinaryOp("add", atom3i, atom5i)); std::shared_ptr<Allocation> allocat(new Allocation(newParam)); std::shared_ptr<Atom> atomArr(new Atom("arr")); std::shared_ptr<Assignation> asignNew3(new Assignation(atomArr, allocat)); sub1->Add(asignNew3); std::shared_ptr<Atom> atomArrBis(new Atom("arr")); std::shared_ptr<Deallocation> deallocat(new Deallocation(atomArrBis)); sub1->Add(deallocat); std::shared_ptr<Atom> atomC(new Atom("res")); std::shared_ptr<BinaryOp> subCsumAB(new BinaryOp("substract", atomC, initRes)); std::shared_ptr<Assignation> incC(new Assignation(atomC, subCsumAB)); sub1->Add(incC); std::shared_ptr<Atom> atom0(new Atom("0")); std::shared_ptr<BinaryOp> cond1cond(new BinaryOp("equals", atomC, atom0)); std::shared_ptr<If> cond1(new If(cond1cond, "10", "20")); sub1->Add(cond1); std::shared_ptr<Atom> atom1(new Atom("1")); std::shared_ptr<Atom> atom10(new Atom("10")); std::shared_ptr<For> for1(new For("i", atom1, atom10, atom1)); sub1->Add(for1); std::shared_ptr<BinaryOp> addC1(new BinaryOp("add", atomC, atom1)); std::shared_ptr<Assignation> incResActually(new Assignation(atomC, addC1)); for1->Add(incResActually); std::shared_ptr<Loop> loop1(new Loop(cond1cond)); loop1->Add(for1); // don't double reference ever in practice... loop1->Add(addC1); sub1->Add(loop1); std::shared_ptr<Call> call1(new Call("testFun", "")); call1->AddParam(atomA); call1->AddParam(addC1); sub1->Add(call1); std::shared_ptr<Return> ret1(new Return(atom0)); sub1->Add(ret1); XMLDumpVisitor v; prg->Accept(&v); return 0; }
int main (void) { int ignored = sub1 (); return 0; }
int main() { NewsSubscriber sub1("one"); sub1.add_channel("x"); sub1.add_channel("y"); //sub2.add_channel("y"); //sub2.add_channel("z"); CableTV cable(&sub1); cable.Subscribe("two","y"); cable.Subscribe("two","z"); cable.OnNews("y","as"); cable.OnNews("x","rt"); cable.OnNews("z","das"); /* // test NewsSubscriber std::cout << "test NewsSubscriber\n\n"; //sub.set_subscriber_name("one"); // std::cout << sub.get_subscriber_name() << std::endl; sub.add_channel("x"); sub.add_channel("y"); sub.add_channel("z"); // std::set <std::string> ch=sub.get_channels_names(); // std::set<std::string>::iterator it; // for (it = ch.begin(); it != ch.end(); it++) { // std::cout << *it << ' '; // } // std::cout << "\n\ntest cabletv"; //test cabletv CableTV cable(&sub); cable.Subscribe("one", "tx"); // cable.display(); // NewsSubscriber sub2; // sub2.set_subscriber_name("two"); // cable.add_Subscriber(&sub2); cable.Subscribe("two", "x"); // cable.display(); cable.Subscribe("three", "x"); // cable.display(); cable.OnNews("x", "ttttt"); // cable.display(); cable.UnSubscribe("one", "tx"); cable.display(); cable.Subscribe("two", "ygy"); cable.display(); cable.UnSubscribeBySubscriber("one"); cable.display(); // cable.UnSubscribeByChannel("x"); // cable.display(); //std::cout << cable.number_of_user() << '\n'; //cable.UnSubscribeBySubscriber("one"); cable.OnNews("ygy", "fake2"); */ return 0; }
int main() { sub1(); }
main () { sub1 (); sub2 (); }