Exemplo n.º 1
0
bool Mobius::branchTermination(QPainter &painter) {

    complex<double> z[3];

    newPoint = mobius(oldPoint, word[level]);
    double dist = distance(oldPoint, newPoint);

    for(int j=0; j<3; j++)  {
        z[j]=mobius(parabolics[tag[level]][j],word[level]);
    }

    if(level >= DEPTH || ((dist<EPSILON) && (distance(z[0],z[1])<EPSILON) && (distance(z[1],z[2])<EPSILON))) {
//    if(level >= DEPTH || dist<EPSILON) {
        //          stroke(0,4*level,250-5*level);
        painter.setPen(QColor(0.0,2*level, 250-(2*level)));
        painter.drawLine(oldPoint.real() * 10.0 + 600, oldPoint.imag() * 10.00 + 450, newPoint.real() * 10.0 + 600, newPoint.imag() * 10.0 + 450 );
        oldPoint=newPoint;
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 2
0
/* Compute cyclotomic polynomial */
ZZX Cyclotomic(long N)
{
  ZZX Num,Den,G,F;
  NTL::set(Num); NTL::set(Den);
  long m,d;
  for (d=1; d<=N; d++)
    { if ((N%d)==0)
         { clear(G);
           SetCoeff(G,N/d,1); SetCoeff(G,0,-1);
           m=mobius(d);
           if (m==1)       { Num*=G; }
           else if (m==-1) { Den*=G; }
         }
    } 
  F=Num/Den;
  return F;
}
Exemplo n.º 3
0
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	if(n>m) n^=m^=n^=m;
	mobius(n);
	long long ans=0,res;
	for(int i=1,last=0;i<=n;i=last+1)
	{
		i=Min(n/(n/i),m/(m/i));
		res=getf(n/i,m/i)%MO;
		res=(res*(i+last+1)*(i-last)/2)%MO;
		ans=(ans+res)%MO;
		last=i;
	}
	printf("%lld",ans);
}
Exemplo n.º 4
0
static void tonemap(TonemapContext *s, AVFrame *out, const AVFrame *in,
                    const AVPixFmtDescriptor *desc, int x, int y, double peak)
{
    const float *r_in = (const float *)(in->data[0] + x * desc->comp[0].step + y * in->linesize[0]);
    const float *b_in = (const float *)(in->data[1] + x * desc->comp[1].step + y * in->linesize[1]);
    const float *g_in = (const float *)(in->data[2] + x * desc->comp[2].step + y * in->linesize[2]);
    float *r_out = (float *)(out->data[0] + x * desc->comp[0].step + y * out->linesize[0]);
    float *b_out = (float *)(out->data[1] + x * desc->comp[1].step + y * out->linesize[1]);
    float *g_out = (float *)(out->data[2] + x * desc->comp[2].step + y * out->linesize[2]);
    float sig, sig_orig;

    /* load values */
    *r_out = *r_in;
    *b_out = *b_in;
    *g_out = *g_in;

    /* desaturate to prevent unnatural colors */
    if (s->desat > 0) {
        float luma = s->coeffs->cr * *r_in + s->coeffs->cg * *g_in + s->coeffs->cb * *b_in;
        float overbright = FFMAX(luma - s->desat, 1e-6) / FFMAX(luma, 1e-6);
        *r_out = MIX(*r_in, luma, overbright);
        *g_out = MIX(*g_in, luma, overbright);
        *b_out = MIX(*b_in, luma, overbright);
    }

    /* pick the brightest component, reducing the value range as necessary
     * to keep the entire signal in range and preventing discoloration due to
     * out-of-bounds clipping */
    sig = FFMAX(FFMAX3(*r_out, *g_out, *b_out), 1e-6);
    sig_orig = sig;

    switch(s->tonemap) {
    default:
    case TONEMAP_NONE:
        // do nothing
        break;
    case TONEMAP_LINEAR:
        sig = sig * s->param / peak;
        break;
    case TONEMAP_GAMMA:
        sig = sig > 0.05f ? pow(sig / peak, 1.0f / s->param)
                          : sig * pow(0.05f / peak, 1.0f / s->param) / 0.05f;
        break;
    case TONEMAP_CLIP:
        sig = av_clipf(sig * s->param, 0, 1.0f);
        break;
    case TONEMAP_HABLE:
        sig = hable(sig) / hable(peak);
        break;
    case TONEMAP_REINHARD:
        sig = sig / (sig + s->param) * (peak + s->param) / peak;
        break;
    case TONEMAP_MOBIUS:
        sig = mobius(sig, s->param, peak);
        break;
    }

    /* apply the computed scale factor to the color,
     * linearly to prevent discoloration */
    *r_out *= sig / sig_orig;
    *g_out *= sig / sig_orig;
    *b_out *= sig / sig_orig;
}