Small bug fix in TransFarToFar: the order of the approximation was set to 0, but it really should have been set to the order of the translated expansion
This commit is contained in:
@@ -445,6 +445,9 @@ template<typename TKernel>
|
||||
void SeriesExpansion<TKernel>::PrintDebug(const char *name,
|
||||
FILE *stream) const {
|
||||
|
||||
int dim = sea_->get_dimension();
|
||||
int total_num_coeffs = sea_->get_total_num_coeffs(order_);
|
||||
|
||||
fprintf(stream, "----- SERIESEXPANSION %s ------\n", name);
|
||||
fprintf(stream, "Expansion type: %s\n", (expansion_type_ == FARFIELD) ?
|
||||
"FARFIELD":"LOCAL");
|
||||
@@ -455,8 +458,29 @@ void SeriesExpansion<TKernel>::PrintDebug(const char *name,
|
||||
}
|
||||
fprintf(stream, "\n");
|
||||
|
||||
for (index_t i = 0; i < coeffs_.length(); i++) {
|
||||
fprintf(stream, "%g ", coeffs_[i]);
|
||||
fprintf(stream, "f(");
|
||||
for(index_t d = 0; d < dim; d++) {
|
||||
fprintf(stream, "x_%d", d);
|
||||
if(d < dim - 1)
|
||||
fprintf(stream, ",");
|
||||
}
|
||||
fprintf(stream, ") = ");
|
||||
|
||||
for (index_t i = 0; i < total_num_coeffs; i++) {
|
||||
ArrayList<int> mapping = sea_->get_multiindex(i);
|
||||
if(expansion_type_ == FARFIELD) {
|
||||
fprintf(stream, "%g", coeffs_[i]);
|
||||
|
||||
for(index_t d = 0; d < dim; d++) {
|
||||
fprintf(stream, "(x_%d - (%g))^%d", d, center_[d], mapping[d]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stream, "%g ", coeffs_[i]);
|
||||
}
|
||||
if(i < total_num_coeffs - 1) {
|
||||
fprintf(stream, " + ");
|
||||
}
|
||||
}
|
||||
fprintf(stream, "\n");
|
||||
}
|
||||
@@ -486,6 +510,8 @@ void SeriesExpansion<TKernel>::TransFarToFar(const SeriesExpansion &se) {
|
||||
// no coefficients can be translated
|
||||
if(order == 0)
|
||||
return;
|
||||
else
|
||||
order_ = order;
|
||||
|
||||
// the first order (the sum of the weights) stays constant regardless
|
||||
// of the location of the center.
|
||||
|
||||
@@ -31,27 +31,6 @@ class SeriesExpansionAux {
|
||||
/** row index is for n, column index is for k */
|
||||
Matrix n_choose_k_;
|
||||
|
||||
/** compute n choose k: this might be moved later to FastLib core... */
|
||||
int nchoosek(int n, int k) {
|
||||
int n_k = n - k;
|
||||
int nchsk = 1;
|
||||
int i;
|
||||
|
||||
if(k > n)
|
||||
return 0;
|
||||
|
||||
if(k < n_k) {
|
||||
k = n_k;
|
||||
n_k = n - k;
|
||||
}
|
||||
|
||||
for(i = 1; i <= n_k; i++) {
|
||||
nchsk *= (++k);
|
||||
nchsk /= i;
|
||||
}
|
||||
return nchsk;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// construtor/destructor
|
||||
|
||||
Reference in New Issue
Block a user