コード例 #1
0
 void teste( int bits, double c1, int e1, double c2, int e2 )
  {
   int exact = arrondi(c1*e1+c2*e2) ;
   Coef coef1(bits), coef2(bits) ;
   coef1 = c1 ;
   coef2 = c2 ;
   int approx = coef1*e1 + coef2*e2 ;
   erreur(bits,exact,approx) ;
   std::cout<<std::endl ;
  }
コード例 #2
0
 void teste( int bits, double c1, int e1, double c2, int e2 )
  {
   int exact = arrondi(c1*e1+c2*e2) ;
   Coef coef1(bits), coef2(bits) ;
   coef1.approxime(c1) ;
   coef2.approxime(c2) ;
   int approx = coef1.multiplie(e1) + coef2.multiplie(e2) ;
   erreur(bits,exact,approx) ;
   std::cout<<std::endl ;
  }
コード例 #3
0
 virtual void execute( int bits )
  {
   Coef<U> coef1(bits), coef2(bits) ;
   for ( int i=0 ; i<nb_ ; ++i )
    {
     coef1 = num_[i] ; coef2 = (1-num_[i]) ;
     exact_[i] = 200. ;
     approx_[i] = arrondi(coef1*U(exact_[i]) + coef2*U(exact_[i]),3) ;
    }
   erreur(bits) ;
  }
コード例 #4
0
    void create_curve_test()
    {
      eli::geom::curve::piecewise_polynomial_creator<data_type, 3, tolerance_type> ppc;
      piecewise_curve_type pc;
      polynomial_type c;
      coefficient_type coef1(5), coef2(2);
      point_type eval_out, eval_ref;
      data_type t, t0, t1;
      bool rtn_flag;

      // set coefficients
      coef1 << 2, 4, 3, 1, 2;
      coef2 << 1, 1;
      c.set_coefficients(coef1, 0);
      c.set_coefficients(coef2, 1);

      // set the parameterization
      t0=-1;
      t1=1;

      // create curve
      rtn_flag=ppc.set_conditions(c);
      TEST_ASSERT(rtn_flag);
      ppc.set_t0(t0);
      ppc.set_segment_dt(t1-t0, 0);
      rtn_flag=ppc.create(pc);
      TEST_ASSERT(rtn_flag);

      // test evaluation at ends
      t=t0;
      eval_out=pc.f(t);
      eval_ref=c.f((t-t0)/(t1-t0));
      TEST_ASSERT(tol.approximately_equal(eval_out, eval_ref));
      t=t1;
      eval_out=pc.f(t);
      eval_ref=c.f((t-t0)/(t1-t0));
      TEST_ASSERT(tol.approximately_equal(eval_out, eval_ref));

      // test evaluation at interior point
      t=(t1-t0)*static_cast<data_type>(0.2)+t0;
      eval_out=pc.f(t);
      eval_ref=c.f((t-t0)/(t1-t0));
      TEST_ASSERT(tol.approximately_equal(eval_out, eval_ref));

//      if (typeid(data_type)==typeid(float))
//      {
//        std::cout.flush();
//        eli::test::octave_start(1);
//        eli::test::octave_print(1, c, "poly");
//        eli::test::octave_print(1, pc, "piecewise");
//        eli::test::octave_finish(1, false);
//      }
    }
コード例 #5
0
    void full_cycle_test()
    {
      eli::geom::curve::piecewise_polynomial_creator<data_type, 3, tolerance_type> ppc;
      piecewise_curve_type pc;
      polynomial_type c;
      coefficient_type coef1(5), coef2(2);
      point_type eval_out, eval_ref;
      data_type t0, t1;
      bool rtn_flag;

      // set coefficients
      coef1 << 2, 4, 3, 1, 2;
      coef2 << 1, 1;
      c.set_coefficients(coef1, 0);
      c.set_coefficients(coef2, 1);

      // set the parameterization
      t0=-1;
      t1=1;

      // create curve
      rtn_flag=ppc.set_conditions(c);
      TEST_ASSERT(rtn_flag);
      ppc.set_t0(t0);
      ppc.set_segment_dt(t1-t0, 0);
      rtn_flag=ppc.create(pc);
      TEST_ASSERT(rtn_flag);

      // extract the curve and obtain the monomial coefficients
      curve_type crv;
      typename curve_type::monomial_coefficient_type coef_out;

      pc.get(crv, 0);
      crv.get_monomial_coefficients(coef_out);

      // test the coefficients
      index_type i;

      i=0;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 0), coef1(i)));
      i=1;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 0), coef1(i)));
      i=2;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 0), coef1(i)));
      i=3;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 0), coef1(i)));
      i=4;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 0), coef1(i)));

      i=0;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 1), coef2(i)));
      i=1;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 1), coef2(i)));
      i=2;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 1), 0));
      i=3;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 1), 0));
      i=4;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 1), 0));

      i=0;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 2), 0));
      i=1;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 2), 0));
      i=2;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 2), 0));
      i=3;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 2), 0));
      i=4;
      TEST_ASSERT(tol.approximately_equal(coef_out(i, 2), 0));
    }