aboutsummaryrefslogtreecommitdiff
path: root/src/GeneralizedPolynomial-Uniform/interpolate.maple
diff options
context:
space:
mode:
authorjthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416>2002-09-02 10:22:52 +0000
committerjthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416>2002-09-02 10:22:52 +0000
commit829a7c06be671391415df5774fc82ac245be4b1a (patch)
tree87904ea29a49868d26e53d1a4f87ea9ae089795f /src/GeneralizedPolynomial-Uniform/interpolate.maple
parent99d21c918b38d15d6974e7b2f1e8dacf32b39105 (diff)
This is a major reworking of this interpolator.
The interpolation code in template.c is now split up into subfunctions (in common/, Lagrange/, and Hermite/), so it should now compile in finite cpu/memory even with optimization. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalInterp/trunk@113 df1f8a13-aa1d-4dd4-9681-27ded5b42416
Diffstat (limited to 'src/GeneralizedPolynomial-Uniform/interpolate.maple')
-rw-r--r--src/GeneralizedPolynomial-Uniform/interpolate.maple70
1 files changed, 24 insertions, 46 deletions
diff --git a/src/GeneralizedPolynomial-Uniform/interpolate.maple b/src/GeneralizedPolynomial-Uniform/interpolate.maple
index 71280fe..7337648 100644
--- a/src/GeneralizedPolynomial-Uniform/interpolate.maple
+++ b/src/GeneralizedPolynomial-Uniform/interpolate.maple
@@ -5,11 +5,11 @@
# <<<representation of numbers, data values, etc>>>
# Lagrange_polynomial_interpolant - compute Lagrange polynomial interpolant
# Hermite_polynomial_interpolant - compute Hermite polynomial interpolant
-# coeff_as_lc_of_data - coefficients of ... (linear combination of data)
+# coeffs_as_lc_of_data - coefficients of ... (linear combination of data)
#
-# 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_coeffs__lc_of_data - print C code to compute coefficients
+# print_fetch_data - print C code to fetch input array chunk into struct data
+# print_store_coeffs - print C code to store struct coeffs "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
@@ -257,7 +257,7 @@ end proc;
# form COEFF(...) = value , where each value is a polynomial in the
# coordinates. The order of the list matches that of posn_list.
#
-coeff_as_lc_of_data :=
+coeffs_as_lc_of_data :=
proc(
interpolant::algebraic,
posn_list::list(list(numeric))
@@ -291,14 +291,14 @@ end proc;
#
# Arguments:
# coeff_list = A list of the coefficients, as returned from
-# coeff_as_lc_of_data() .
+# coeffs_as_lc_of_data() .
# coeff_name_prefix = A prefix string for the coefficient names.
# temp_name_type = The C type to be used for Maple-introduced temporary
# names, eg. "double".
# file_name = The file name to write the coefficients to. This is
# truncated before writing.
#
-print_coeff__lc_of_data :=
+print_coeffs__lc_of_data :=
proc( coeff_list::list(specfunc(numeric,COEFF) = algebraic),
coeff_name_prefix::string,
temp_name_type::string,
@@ -357,7 +357,7 @@ end proc;
#
# This function prints a sequence of C expression to assign the data-value
# variables, eg
-# data_m1_p1 = DATA(-1,1);
+# data->data_m1_p1 = DATA(-1,1);
#
# Arguments:
# posn_list = The same list of positions as was used to compute the
@@ -366,7 +366,7 @@ end proc;
# file_name = The file name to write the coefficients to. This is
# truncated before writing.
#
-print_data_var_assign :=
+print_fetch_data :=
proc(
posn_list::list(list(numeric)),
data_var_name_prefix::string,
@@ -394,25 +394,18 @@ end proc;
#
# This function prints a sequence of C expression to store the interpolation
# coefficients in COEFF(...) expressions, eg
-# COEFF(1,-1) = factor * coeff_dx_p1_m1;
+# COEFF(1,-1) = factor * coeffs->coeff_p1_m1;
#
# Arguments:
-# posn_list = The same list of positions as was used to compute the
-# interpolating polynomial.
-# RHS_factor_name = If this string is non-empty, then the coefficient is
-# multiplied by this factor before being stored, eg
-# setting this to "factor" would give the example above.
-# If this string is empty (""), the multiplication is
-# omitted, eg
-# COEFF(1,-1) = coeff_dx_p1_m1;
-# coeff_name_prefix = A prefix string for the coefficient names.
+# posn_list = The list of positions in the molecule.
+# coeff_name_prefix = A prefix string for the coefficient names,
+# eg "factor * coeffs->coeff_"
# file_name = The file name to write the coefficients to. This is
# truncated before writing.
#
-print_interp_coeff_var_store :=
+print_store_coeffs :=
proc(
posn_list::list(list(numeric)),
- RHS_factor_name::string,
coeff_name_prefix::string,
file_name::string
)
@@ -420,17 +413,10 @@ proc(
ftruncate(file_name);
map(
proc(posn::list(numeric))
- if (length(RHS_factor_name) > 0)
- then fprintf(file_name,
- "%a = %s * %s;\n",
- 'COEFF'(op(posn)),
- RHS_factor_name,
- coeff_name(posn,coeff_name_prefix));
- else fprintf(file_name,
- "%a = %s;\n",
- 'COEFF'(op(posn)),
- coeff_name(posn,coeff_name_prefix));
- end if;
+ fprintf(file_name,
+ "%a = %s;\n",
+ 'COEFF'(op(posn)),
+ coeff_name(posn,coeff_name_prefix));
end proc
,
posn_list
@@ -443,25 +429,19 @@ end proc;
################################################################################
#
-# This function prints a C expression to compute the interpolant,
-# using the coefficients computed by print_coeff__lc_of_data()
-# (i.e. expressing the interpolant as a linear combination of the
-# data values).
+# This function prints a C expression to evaluate a molecule, i.e.
+# to compute the molecule as a linear combination of the data values.
#
# Arguments:
-# posn_list = The same list of positions as was used to compute the
-# interpolating polynomial.
-# result_var_name = The (string) name of the variable to which the
-# result is to be assigned.
+# posn_list = The list of positions in the molecule.
# coeff_name_prefix = A prefix string for the coefficient names.
# data_var_name_prefix = A prefix string for the data variable names.
# file_name = The file name to write the coefficients to. This is
# truncated before writing.
#
-print_interp_cmpt__lc_of_data :=
+print_evaluate_molecule :=
proc(
posn_list::list(list(numeric)),
- result_var_name::string,
coeff_name_prefix::string,
data_var_name_prefix::string,
file_name::string
@@ -469,8 +449,6 @@ proc(
ftruncate(file_name);
-fprintf(file_name, "%s =\n", result_var_name);
-
# list of "coeff*data_var" terms
map(
proc(posn::list(numeric))
@@ -482,9 +460,9 @@ map(
posn_list
);
-ListTools[Join](%, "\n\t+ ");
+ListTools[Join](%, "\n + ");
cat(op(%));
-fprintf(file_name, "\t%s;\n", %);
+fprintf(file_name, " %s;\n", %);
fclose(file_name);