Пример #1
0
void UniMulFC(poly_fc & r,poly_fc & f,poly_fc & g)
{
	uint sa=f.size(),sb=g.size();
	if(sa==0||sb==0)
	{
		r.resize(0);
		return ;
	}
	uint sx = sa+sb-1;
	r.resize(sx);
	int i, j, jmin, jmax;
	static mpfc_t t, accum;
	mpfc_init(t); mpfc_init(accum);
	for (i = 0; i < sx; i++) {
		jmin = std::max<int>(0, i-sb+1);
		jmax = std::min<int>(sa-1, i);
		mpfc_set_ui(accum,0);
		for (j = jmin; j <= jmax; j++) {
			mpfc_mul(t, f[j], g[i-j]);
			mpfc_add(accum, accum, t);
		}
		mpfc_set(r[i], accum);
	}
	mpfc_clear(t); mpfc_clear(accum);
}
Пример #2
0
void UniEvalFC(mpfc_ptr r,poly_fc & f,mpfc_ptr x)
{
	uint i=f.size()-1;
	mpfc_set(r,f[i]);
	if(i==0)return ;
	--i;
	while(1)
	{
		mpfc_mul(r,r,x);
		mpfc_add(r,r,f[i]);
		if(i==0)break;
		--i;
	}
	return ;
}
Пример #3
0
void UniAddFC(poly_fc & r,poly_fc & f,poly_fc & g)
{
	int sf=f.size(),sg=g.size(),ms=std::min<int>(sf,sg);
	r.resize(std::max<int>(sf,sg));
	for(int i=0;i<ms;i++)mpfc_add(r[i],f[i],g[i]);
	if(sf<sg)
	{
		for(int i=ms;i<sg;i++)mpfc_set(r[i],g[i]);
	}
	else
	{
		for(int i=ms;i<sf;i++)mpfc_set(r[i],f[i]);
	}
	if(sf==sg)r.normalize();
	return ;
}
Пример #4
0
inline complexAP& complexAP::operator +=( complexAP c)
{
  mpfc_add(&value, &value, &c.value);
  return *this;
}
Пример #5
0
inline complexAP complexAP::operator +( complexAP c)
{
  complexAP tmp;
  mpfc_add(&tmp.value, &value, &c.value);
  return tmp;
}
Пример #6
0
 void add(elem &result, elem a, elem b) const { mpfc_add(&result,&a,&b); }