int main(int argc, const char *argv[]) {
    Date d1;
    Date d2("February", 14, 1952);

    d1.printDayYear();
    printf("\n");
    d1.printShort();
    printf("\n");
    d1.printLong();
    printf("\n\n");

    d2.printDayYear();
    printf("\n");
    d2.printShort();
    printf("\n");
    d2.printLong();
    std::cout << std::endl;

    return 0;
}
Exemple #2
0
    bool SegmentationChangeIndexAutoTest(int width, int height, const FuncCI & f1, const FuncCI & f2)
    {
        bool result = true;

        TEST_LOG_SS(Info, "Test " << f1.description << " & " << f2.description << " for size [" << width << "," << height << "].");

        const uint8_t oldIndex = 3, newIndex = 2;
        View s(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View d1(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View d2(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        FillRandomMask(s, oldIndex);

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f1.Call(s, oldIndex, newIndex, d1));

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f2.Call(s, oldIndex, newIndex, d2));

        result = result && Compare(d1, d2, 0, true, 64);

        return result;
    }
void SetContainerClass::setFunc()
{
  std::cout << "before:\n\tstd::string string1[n] = { c b c d e f };\n";
  std::string string1[n] = {"c","b","c","d","e","f"};
/*  for(int i = 0; i < 6; i++)
  {
    if(i == 0) { 
      string1[i] = i + 98; 
      continue;
    }
    string1[i] = i + 97;
  }
  */
  std::set<std::string, std::less<std::string> > d1; // old implementing
  std::set<std::string> d2(string1, string1 + n); // new implementing
  std::ostream_iterator<std::string, char> out(std::cout, " ");
  std::cout << "after:\n\tstd::string string1[n] = { ";
  copy(d2.begin(), d2.end(), out);
  std::cout << "};\n";
}
Exemple #4
0
void FLDiskCache::clear()
{
  QDir d(AQ_DISKCACHE_DIRPATH);
  if (d.exists()) {
    QStringList lst = d.entryList("*; *.*");
    for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it)
      d.remove(AQ_DISKCACHE_DIRPATH + '/' + (*it));
  }
#ifndef QSDEBUGGER
  QTextCodec *codec = QTextCodec::codecForLocale();
  QString localEncode(codec ? codec->mimeName() : "");
  QString path(AQ_USRHOME + "/.eneboocache/" + localEncode);
  QDir d2(path);
  if (d2.exists()) {
    QStringList lst = d2.entryList("sys*");
    for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it)
      d2.remove(path + '/' + (*it));
  }
#endif
}
Exemple #5
0
static void tst0() {
    std::cout << "--------------------------------\n";    
    imdd_manager m;
    imdd_ref d1(m), d2(m), d3(m), d4(m);
    d1 = m.mk_empty(1);
    d2 = m.mk_empty(1);
    m.insert_dupdt(d1, 10, 20);
    m.insert_dupdt(d1, 31, 50);
    m.insert_dupdt(d2, 1,  5);
    m.insert_dupdt(d2, 11,  13);
    m.mk_product(d1, d2, d4);
    m.mk_product(d4, d2, d4);
    m.mk_product_dupdt(d1, d2);
    std::cout << "d1:\n" << mk_ll_pp(d1, m) << "\n-------\n";
    m.mk_product_dupdt(d1, d2);
    std::cout << "d4:\n" << mk_ll_pp(d4, m) << "\nd1:\n" << mk_ll_pp(d1, m) << "\nd2:\n" << mk_ll_pp(d2, m) << "\n";
    std::cout << d1 << "\n" << d2 << "\n";
    m.mk_product_dupdt(d1, d1);
    std::cout << "d1 X d1:\n" << mk_ll_pp(d1, m) << "\n";
}
Exemple #6
0
	bool ColorFilterAutoTest(View::Format format, int width, int height, const FuncC & f1, const FuncC & f2)
	{
		bool result = true;

		TEST_LOG_SS(Info, "Test " << f1.description << " & " << f2.description << " [" << width << ", " << height << "].");

		View s(width, height, format, NULL, TEST_ALIGN(width));
		FillRandom(s);

		View d1(width, height, format, NULL, TEST_ALIGN(width));
		View d2(width, height, format, NULL, TEST_ALIGN(width));

		TEST_EXECUTE_AT_LEAST_MIN_TIME(f1.Call(s, d1));

		TEST_EXECUTE_AT_LEAST_MIN_TIME(f2.Call(s, d2));

		result = result && Compare(d1, d2, 0, true, 32);

		return result;
	}
