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


C++ Traits::pseudo_remainder_object方法代码示例

本文整理汇总了C++中Traits::pseudo_remainder_object方法的典型用法代码示例。如果您正苦于以下问题:C++ Traits::pseudo_remainder_object方法的具体用法?C++ Traits::pseudo_remainder_object怎么用?C++ Traits::pseudo_remainder_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Traits的用法示例。


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

示例1: test_polynomial

void test_polynomial(const Traits &tr)
{
  typedef typename Traits::Construct_function CF;
  typedef typename Traits::Function Polynomial;
  typedef typename Polynomial::NT NT;

  CF cf= tr.construct_function_object();

  NT v[] = {-1, 2, 27, -17, 0, 0};
  //  NT v[] = {0, 0, 0, 0, 0, 0};

  Polynomial p(v, v+6);
  Polynomial q(v, v+3);

  NT a(2);

  write_variable( "p", p);
  write_variable("q", q );

  write("-p", (-p));
  check_equal<Traits>(-p , cf(1,-2,-27,17));

  write("p-p",(p-p));
  check_equal<Traits>(p-p , cf(0));

  write("p+q" , (p+q) );
  check_equal<Traits>(p+q , cf( -2, 4, 54, -17));

  write("p-q" , (p-q));
  check_equal<Traits>(p-q , cf(0,0,0,-17));

  write("q*(p-q)" , q*(p-q) );
  check_equal<Traits>(q*(p-q) , cf(0,0,0,17,-34,-459));

  write_variable( "a", a);

  Polynomial diff(p-q);
  Polynomial dp(diff +Polynomial(a));

  write("(p-q)+a" , dp );
  check_equal<Traits>((p-q)+Polynomial(a) , cf(2, 0, 0, -17));

  write("(p-q)-a" , ((p-q)-a) );
  check_equal<Traits>((p-q)-Polynomial(a) , cf(-2, 0, 0, -17));

  write("a*(p-q)" , (a*(p-q)) );
  check_equal<Traits>((Polynomial(a)*(p-q)) , cf(0,0,0,-34));

  write("(p-q)*a" , ((p-q)*a) );
  check_equal<Traits>(((p-q)*Polynomial(a)) , cf(0,0,0,-34));

  write("(p-q)/a" , ((p-q)/a) );
  check_equal<Traits>((Polynomial(p-q)/a) , cf(0,0,0,-NT(.5)*NT(17)));

  write("subs(t=-t, p)", tr.negate_variable_object()(p) );
  check_equal<Traits>(tr.negate_variable_object()(p) , cf( -1, -2, 27, 17));

  /*write("t^degree(p) * subs(t=(1/t), p)", tr.invert_variable_object()(p) );
    check_equal<Traits>( tr.invert_variable_object()(p) , cf(-17, 27, 2, -1));*/


  NT v1[] = {-1, 1};
  NT v2[] = {-2, 1};

  Polynomial r = Polynomial(v1, v1+2);
  Polynomial s = Polynomial(v2, v2+2);

  p = r * r * s + Polynomial(NT(1));
  write_variable( "p", p);
  check_equal<Traits>(p , cf(-1, 5, -4, 1));

  q = r * s;
  write_variable("q", q );
  check_equal<Traits>(q , cf( 2, -3, 1));

  write("rem(p,q,t)",
        tr.remainder_object()(p,q) );
  check_equal<Traits>(tr.remainder_object()(p,q) , cf(1));

  write("prem(p,q,t)",
        tr.pseudo_remainder_object()(p,q) );
  check_equal<Traits>(tr.pseudo_remainder_object()(p,q) , cf(1));

  write("quo(p,q,t)",
        tr.quotient_object()(p,q) );
  check_equal<Traits>(tr.quotient_object()(p,q) , cf(-1,1));

  write("pquo(p,q,t)",
        tr.pseudo_quotient_object()(p,q) );
  check_equal<Traits>(tr.pseudo_quotient_object()(p,q) , cf(-1,1));

  p = r * r * s * s * s;
  write_variable( "p", p);
  check_equal<Traits>(p , cf(-8, 28, -38, 25, -8, 1));

  q = r * s;
  write_variable("q", q );
  check_equal<Traits>(q , cf(2,-3,1));

  write("rem(p,q,t)",
//.........这里部分代码省略.........
开发者ID:ArcEarth,项目名称:cgal,代码行数:101,代码来源:polynomial.cpp


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