Exemple #1
0
Expression *checkGC(Scope *sc, Expression *e)
{
    FuncDeclaration *f = sc->func;
    if (e && e->op != TOKerror &&
        f && sc->intypeof != 1 && !(sc->flags & SCOPEctfe) &&
        (f->type->ty == Tfunction && ((TypeFunction *)f->type)->isnogc ||
         (f->flags & FUNCFLAGnogcInprocess) ||
         global.params.vgc))
    {
        NOGCVisitor gcv(f);
        walkPostorder(e, &gcv);
        if (gcv.err)
            return new ErrorExp();
    }
    return e;
}
Exemple #2
0
void freepsgold(int* sampsize, double* xdata, double* ydata, int* ord,
      int* numknot, int* initseed, int* initstream, double* lambda,
      double* optknot, double* trace_hat, double* GCV, double* GSJS_value)
{
int i, order, n, nobs, inform, seed, stream;

double bestlambda;
double shift, scale;

struct L2_1D_DATA * origdat, * sortdat;

struct SP_1D * best_sp;

/*  set order and dimension for spline, seed, and stream */

order = *ord;
n = *numknot;
n += order;
seed = *initseed;
stream = *initstream;
  
/* load data into data struct */
origdat = data_1d_initialize(*sampsize, &inform);

for(i=0; i<*sampsize; i++)
{
    origdat->xdata[i] = xdata[i];
    origdat->ydata[i] = ydata[i];
}

nobs = origdat->nobs;

sortdat = data_1d_initialize(nobs, &inform);
dat_psgold = data_1d_initialize(nobs, &inform);
sort_data(origdat, sortdat);
scale_data(sortdat, dat_psgold, &shift, &scale);

sp_psgold = sp_1d_initialize( order, n,  &inform);
sp_1d_set_knots(sp_psgold, 0., 1.);
best_sp = sp_1d_initialize( order, n,  &inform);
sp_1d_set_knots(best_sp, 0., 1.);

bestlambda = slave_psgold(shift, scale, seed, stream);

/* Save information */
/* Lambda */
*lambda = bestlambda * pow(scale, 2*sp_psgold->order-2);

/* Optimal knots */ 
for (i = 0; i <*numknot; i++)
    optknot[i] = shift + scale * sp_psgold->knot[i+*ord];

/* trace of hat matrix */
*trace_hat = trace_hat_matrix(dat_psgold, sp_psgold, bestlambda);

/* GCV */
*GCV = gcv(dat_psgold, sp_psgold, bestlambda, MIN_SPACE_PSGOLD);

/* GSJS */
*GSJS_value = GSJS(dat_psgold);
}