int main() { size_t dx = 2; size_t dim = dx; struct OpeOpts * opts = ope_opts_alloc(LEGENDRE); ope_opts_set_start(opts,3); ope_opts_set_coeffs_check(opts,3); ope_opts_set_maxnum(opts,3); struct OneApproxOpts * qmopts = one_approx_opts_alloc(POLYNOMIAL,opts); struct C3Approx * c3a = c3approx_create(CROSS,dim); int verbose = 1; size_t init_rank = 4; double ** start = malloc_dd(dim); for (size_t ii = 0; ii < dim; ii++){ c3approx_set_approx_opts_dim(c3a,ii,qmopts); start[ii] = linspace(-1.0,1.0,init_rank); } c3approx_init_cross(c3a,init_rank,verbose,start); c3approx_set_cross_tol(c3a,1e-4); c3approx_set_round_tol(c3a,1e-4); size_t counter = 0; struct Fwrap * fw = fwrap_create(dx,"general"); fwrap_set_f(fw,doug,&counter); struct FunctionTrain * f = c3approx_do_cross(c3a,fw,1); free_dd(dim,start); one_approx_opts_free_deep(&qmopts); c3approx_destroy(c3a); fwrap_destroy(fw); printf("ranks are "); iprint_sz(3,f->ranks); printf("Number of evaluations is %zu\n",counter); double derr = 0.0; double dden = 0.0; size_t N = 100; double * xtest = linspace(-1.0,1.0,N); size_t ii,jj; double x[2]; size_t counter2 = 0; for (ii = 0; ii < N; ii++){ for(jj = 0; jj < N; jj++){ x[0] = xtest[ii]; x[1] = xtest[jj]; double tval = doug(x,&counter2); double aval = function_train_eval(f,x); derr += pow(tval-aval,2); dden += pow(tval,2); } } printf("L2 error for displacement is %G\n",derr/dden); function_train_free(f); return 0; }
main() { printf("%d\n", crappy_max(100, 200)); printf("%d\n", crappy_max(200, 200)); printf("%d\n", crappy_max(200, 100)); printf("%d\n", crappy_max(100, 100)); printf("%d %s\n", args(3)); /* recursive substiution support is important */ printf("%d\n", doug(bob(123,456), doug(123, 456))); printf("%d\n", bob(123,456)); printf("%d\n", bob( bob(123,456), bob(123,456) )); printf("%d\n", bob( bob(bob(123,456),456), bob(123,456) )); printf("%d\n", bob( bob(bob(123,bob(123,456)),456), bob(123,456) )); /* XXX: this one doesn't work yet */ /* printf("%d\n", bob( bob(123,456), bob(123,456) )); */ }