From 3653ec2cce507bd4076d379207952e33e9c53aed Mon Sep 17 00:00:00 2001 From: Marco Galliani <105008364+marcogalliani@users.noreply.github.com> Date: Mon, 27 Oct 2025 12:20:11 +0100 Subject: [PATCH] bugfix: correct dof computation for fpca_direct --- fdaPDE/src/models/fpca.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdaPDE/src/models/fpca.h b/fdaPDE/src/models/fpca.h index 2036524b..10257ab3 100644 --- a/fdaPDE/src/models/fpca.h +++ b/fdaPDE/src/models/fpca.h @@ -371,7 +371,7 @@ template class fpca_direct_impl { double gcv_(const matrix_t& X, int rank, const LambdaT lambda, int flag) { const auto& [F, S] = solve_(X, rank, lambda, flag); // evaluate GCV index at convergence (note that Tr[S] = \|D^(-1)\|_F^2) - int dor = n_locs_ - invD_.squaredNorm(); + int dor = n_locs_ - (invD_*smoother_->Psi().transpose()).squaredNorm(); return (n_locs_ / std::pow(dor, 2)) * (X.transpose() * S - (smoother_->Psi() * F)).squaredNorm(); } int n_locs_ = 0, n_units_ = 0, n_dofs_ = 0;