Skip to content
Open
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ cmake-build-debug/
#docs files
*.puml
.Rproj.user

experiments/
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "fdaPDE/core"]
path = fdaPDE/core
url = https://github.com/fdaPDE/fdaPDE-core
url = https://github.com/marcogalliani/fdaPDE-core
branch = stable
2 changes: 1 addition & 1 deletion fdaPDE/core
Submodule core updated 34 files
+3 −39 fdaPDE/optimization.h
+1 −1 fdaPDE/src/assembly.h
+1 −0 fdaPDE/src/fields/matrix_field.h
+1 −2 fdaPDE/src/fields/spline.h
+16 −13 fdaPDE/src/finite_elements/fe_assembler_base.h
+30 −25 fdaPDE/src/finite_elements/fe_evaluator.h
+62 −48 fdaPDE/src/geoframe/data_layer.h
+18 −5 fdaPDE/src/geoframe/geo_layer.h
+12 −11 fdaPDE/src/geoframe/geoframe.h
+2 −6 fdaPDE/src/linear_algebra/rp_chol.h
+66 −65 fdaPDE/src/linear_algebra/sparse_block_matrix.h
+7 −7 fdaPDE/src/optimization/backtracking_line_search.h
+54 −38 fdaPDE/src/optimization/bfgs.h
+22 −45 fdaPDE/src/optimization/callbacks.h
+0 −131 fdaPDE/src/optimization/conjugate_gradient.h
+38 −38 fdaPDE/src/optimization/gradient_descent.h
+99 −0 fdaPDE/src/optimization/grid.h
+0 −104 fdaPDE/src/optimization/grid_search.h
+72 −46 fdaPDE/src/optimization/lbfgs.h
+0 −195 fdaPDE/src/optimization/nelder_mead.h
+39 −41 fdaPDE/src/optimization/newton.h
+0 −96 fdaPDE/src/optimization/wolfe.h
+69 −0 fdaPDE/src/optimization/wolfe_line_search.h
+1 −1 fdaPDE/src/splines/bs_space.h
+16 −13 fdaPDE/src/splines/sp_assembler_base.h
+3 −1 fdaPDE/src/splines/sp_bilinear_form_assembler.h
+3 −1 fdaPDE/src/splines/sp_linear_form_assembler.h
+19 −11 fdaPDE/src/splines/sp_objects.h
+0 −12 fdaPDE/src/utility/binary.h
+2 −52 fdaPDE/src/utility/matrix.h
+43 −22 fdaPDE/src/utility/meta.h
+4 −4 test/main.cpp
+38 −50 test/src/rand_linear_algebra_test.cpp
+25 −19 test/src/utils/utils.h
21 changes: 12 additions & 9 deletions fdaPDE/src/models/fpca.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ template <typename VariationalSolver> class fpca_power_iteration_impl {
case OptimizeGCV: {
auto gcv_functor = [&](auto lambda) { return gcv_(X, lambda, V.col(i)); };
GridSearch<n_lambda> optimizer;
opt_lambda = optimizer.optimize(gcv_functor, lambda_grid);
auto opt_ = optimizer.optimize(gcv_functor, lambda_grid);
for (int i = 0; i < n_lambda; ++i) { opt_lambda[i] = opt_[i]; }
} break;
case OptimizeMSRE: {
} break;
Expand Down Expand Up @@ -134,12 +135,12 @@ template <typename VariationalSolver> class fpca_power_iteration_impl {
double gcv_(const matrix_t& X, const LambdaT lambda, const InitT& f0) {
const auto& [f, s] = solve_(X, lambda, f0);
// evaluate GCV index at convergence
std::array<double, n_lambda> lambda_vec;
std::copy(lambda.data(), lambda.data() + n_lambda, lambda_vec.begin());
if (edf_map_.find(lambda_vec) == edf_map_.end()) { // cache Tr[S]
edf_map_[lambda_vec] = smoother_->edf();
std::array<double, n_lambda> lambda_;
for (int i = 0; i < n_lambda; ++i) { lambda_[i] = lambda[i]; }
if (edf_map_.find(lambda_) == edf_map_.end()) { // cache Tr[S]
edf_map_[lambda_] = smoother_->edf();
}
int dor = n_locs_ - edf_map_.at(lambda_vec);
int dor = n_locs_ - edf_map_.at(lambda_);
return (n_locs_ / std::pow(dor, 2)) * ((smoother_->Psi() * f) - smoother_->response()).squaredNorm();
}
std::unordered_map<std::array<double, n_lambda>, double, internals::std_array_hash<double, n_lambda>> edf_map_;
Expand Down Expand Up @@ -199,7 +200,8 @@ template <typename VariationalSolver> class fpca_subspace_iteration_impl {
case OptimizeGCV: {
auto gcv_functor = [&](auto lambda) { return gcv_(X, rank, lambda, V); };
GridSearch<n_lambda> optimizer;
opt_lambda = optimizer.optimize(gcv_functor, lambda_grid);
auto opt_ = optimizer.optimize(gcv_functor, lambda_grid);
for (int i = 0; i < n_lambda; ++i) { opt_lambda[i] = opt_[i]; }
} break;
case OptimizeMSRE: {
} break;
Expand Down Expand Up @@ -313,7 +315,8 @@ template <typename VariationalSolver> class fpca_direct_impl {
case OptimizeGCV: {
auto gcv_functor = [&](auto lambda) { return gcv_(X, rank, lambda, flag); };
GridSearch<n_lambda> optimizer;
opt_lambda = optimizer.optimize(gcv_functor, lambda_grid);
auto opt_ = optimizer.optimize(gcv_functor, lambda_grid);
for (int i = 0; i < n_lambda; ++i) { opt_lambda[i] = opt_[i]; }
} break;
case OptimizeMSRE: {
} break;
Expand Down Expand Up @@ -371,7 +374,7 @@ template <typename VariationalSolver> 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;
Expand Down