Ejemplo n.º 1
0
void UniDivFC(poly_fc & q,poly_fc & f,poly_fc & g)
{
	poly_fc r;
	int k,n;
	r.resize(f.size());
	for(int i=0;i<f.size();i++)mpfc_set(r[i],f[i]);
	n=g.size()-1;
	k=r.size()-g.size();
	if(k<0)
	{
		q.resize(0);return;
	}
	q.resize(k+1);
	mpfc_t t;
	mpfc_init(t);
	do 
	{
		mpfc_div(q[k],r[n+k],g[n]);
		if(!mpfc_iszero(q[k]))
		{
			for(int i=0;i<n;i++)
			{
				uint j=n+k-1-i;
				mpfc_mul(t,q[k],g[j-k]);
				mpfc_sub(r[j],r[j],t);
			}
		}
	} while (k--);
	mpfc_clear(t);
	r.resize(0);
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 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 ;
}
Ejemplo n.º 4
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 ;
}
Ejemplo n.º 5
0
inline void complexAP::operator =(complexAP c)
{
  mpfc_set(&value, &c.value);
}
Ejemplo n.º 6
0
 void set(elem &result, elem a) const { mpfc_set(&result, &a); }