Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.25) # Needed for CUDA, MPI, and CTest features

project(
EXP
VERSION "7.8.3"
VERSION "7.8.4"
HOMEPAGE_URL https://github.com/EXP-code/EXP
LANGUAGES C CXX Fortran)

Expand Down
2 changes: 1 addition & 1 deletion expui/Coefficients.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace CoefClasses
in2.transposeInPlace();

for (size_t c=0, n=0; c<in.cols(); c++) {
for (size_t r=0, n=0; r<in.rows(); r++) {
for (size_t r=0; r<in.rows(); r++) {
in(r, c) = in2.data()[n++];
}
}
Expand Down
15 changes: 10 additions & 5 deletions exputil/OrthoFunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ double OrthoFunction::scalar_prod(int n, int m)
return ans;
}

// Compute the unnormalized polynomial
Eigen::VectorXd OrthoFunction::poly_eval(double t, int n)
{
Eigen::VectorXd ret(n+1);
Expand All @@ -68,6 +69,8 @@ Eigen::VectorXd OrthoFunction::poly_eval(double t, int n)
return ret;
}

// Compute the orthogonality matrix. A perfect result is the unit
// matrix.
Eigen::MatrixXd OrthoFunction::testOrtho()
{
Eigen::MatrixXd ret(nmax+1, nmax+1);
Expand All @@ -80,10 +83,10 @@ Eigen::MatrixXd OrthoFunction::testOrtho()
double f = dx*lq->weight(i)*d_r_to_x(x)*pow(r, dof-1);
double y = 2.0*r/scale; if (segment) y = x;

// Evaluate polynomial
// Evaluate the unnormalized polynomial
Eigen::VectorXd p = poly_eval(y, nmax) * W(r);

// Compute scalar products
// Compute scalar products with the normalizations
for (int n1=0; n1<=nmax; n1++) {
for (int n2=0; n2<=nmax; n2++) {
ret(n1, n2) += f * p(n1) * p(n2) / sqrt(norm[n1]*norm[n2]);
Expand All @@ -110,11 +113,11 @@ void OrthoFunction::dumpOrtho(const std::string& filename)
double r = x_to_r(x);
double y = 2.0*r/scale; if (segment) y = x;

// Evaluate polynomial
// Evaluate polynomial and apply the normalization
//
Eigen::VectorXd p = poly_eval(y, nmax) * W(r);
fout << std::setw(16) << r;
Copy link

Copilot AI May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding a comment explaining the rationale behind dividing by sqrt(norm[n]) to ensure that future maintainers understand the fix for the spherical coefficient read.

Suggested change
fout << std::setw(16) << r;
fout << std::setw(16) << r;
// Normalize the polynomial coefficients by dividing by sqrt(norm[n])
// to ensure they adhere to the expected orthogonality or normalization properties.

Copilot uses AI. Check for mistakes.
for (int n=0; n<nmax; n++) fout << std::setw(16) << p(n);
for (int n=0; n<nmax; n++) fout << std::setw(16) << p(n)/sqrt(norm[n]);
fout << std::endl;
}
}
Expand All @@ -132,9 +135,11 @@ Eigen::VectorXd OrthoFunction::operator()(double r)
double y = 2.0*r/scale;
if (segment) y = r_to_x(r);

// Generate normalized orthogonal functions
// Generate normalized orthogonal functions with weighting
auto p = poly_eval(y, nmax);
for (int i=0; i<=nmax; i++) p(i) *= w/sqrt(norm[i]);

// The inner product of p(i), p(j) is Kronecker delta(i, j)

return p;
}