@@ -68,7 +68,7 @@ template <typename VariationalSolver> class fpca_power_iteration_impl {
6868 int calibration = (flag & 0b11110 ); // detect calibration strategy
6969 for (int i = 0 ; i < rank; ++i) {
7070 // select optimal smoothing level for i-th component
71- std::array <double , n_lambda> opt_lambda;
71+ Eigen::Matrix <double , n_lambda, 1 > opt_lambda;
7272 switch (calibration) {
7373 case 0 : { // no calibration
7474 fdapde_assert (lambda_grid.size () == n_lambda);
@@ -134,10 +134,12 @@ template <typename VariationalSolver> class fpca_power_iteration_impl {
134134 double gcv_ (const matrix_t & X, const LambdaT lambda, const InitT& f0) {
135135 const auto & [f, s] = solve_ (X, lambda, f0);
136136 // evaluate GCV index at convergence
137- if (edf_map_.find (lambda) == edf_map_.end ()) { // cache Tr[S]
138- edf_map_[lambda] = smoother_->edf ();
137+ std::array<double , n_lambda> lambda_vec;
138+ std::copy (lambda.data (), lambda.data () + n_lambda, lambda_vec.begin ());
139+ if (edf_map_.find (lambda_vec) == edf_map_.end ()) { // cache Tr[S]
140+ edf_map_[lambda_vec] = smoother_->edf ();
139141 }
140- int dor = n_locs_ - edf_map_.at (lambda );
142+ int dor = n_locs_ - edf_map_.at (lambda_vec );
141143 return (n_locs_ / std::pow (dor, 2 )) * ((smoother_->Psi () * f) - smoother_->response ()).squaredNorm ();
142144 }
143145 std::unordered_map<std::array<double , n_lambda>, double , internals::std_array_hash<double , n_lambda>> edf_map_;
@@ -188,7 +190,7 @@ template <typename VariationalSolver> class fpca_subspace_iteration_impl {
188190 lambda_.resize (rank, n_lambda);
189191
190192 int calibration = (flag & 0b11110 ); // detect calibration strategy
191- std::array <double , n_lambda> opt_lambda;
193+ Eigen::Matrix <double , n_lambda, 1 > opt_lambda;
192194 switch (calibration) {
193195 case 0 : { // no calibration
194196 fdapde_assert (lambda_grid.size () == n_lambda);
@@ -302,7 +304,7 @@ template <typename VariationalSolver> class fpca_direct_impl {
302304 lambda_.resize (rank, n_lambda);
303305
304306 int calibration = (flag & 0b11110 ); // detect calibration strategy
305- std::array <double , n_lambda> opt_lambda;
307+ Eigen::Matrix <double , n_lambda, 1 > opt_lambda;
306308 switch (calibration) {
307309 case 0 : { // no calibration
308310 fdapde_assert (lambda_grid.size () == n_lambda);
@@ -523,7 +525,7 @@ template <typename VariationalSolver> class fPCA {
523525 fPCA () noexcept = default ;
524526 template <typename GeoFrame, typename Penalty>
525527 fPCA (const std::string& colname, const GeoFrame& gf, Penalty&& penalty) noexcept : smoother_(), data_() {
526- discretize (penalty.get (). penalty );
528+ discretize (penalty.get ());
527529 analyze_data (colname, gf);
528530 }
529531 template <typename ... Args> void discretize (Args&&... args) {
0 commit comments