Exemple #7
0
string Parser::getStringBetweenMatched(char cd1, char cd2) {
  string token = "";
  int open_delims = 0;
  string d1(1, cd1);
  string d2(1, cd2);
  nextTokenMustBe(d1);
  while (infile.peek() != cd2 || open_delims != 0) {
    if (infile.peek() == EOF) throw DanglingDelimiterException(filename, line_num, line_pos, d2);
    line_pos++;
    if (infile.peek() == '\n' || infile.peek() == '\f') {
      line_num++;
      line_pos = 1;
    }
    else if (infile.peek() == cd1) open_delims++;
    else if (infile.peek() == cd2) open_delims--;
    token += infile.get();
  }
  nextTokenMustBe(d2);
  return token;
}
Exemple #8
0
    bool StretchGrayDataTest(bool create, int width, int height, const Func & f, int stretch)
    {
        bool result = true;

        Data data(f.description);

        std::cout << (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "]." << std::endl;

        const int stretchedWidth = width*stretch;
        const int stretchedHeight = height*stretch;

        View s(width, height, View::Gray8, NULL, TEST_ALIGN(width));

        View d1(stretchedWidth, stretchedHeight, View::Gray8, NULL, TEST_ALIGN(stretchedWidth));
        View d2(stretchedWidth, stretchedHeight, View::Gray8, NULL, TEST_ALIGN(stretchedWidth));

        if(create)
        {
            FillRandom(s);

            TEST_SAVE(s);

            f.Call(s, d1);

            TEST_SAVE(d1);
        }
        else
        {
            TEST_LOAD(s);

            TEST_LOAD(d1);

            f.Call(s, d2);

            TEST_SAVE(d2);

            result = result && Compare(d1, d2, 0, true, 64);
        }

        return result;
    }
Exemple #9
0
unsigned int CDateTime::weekOfYear(int year, unsigned int month, unsigned int day)
{
    if (!isValid(year, month, day))
    {
        return 0;
    }

    CDateTime d1(year, month, day);
    int a = dayOfWeek(year, month, day);
    d1.addDays(4 - a); // Jeudi de cette semaine

    int y1 = d1.getYear();

    CDateTime d2(y1, 1, 4);
    int b = dayOfWeek(y1, 1, 4);
    d2.addDays(1 - b); // Lundi de cette semaine

    int y2 = d2.getYear();

    if (y1 < y2)
    {
        unsigned int a1 = (isLeapYear(y1) ? 366 : 365) - dayOfYear(y1, d1.getMonth(), d1.getDay());
        unsigned int a2 = dayOfYear(y2, d2.getMonth(), d2.getDay());

        return (1 + (a1 + a2) / 7);
    }
    else if (y1 > y2)
    {
        unsigned int a1 = dayOfYear(y1, d1.getMonth(), d1.getDay());
        unsigned int a2 = (isLeapYear(y2) ? 366 : 365) - dayOfYear(y2, d2.getMonth(), d2.getDay());

        return (1 + (a1 + a2) / 7);
    }
    else
    {
        unsigned int a1 = dayOfYear(y1, d1.getMonth(), d1.getDay());
        unsigned int a2 = dayOfYear(y2, d2.getMonth(), d2.getDay());

        return (1 + (a2 > a1 ? a2 - a1 : a1 - a2) / 7);
    }
}
int main() {
    {
        using T0 = hana::tuple<double>;
        using T1 = hana::tuple<int>;
        T0 t0(2.5);
        T1 t1;
        t1 = t0;
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
    }
    {
        using T0 = hana::tuple<double, char>;
        using T1 = hana::tuple<int, int>;
        T0 t0(2.5, 'a');
        T1 t1;
        t1 = t0;
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
    }
    {
        using T0 = hana::tuple<double, char, D>;
        using T1 = hana::tuple<int, int, B>;
        T0 t0(2.5, 'a', D(3));
        T1 t1;
        t1 = t0;
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3);
    }
    {
        D d(3);
        D d2(2);
        using T0 = hana::tuple<double, char, D&>;
        using T1 = hana::tuple<int, int, B&>;
        T0 t0(2.5, 'a', d2);
        T1 t1(1.5, 'b', d);
        t1 = t0;
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2);
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a'));
        BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2);
    }
}
Exemple #11
0
TEST(DictionaryEquality, SimpleValues) {
	AmfDictionary d0(true), d1(true), d2(false);
	d0.insert(AmfInteger(0), AmfString("foo"));
	d1.insert(AmfInteger(0), AmfString("foo"));
	d2.insert(AmfInteger(0), AmfString("foo"));
	EXPECT_EQ(d0, d1);
	EXPECT_NE(d0, d2);

	d0.insert(AmfString("qux"), AmfByteArray(v8 { 0x00 }));
	EXPECT_NE(d0, d1);
	d1.insert(AmfString("qux"), AmfByteArray(v8 { 0x00 }));
	EXPECT_EQ(d0, d1);

	d0.insert(AmfNull(), AmfUndefined());
	d1.insert(AmfUndefined(), AmfNull());
	EXPECT_NE(d0, d1);

	d0.insert(AmfUndefined(), AmfNull());
	d1.insert(AmfNull(), AmfUndefined());
	EXPECT_EQ(d0, d1);
}
Exemple #12
0
		double BlackScholesPrice(const double stockPrice, const double strikePrice,
			const double expiry, const double volatility, const double interestRate, 
			const double costOfCarry, const OptionType optionType)
		{
			double normalVal1 = NORMALDISTRIBUTIONS::N(d1(stockPrice, strikePrice, expiry, volatility, costOfCarry));
			double normalVal2 = NORMALDISTRIBUTIONS::N(d2(stockPrice, strikePrice, expiry, volatility, costOfCarry));

			switch (optionType)
			{
			case EUROPEANCALL:
				return (stockPrice*normalVal1*exp((costOfCarry - interestRate)*expiry) - strikePrice*normalVal2*exp(-interestRate*expiry));
				break;
			case EUROPEANPUT:
				// N(-d1) = 1 - N(d1) and N(-d2) = 1 - N(d2)
				return (strikePrice*(1 - normalVal2)*exp(-interestRate*expiry) - stockPrice*(1 - normalVal1)*exp((costOfCarry - interestRate)*expiry));
				break;
			default:
				throw EXCEPTIONS::InvalidOptionException(-1);
				break;
			}
		}
