Exemplo n.º 1
0
__complex128
clog10q (__complex128 z)
{
  __complex128 v;
  COMPLEX_ASSIGN (v, log10q (cabsq (z)), cargq (z));
  return v;
}
Exemplo n.º 2
0
inline void eval_log10(float128_backend& result, const float128_backend& arg)
{
   result.value() = log10q(arg.value());
}
Exemplo n.º 3
0
void curve_convergence(long double ax1, long double ay1, long double bx1, long double by1, long double anonlin, int numpoints, int time, int fnum, int preshift, double (*points)[2]) {

    FILE *f;

    const char name[] = "outputs/text_quasi_curve_t%u_np%u_ax%.2Lf_ay%.2Lf_bx%.2Lf_by%.2Lf.txt";
    char fname[100];
    sprintf(fname, name, time,numpoints,ax1,ay1,bx1,by1);
    f= fopen(fname,"w");

    int t, v;
    __float128 wsum=0;
    for(t=0; t<time; t++) {
        wsum += weight((__float128)t/(__float128)time);
    }

    __float128 ax = ax1;
    __float128 bx = bx1;
    __float128 ay = ay1;
    __float128 by = by1;

    __float128 x,y, xn, yn;
    __float128 first[fnum];
    __float128 second[fnum];
    __float128 diff[fnum];
    __float128 diff_mag;
    __float128 numzeros;
    __float128 wvar;

    __float128 nonlin=anonlin;
    
    for(int p=0; p < numpoints; p++) {
        x = ax + (bx-ax)*((__float128)p/(__float128)numpoints);
        y = ay + (by-ay)*((__float128)p/(__float128)numpoints);
        fprintf(f,"x: %.10Lf, y: %.10Lf, ", (long double)x, (long double)y);
        for(int s=0; s < preshift; s++) {
            for(t=0; t< time; t++) {
                xn = smod(x+y,2.Q*M_PIq);
                yn = smod(nonlin*sinq(x+y)+y,2.Q*M_PIq);
                x = xn;
                y = yn;
            }
        }

        memset(first, 0, sizeof(__float128)*fnum);
        for( t=0; t<time; t++) {
            wvar = weight((__float128)t/(__float128)time);

            for(v=0; v<fnum;v++) {
                first[v] += (*fvec[v])(x,y)*wvar;
            }
            xn = smod(x+y,2.Q*M_PIq);
            yn = smod(nonlin*sinq(x+y)+y,2.Q*M_PIq);
            x = xn;
            y = yn;
        }

        memset(second,0,sizeof(__float128)*fnum);

        for( t=0; t <time; t++) {
            wvar = weight((__float128)t/(__float128)time);


            for(v=0; v<fnum;v++) {
                second[v]+= (*fvec[v])(x,y)*wvar;
            }
            xn = smod(x+y,2.Q*M_PIq);
            yn = smod(nonlin*sinq(x+y)+y,2.Q*M_PIq);
            x = xn;
            y = yn;
        }
        diff_mag=0.Q;
        for(v=0; v<fnum; v++) {
            diff[v]=(second[v]-first[v])/wsum;
            diff_mag+=diff[v]*diff[v];
        }
        diff_mag = sqrtq(diff_mag);
        numzeros = (__float128)(-1.Q*log10q(diff_mag));
        fprintf(f,"numzeros: %.12Lf\n",(long double)numzeros);
        points[p][0] = (double)p/(__float128)numpoints;
        points[p][1] = (double)numzeros;
        printf("numzeros: %.20Lf\n",(long double)numzeros);
    }

}
Exemplo n.º 4
0
void convergence(int rows, int cols, int time, long double aleastx, long double aleasty,
        long double adeltax, long double adeltay, int fnum, char (*m)[cols]) {
    printf("Running Optimized Version of Quasiperiodicity\n");
    unsigned int i, j, t, v;
    
    FILE *f;
    const char name[] = "outputs/text_optquasi_conv_t%u_g%u_xs%.2Lf_ys%.2Lf_xb%.2Lf_yb%.2Lf.txt";
    char fname[100];
    sprintf(fname, name, time,rows, aleastx, aleasty, aleastx+rows*adeltax,aleasty+cols*adeltay);
    f= fopen(fname,"w");
    fprintf(f,"ONLY BOX IS CERTAIN\n\n");
    unsigned int** traj = (unsigned int**) malloc(sizeof(unsigned int*)*time);
    int ntraj=0;
    for(int o=0; o < time; o++) {
        traj[o] = (unsigned int*) malloc(sizeof(unsigned int)*2);
    }
    __float128  wsum=0;
    for(t=0; t<time; t++) {
        wsum += weight((__float128)t/(__float128)time);
    }

    __float128  x,y, xn, yn;
    __float128  first[fnum];
    __float128  second[fnum];
    __float128  diff[fnum];
    __float128  diff_mag;
    char numzeros;
    __float128  wvar;


    __float128 leastx = aleastx;
    __float128 leasty = aleasty;
    __float128 deltax = adeltax;
    __float128 deltay = adeltay;



    for(i=0; i < rows; i++) {
        printf("i is: %u\n", i);
        for(j=0; j < cols; j++) {
            if(m[i][j]==-1) {
                ntraj++;
                x = leastx + j*deltax+0.5*deltax;
                y = leasty + i*deltay+0.5*deltay;
                memset(first, 0, sizeof(__float128)*fnum);
                for( t=0; t<time; t++) {
                    wvar = weight((__float128)t/(__float128)time);

                    for(v=0; v<fnum;v++) {
                        first[v] += (*fvec[v])(x,y)*wvar;
                    }
                    xn = smod(x+y,2.Q*M_PIq);
                    yn = smod(1.4Q*sinq(x+y)+y,2.Q*M_PIq);
                    traj[t][0] = floorq((x-leastx)/deltax);
                    traj[t][1] = floorq((y-leasty)/deltay);
                    x = xn;
                    y = yn;
                }

                memset(second,0,sizeof(__float128)*fnum);

                for( t=0; t <time; t++) {
                    wvar = weight((__float128)t/(__float128)time);


                    for(v=0; v<fnum;v++) {
                        second[v]+= (*fvec[v])(x,y)*wvar;
                    }
                    xn = smod(x+y,2.Q*M_PIq);
                    yn = smod(1.4Q*sinq(x+y)+y,2.Q*M_PIq);
                    x = xn;
                    y = yn;
                }
                diff_mag=0.Q;
                for(v=0; v<fnum; v++) {
                    diff[v]=(second[v]-first[v])/wsum;
                    diff_mag+=diff[v]*diff[v];
                }
                diff_mag = sqrtq(diff_mag);
                numzeros = (char)(-1.Q*log10q(diff_mag));
                for(t=0;t<time;t++) {
                    m[(int)fmin(fmax(traj[t][1],0),rows-1)][(int)fmin(fmax(traj[t][0],0),cols-1)] = numzeros;
                }
                //m[i][j]=(unsigned char)numzeros; (old way)
            }
        }
    }
    for(int o=0; o< time; o++) {
        free(traj[o]);
    }
    free(traj);
    for(int i=0; i<rows; i++) {
        for(int j=0; j<cols; j++) {
            fprintf(f, "m[%u][%u] is %d",i,j,m[i][j]);
        }
    }

    printf("%u\n",m[8][8]);
}