コード例 #1
0
double BC_lin(double *f, int j, int N, double* x, int *BC){
	double d1, d2;
	if (j == N-1){ // approximate the end points linearly
		d1 = d2dx2(f, N-3, N, x, BC);
		d2 = d2dx2(f, N-2, N, x, BC);
		return ((x[N-1] - x[N-2])/(x[N-3] - x[N-2])) * (d1 - d2) + d2;
	} else if (j == 0){
		d1 = d2dx2(f, 1, N, x, BC);
		d2 = d2dx2(f, 2, N, x, BC);
		return (x[0] - x[1])/(x[2] - x[1]) * (d2 - d1) + d1;
	} else {
		return 0;
	}
}
コード例 #2
0
/* R interface for d2dx2. Returns array of derivatives
*/
void d2dx2_R(double *f, int *N, double* x, int* BC, double* result){
	int j;
	
	for (j = 0; j < N[0]; j++){
		result[j] = d2dx2(f, j, N[0], x, BC);
	}
}
コード例 #3
0
ファイル: recombine.c プロジェクト: bgreer/smc
void recombine_level (int l)
{
    int i, j, count, done;
    /* sweep right */
    count= 0;
    done = 0;
    for (i=N-1; i>0; i--) /* search for first relevant point */
    {
        if (sd[i+1] == l/2 && sd[i] == l)
        {
            /* Look for points to the right that need recombination */
            count = 0;
            while (sd[i-count]==l && fabs(dx*dx*d2dx2(Tm,i-count)/(sd[i-count]*sd[i-count]))<1e-6)
                count++;
            i -= count;
            if (count>10) {
                done = 1;
                printf("count = %d, %d, %d\n", count, i, l);
            }
        }
    }
    if (done && 0)
    {
        output_state("state", 0);
        exit(0);
    }
}