Exemple #13
0
    void testDoubleDerived() {
      DoubleDerivedVTBL d;
      d.x = 1;
      d.y = 2;
      d.z = 3;
      clang_analyzer_eval(getX(d) == 1); // expected-warning{{TRUE}}
      clang_analyzer_eval(getY(d) == 2); // expected-warning{{TRUE}}
      clang_analyzer_eval(getZ(d) == 3); // expected-warning{{TRUE}}

      Base b(d);
      clang_analyzer_eval(getX(b) == 1); // expected-warning{{TRUE}}

      DerivedVTBL d2(d);
      clang_analyzer_eval(getX(d2) == 1); // expected-warning{{TRUE}}
      clang_analyzer_eval(getY(d2) == 2); // expected-warning{{TRUE}}

      DoubleDerivedVTBL d3(d);
      clang_analyzer_eval(getX(d3) == 1); // expected-warning{{TRUE}}
      clang_analyzer_eval(getY(d3) == 2); // expected-warning{{TRUE}}
      clang_analyzer_eval(getZ(d3) == 3); // expected-warning{{TRUE}}
    }
Exemple #14
0
int main()
{
	Complex d1(5, 10);
	Complex d2(7, 10);
	Complex d4;

	cout << "d1(5,10)  "<<"d2(7,10)  "<<"d4(0,0)"<<endl;
	
	cout << "d4 = d1" << endl;
	d4 = d1;
	d4.Display();
	cout << "d2 - d1" << endl;
	d4 = d2 - d1;
	d4.Display();
	cout << "d2 + d1" << endl;
	d4 = d2 + d1;
	d4.Display();
	cout << "d4 += d1" << endl;
	d4 += d1;
	d4.Display();
	cout << "d4 -= d1" << endl;
	d4 -= d1;
	d4.Display();
	cout << "d4++" << endl;
	d4++;
	d4.Display();
	cout << "++d4" << endl;
	++d4;
	d4.Display();
	cout << "d4++" << endl;
	d4--;
	d4.Display();
	cout << "--d4" << endl;
	--d4;
	cout << "d4 == d1" << endl;
	cout << (d4 == d1) << endl;

	system("pause");
	return 0;
}
Exemple #15
0
main()
{
   Punct x1(10, 10), x2(100, 200);
   Dreptunghi d1(x1, x2), d2(10, 20, 14, 50);

   clrscr();

   d1.List();
   getch();
   cout<<'\n';
   d2.List();
   getch();
   cout<<'\n';
   if (d1 == d2)
      cout<<"d1 = d2";
   else
      cout<<"d1 != d2";
   getch();
   cout<<'\n';
   cout<<d1.Lung_lat1()<<' '<<d1.Lung_lat2();
   getch();
   cout<<'\n';
   cout<<d2.Lung_lat1()<<' '<<d2.Lung_lat2();
   getch();
   cout<<'\n';
   cout<<"Perimetrul d1: "<<d1.Perimetru();
   getch();
   cout<<'\n';
   cout<<"Perimetrul d2: "<<d2.Perimetru();
   getch();
   cout<<'\n';
   cout<<"d1, colt stanga sus : "<<d1.Colt_st_sus();
   getch();
   cout<<'\n';
   cout<<"d1, colt dreapta jos : "<<d1.Colt_dr_jos();
   getch();
   cout<<'\n';

   return 0;
}
//-------------------------------------------------------------------
// needs simplifyDP which is above
static vector <ofPoint> ofSimplifyContour(vector <ofPoint> &V, float tol){
	int n = V.size();

	vector <ofPoint> sV;
	sV.assign(n, ofPoint());

    int    i, k, m, pv;            // misc counters
    float  tol2 = tol * tol;       // tolerance squared
    ofPoint * vt = new ofPoint[n];
	int * mk = new int[n];

	memset(mk, 0, sizeof(int) * n );

    // STAGE 1.  Vertex Reduction within tolerance of prior vertex cluster
    vt[0] = V[0];              // start at the beginning
    for (i=k=1, pv=0; i<n; i++) {
        if (d2(V[i], V[pv]) < tol2) continue;

        vt[k++] = V[i];
        pv = i;
    }
    if (pv < n-1) vt[k++] = V[n-1];      // finish at the end

    // STAGE 2.  Douglas-Peucker polyline simplification
    mk[0] = mk[k-1] = 1;       // mark the first and last vertices
    simplifyDP( tol, vt, 0, k-1, mk );

    // copy marked vertices to the output simplified polyline
    for (i=m=0; i<k; i++) {
        if (mk[i]) sV[m++] = vt[i];
    }

	//get rid of the unused points
	if( m < (int)sV.size() ) sV.erase( sV.begin()+m, sV.end() );

	delete [] vt;
	delete [] mk;

	return sV;
}
Exemple #17
0
    bool SegmentationChangeIndexDataTest(bool create, int width, int height, const FuncCI & f)
    {
        bool result = true;

        Data data(f.description);

        TEST_LOG_SS(Info, (create ? "Create" : "Verify") << " test " << f.description << " [" << width << ", " << height << "].");

        View s(width, height, View::Gray8, NULL, TEST_ALIGN(width));

        View d1(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View d2(width, height, View::Gray8, NULL, TEST_ALIGN(width));

        const uint8_t oldIndex = 3, newIndex = 2;

        if(create)
        {
            FillRandomMask(s, oldIndex);

            TEST_SAVE(s);

            f.Call(s, oldIndex, newIndex, d1);

            TEST_SAVE(d1);
        }
        else
        {
            TEST_LOAD(s);

            TEST_LOAD(d1);

            f.Call(s, oldIndex, newIndex, d2);

            TEST_SAVE(d2);

            result = result && Compare(d1, d2, 0, true, 64);
        }

        return result;
    }
void TestQueue( const Allocator& a )
{
    // A queue can be made out of deque or list
    typedef std::deque< typename Allocator::value_type, Allocator > Deque;
    typedef std::list< typename Allocator::value_type, Allocator > List;

    typedef std::queue< typename Allocator::value_type, Deque > DQueue;
    typedef std::queue< typename Allocator::value_type, List > LQueue;

    DQueue d1( Policy< Allocator >::template GetDefaultAdapter< DQueue, Deque >( a ) );
    DQueue d2( Policy< Allocator >::template GetCopiedAdapter< DQueue, Deque >( a ) );
    LQueue l1( Policy< Allocator >::template GetDefaultAdapter< LQueue, List >( a ) );
    LQueue l2( Policy< Allocator >::template GetCopiedAdapter< LQueue, List >( a ) );

    // Test deque queues
    TestQueue( a, d1 );
    TestQueue( a, d2 );

    // Test list queues
    TestQueue( a, l1 );
    TestQueue( a, l2 );
}
Exemple #19
0
  result_type operator()(first_argument_type row,
                         second_argument_type r) const
  {
	  draw_north_wall d1;
	  pair_int p1(0,*r);
	  for (maze_row::walls::const_iterator cit = row->north_walls.begin();
	       cit != row->north_walls.end(); ++cit)
	  {
		  d1(*cit, &p1);
	  }

	  draw_east_wall d2;
	  pair_int p2(0,*r);
	  for (maze_row::walls::const_iterator cit = row->east_walls.begin();
	       cit != row->east_walls.end(); ++cit)
	  {
		  d2(*cit, &p2);
	  }
    (*r)++;

    return (0);
  }
void TestPriorityQueue( const Allocator& a )
{
    // A priority queue can be made out of vector or deque
    typedef std::vector< typename Allocator::value_type, Allocator > Vector;
    typedef std::deque< typename Allocator::value_type, Allocator > Deque;

    typedef std::priority_queue< typename Allocator::value_type, Vector > VQueue;
    typedef std::priority_queue< typename Allocator::value_type, Deque > DQueue;

    VQueue v1( Policy< Allocator >::template GetDefaultPriorityQueue< VQueue, Vector >( a ) );
    VQueue v2( Policy< Allocator >::template GetCopiedPriorityQueue< VQueue, Vector >( a ) );
    DQueue d1( Policy< Allocator >::template GetDefaultPriorityQueue< DQueue, Deque >( a ) );
    DQueue d2( Policy< Allocator >::template GetCopiedPriorityQueue< DQueue, Deque >( a ) );

    // Test vector queues
    TestPriorityQueue( a, v1 );
    TestPriorityQueue( a, v2 );

    // Test deque queues
    TestPriorityQueue( a, d1 );
    TestPriorityQueue( a, d2 );
}
Exemple #21
0
void main()
{
	RMB d1(1,60);
	RMB d2(2,50);
	RMB d3(0,0);
	/*RMB d4(20.16);
	d3=d2+d1;
	d3.display();
	++(++d3);
	d3.display();
	d4.display();
	d4=2.7+d3;
	d4.display();*/
	//d1+=d2;
	//d1.display();
	//d2+=3.8;
	d3=++d2;
	d2.display();
	d3.display();
	(d3=d1)++;
	d3.display();
}
Exemple #22
0
    bool ContourAnchorsAutoTest(int width, int height, const FuncA & f1, const FuncA & f2)
    {
        bool result = true;

        TEST_LOG_SS(Info, "Test " << f1.description << " & " << f2.description << " [" << width << ", " << height << "].");

        View s(width, height, View::Int16, NULL, TEST_ALIGN(width));
        FillRandom(s);

        View d1(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        View d2(width, height, View::Gray8, NULL, TEST_ALIGN(width));
        Simd::Fill(d1, 0);
        Simd::Fill(d2, 0);

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f1.Call(s, 3, 0, d1));

        TEST_EXECUTE_AT_LEAST_MIN_TIME(f2.Call(s, 3, 0, d2));

        result = result && Compare(d1, d2, 0, true, 64);

        return result;
    }
Exemple #23
0
bool FindClosestPoint(const Vector3f & p1, const Vector3f & q1, const Vector3f & p2, const Vector3f & q2, Vector3f & point)
{
	float s,t;
	const float epsUpper = 1+1e-2;
	const float epsLower = -1e-2;

	Vector3f d1(q1-p1);
	Vector3f d2(q2-p2);
	Vector3f r(p1-p2);
	float a = d1.dot(d1);
	float e = d2.dot(d2);
	float f = d2.dot(r);
	float c = d1.dot(r);
	
	float b = d1.dot(d2);
	float denom = a*e-b*b;

	if (denom != 0)
		s = (b*f - c*e)/denom;
	else s = 0;
	if (s < epsLower || s > epsUpper) return 0;

	t = (b*s + f)/e;
	if (t < epsLower) {
		return 0;
		
		//t = 0;
		//s = Clamp(-c/a, 0, 1.f);
	} else if (t > epsUpper) {
		return 0;

		//t = 1.f;
		//s = Clamp((b-c)/a, 0.f, 1.f);
	}

	point = p2 + d2*t;

	return 1;
}
int main(void)
{
    date d(2015, 6, 12);
    d.print();

    date d1(2015, 8, 31);
    std::cout<<"before set!"<<std::endl;
    d1.print();
    d1.add_date(1);
    std::cout<<"after set!"<<std::endl;
    d1.print();

    date d2(2015, 1, 1);
    std::cout<<"before set!"<<std::endl;
    d2.print();
    std::cout<<std::endl;
    std::cout<<"after set!"<<std::endl;
    d2.set_date(3000, 10, 10);
    d2.print();

    return 0;
}
Exemple #25
0
bool Knowledge::CanKick(Position robotPos, Vector2D ballPos)
{
    double distThreshold = _wm->var[0], degThreshold = _wm->var[1] / 10;

    AngleDeg d1((ballPos - robotPos.loc).dir());
    AngleDeg d2(robotPos.dir * AngleDeg::RAD2DEG);
    if(fabs((d1 - d2).degree()) < degThreshold || (360.0 - fabs((d1 - d2).degree())) < degThreshold)
    {
        if(robotPos.loc.dist(ballPos) < distThreshold)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}
/** \param[in] accum If not nullptr, use this object to accumulate
    partial first
    derivatives.
    \return Current score.
 */
double TALOSRestraint::unprotected_evaluate(DerivativeAccumulator *accum)
    const {
  core::XYZ d0(p_[0]);
  core::XYZ d1(p_[1]);
  core::XYZ d2(p_[2]);
  core::XYZ d3(p_[3]);
  Scale kappascale(kappa_);
  double kappaval = kappascale.get_scale();

  // get angle
  algebra::VectorD<3> derv0, derv1, derv2, derv3;
  double angle;
  if (accum) {
    angle = core::internal::dihedral(d0, d1, d2, d3, &derv0, &derv1, &derv2,
                                     &derv3);
  } else {
    angle = core::internal::dihedral(d0, d1, d2, d3, nullptr, nullptr, nullptr,
                                     nullptr);
  }

  // score current angle
  mises_->set_x(angle);
  mises_->set_kappa(kappaval);
  double score = mises_->evaluate();

  // store derivatives if necessary
  if (accum) {

    double deriv = mises_->evaluate_derivative_x();
    d0.add_to_derivatives(derv0 * deriv, *accum);
    d1.add_to_derivatives(derv1 * deriv, *accum);
    d2.add_to_derivatives(derv2 * deriv, *accum);
    d3.add_to_derivatives(derv3 * deriv, *accum);

    kappascale.add_to_scale_derivative(mises_->evaluate_derivative_kappa(),
                                       *accum);
  }
  return score;
}
Exemple #27
0
bool HistoryPlugin::detectOldHistory()
{
	KGlobal::config()->setGroup("History Plugin");
	QString version=KGlobal::config()->readEntry( "Version" ,"0.6" );

	if(version != "0.6")
		return false;


	QDir d( locateLocal( "data", QString::fromLatin1( "kopete/logs")) );
	d.setFilter( QDir::Dirs  );
	if(d.count() >= 3)  // '.' and '..' are included
		return false;  //the new history already exists

	QDir d2( locateLocal( "data", QString::fromLatin1( "kopete")) );
	d2.setFilter( QDir::Dirs  );
	const QFileInfoList_qt3 *list = d2.entryInfoList_qt3();
	QFileInfoListIterator it( *list );
	QFileInfo *fi;
	while ( (fi = it.current()) != 0 )
	{
		if( dynamic_cast<Kopete::Protocol *>( Kopete::PluginManager::self()->plugin( fi->fileName() ) ) )
			return true;

		if(fi->fileName() == "MSNProtocol" || fi->fileName() == "msn_logs" )
			return true;
		else if(fi->fileName() == "ICQProtocol" || fi->fileName() == "icq_logs" )
			return true;
		else if(fi->fileName() == "AIMProtocol" || fi->fileName() == "aim_logs" )
			return true;
		else if(fi->fileName() == "OscarProtocol" )
			return true;
		else if(fi->fileName() == "JabberProtocol" || fi->fileName() == "jabber_logs")
			return true;
		++it;
	}
	return false;
}
void test_transform_binary2(ExPolicy policy, IteratorTag)
{
    static_assert(
        hpx::parallel::is_execution_policy<ExPolicy>::value,
        "hpx::parallel::is_execution_policy<ExPolicy>::value");

    typedef std::vector<int>::iterator base_iterator;
    typedef test::test_iterator<base_iterator, IteratorTag> iterator;

    std::vector<int> c1(10007);
    std::vector<int> c2(c1.size());
    std::vector<int> d1(c1.size()); //-V656
    std::iota(boost::begin(c1), boost::end(c1), std::rand());
    std::iota(boost::begin(c2), boost::end(c2), std::rand());

    auto result =
        hpx::parallel::transform(policy,
            iterator(boost::begin(c1)), iterator(boost::end(c1)),
            boost::begin(c2), boost::end(c2), boost::begin(d1), add());

    HPX_TEST(hpx::util::get<0>(result) == iterator(boost::end(c1)));
    HPX_TEST(hpx::util::get<1>(result) == boost::end(c2));
    HPX_TEST(hpx::util::get<2>(result) == boost::end(d1));

    // verify values
    std::vector<int> d2(c1.size());
    std::transform(boost::begin(c1), boost::end(c1),
        boost::begin(c2), boost::begin(d2), add());

    std::size_t count = 0;
    HPX_TEST(std::equal(boost::begin(d1), boost::end(d1), boost::begin(d2),
        [&count](int v1, int v2) -> bool {
            HPX_TEST_EQ(v1, v2);
            ++count;
            return v1 == v2;
        }));
    HPX_TEST_EQ(count, d2.size());
}
Exemple #29
0
int main()
{
    {
        typedef std::tuple<> T;
        T t0;
        T t = std::move(t0);
        ((void)t); // Prevent unused warning
    }
    {
        typedef std::tuple<MoveOnly> T;
        T t0(MoveOnly(0));
        T t = std::move(t0);
        assert(std::get<0>(t) == 0);
    }
    {
        typedef std::tuple<MoveOnly, MoveOnly> T;
        T t0(MoveOnly(0), MoveOnly(1));
        T t = std::move(t0);
        assert(std::get<0>(t) == 0);
        assert(std::get<1>(t) == 1);
    }
    {
        typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
        T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
        T t = std::move(t0);
        assert(std::get<0>(t) == 0);
        assert(std::get<1>(t) == 1);
        assert(std::get<2>(t) == 2);
    }
    // A bug in tuple caused __tuple_leaf to use its explicit converting constructor
    //  as its move constructor. This tests that ConstructsWithTupleLeaf is not called
    // (w/ __tuple_leaf)
    {
        typedef std::tuple<ConstructsWithTupleLeaf> d_t;
        d_t d((ConstructsWithTupleLeaf()));
        d_t d2(static_cast<d_t &&>(d));
    }
}
void main()
{
	printf("请输入a,b,c的值:\n");
	scanf_s("%f%f%f", &a, &b, &c);
	printf("方程为:%.2fx^2+%.2fx+%.2f\n");
	d = b*b - 4 * a*c;
	if (d > 0){
		d1(a,b);
		printf("x1=%,x2=%f\n", x, y);
	}
	else{
		if (d = 0)
		{
			d2(a,b);
			printf("x=%f\n");
		}
		else
		{
			d3(a,b);
			printf("x1=%f+%fi,x2=%f-%fi\n", x, y);
		}
	}
}