diff options
author | jthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416> | 2002-05-14 14:01:06 +0000 |
---|---|---|
committer | jthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416> | 2002-05-14 14:01:06 +0000 |
commit | c6aa3bd37e89ab1a1f415d5ed9fa286d5a426854 (patch) | |
tree | c2ced1767c00322cdf5a913f1ca63a276368a3a8 /src/GeneralizedPolynomial-Uniform/interpolate.maple | |
parent | ae63009d6b13773dd6cd4ff4c9552d0e2c9fad39 (diff) |
There are 3 changes in this commit
* Add code to print C assignments of the form
COEFF(-1,1) = coeff_dx_m1_p1;
etc
* change all functions which print to name files to now explicit close
the files when they're done -- previously we just left the files open,
and relied on Maple's implicit close-on-exit :(
* reformat whitespace in [123]d.maple
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalInterp/trunk@36 df1f8a13-aa1d-4dd4-9681-27ded5b42416
Diffstat (limited to 'src/GeneralizedPolynomial-Uniform/interpolate.maple')
-rw-r--r-- | src/GeneralizedPolynomial-Uniform/interpolate.maple | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/GeneralizedPolynomial-Uniform/interpolate.maple b/src/GeneralizedPolynomial-Uniform/interpolate.maple index 51ecf0a..7f401af 100644 --- a/src/GeneralizedPolynomial-Uniform/interpolate.maple +++ b/src/GeneralizedPolynomial-Uniform/interpolate.maple @@ -8,6 +8,7 @@ # # print_coeff__lc_of_data - print C code to compute coefficients # print_data_var_assign - print C code to assign data-value variables +# print_interp_coeff_var_store - print C code to store coeff vars "somewhere" # print_interp_cmpt__lc_of_data - print C code for computation of interpolant # # coeff_name - name of coefficient of data at a given [m] coordinate @@ -186,6 +187,8 @@ fi; # now print the optimized computation sequence codegen[C](cmpt_list, filename=file_name); +fclose(file_name); + NULL; end proc; @@ -193,7 +196,8 @@ end proc; # # This function prints a sequence of C expression to assign the data-value -# variables. +# variables, eg +# data_m1_p1 = DATA(-1,1); # # Arguments: # posn_list = The same list of positions as was used to compute the @@ -210,7 +214,6 @@ proc( ) ftruncate(file_name); - map( proc(posn::list(numeric)) fprintf(file_name, @@ -221,6 +224,44 @@ map( , posn_list ); +fclose(file_name); + +NULL; +end proc; + +################################################################################ + +# +# This function prints a sequence of C expression to assign the interpolation +# coefficients to COEFF(...) expressions, eg +# COEFF(1,-1) = coeff_dx_p1_m1 +# +# Arguments: +# posn_list = The same list of positions as was used to compute the +# interpolating polynomial. +# coeff_name_prefix = A prefix string for the coefficient names. +# file_name = The file name to write the coefficients to. This is +# truncated before writing. +# +print_interp_coeff_var_store := +proc( + posn_list::list(list(numeric)), + coeff_name_prefix::string, + file_name::string + ) + +ftruncate(file_name); +map( + proc(posn::list(numeric)) + fprintf(file_name, + "%a = %s;\n", + 'COEFF'(op(posn)), + coeff_name(posn,coeff_name_prefix)); + end proc + , + posn_list + ); +fclose(file_name); NULL; end proc; @@ -253,6 +294,7 @@ proc( ) ftruncate(file_name); + fprintf(file_name, "%s =\n", result_var_name); # list of "coeff*data_var" terms @@ -268,8 +310,10 @@ map( ListTools[Join](%, "\n\t+ "); cat(op(%)); - fprintf(file_name, "\t%s;\n", %); + +fclose(file_name); + NULL; end proc; |