The R wrapper to the fdaPDE library
fdapde / fdapde-r Goto Github PK
View Code? Open in Web Editor NEWThe R wrapper to the fdaPDE library for physics-informed spatial and functional data analysis.
License: GNU General Public License v3.0
The R wrapper to the fdaPDE library for physics-informed spatial and functional data analysis.
License: GNU General Public License v3.0
Installing the R
package on a mac-os
system makes the compilation fail. Error reported:
In file included from R_Model.cpp:23:
In file included from fdaPDE/fdaPDE/models.h:20:
In file included from fdaPDE/fdaPDE/models/model_base.h:20:
In file included from fdaPDE/fdaPDE/core/fdaPDE/mesh.h:20:
fdaPDE/fdaPDE/core/fdaPDE/mesh/mesh.h:202:56: error: declaration of 'N' shadows template parameter
static constexpr bool is_manifold = is_manifold<M, N>::value;
^
fdaPDE/fdaPDE/core/fdaPDE/mesh/mesh.h:59:22: note: template parameter is declared here
template <int M, int N> class Mesh {
^
fdaPDE/fdaPDE/core/fdaPDE/mesh/mesh.h:202:56: error: default initialization of an object of const type 'const bool'
static constexpr bool is_manifold = is_manifold<M, N>::value;
^
= false
fdaPDE/fdaPDE/core/fdaPDE/mesh/mesh.h:202:57: error: expected ';' at end of declaration list
static constexpr bool is_manifold = is_manifold<M, N>::value;
^
;
In file included from R_Model.cpp:23:
In file included from fdaPDE/fdaPDE/models.h:20:
In file included from fdaPDE/fdaPDE/models/model_base.h:21:
In file included from fdaPDE/fdaPDE/core/fdaPDE/utils.h:24:
fdaPDE/fdaPDE/core/fdaPDE/utils/type_erasure.h:222:28: error: use 'template' keyword to treat 'fn_ptrs' as a dependent template name
size_ = (size<typename I::fn_ptrs<T_>>::value + ...);
^
template
fdaPDE/fdaPDE/core/fdaPDE/utils/type_erasure.h:225:55: error: use 'template' keyword to treat 'fn_ptrs' as a dependent template name
init_vtable<0, T_>(typename merge<typename I::fn_ptrs<T_>...>::type(), vtable_);
^
template
fdaPDE/fdaPDE/core/fdaPDE/utils/type_erasure.h:230:67: error: use 'template' keyword to treat 'fn_ptrs' as a dependent template name
base_ += size<typename std::decay<decltype(i)>::type::fn_ptrs<T_>>::value;
^
template
In file included from R_Model.cpp:23:
In file included from fdaPDE/fdaPDE/models.h:20:
In file included from fdaPDE/fdaPDE/models/model_base.h:22:
In file included from fdaPDE/fdaPDE/core/fdaPDE/pde.h:20:
In file included from fdaPDE/fdaPDE/core/fdaPDE/pde/pde.h:29:
fdaPDE/fdaPDE/core/fdaPDE/pde/differential_operators.h:48:51: error: template template argument has different template parameters than its corresponding template template parameter
static constexpr bool value = has_instance_of<dT, decltype(std::declval<E>().get_operator_type())>::value;
^
fdaPDE/fdaPDE/core/fdaPDE/pde/differential_operators.h:36:1: note: too many template parameters in template template argument
FDAPDE_DEFINE_DIFFERENTIAL_OPERATOR(dT, dt );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fdaPDE/fdaPDE/core/fdaPDE/pde/differential_operators.h:28:5: note: expanded from macro 'FDAPDE_DEFINE_DIFFERENTIAL_OPERATOR'
template <typename T, typename... Ts> class OP { }; \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fdaPDE/fdaPDE/core/fdaPDE/utils/traits.h:58:11: note: previous template template parameter is here
template <template <typename F> typename E, typename Tuple> struct has_instance_of { };
^~~~~~~~~~~~~~~~~~~~~
In file included from R_Model.cpp:23:
In file included from fdaPDE/fdaPDE/models.h:20:
In file included from fdaPDE/fdaPDE/models/model_base.h:22:
In file included from fdaPDE/fdaPDE/core/fdaPDE/pde.h:20:
In file included from fdaPDE/fdaPDE/core/fdaPDE/pde/pde.h:29:
fdaPDE/fdaPDE/core/fdaPDE/pde/differential_operators.h:48:27: error: default initialization of an object of const type 'const bool'
static constexpr bool value = has_instance_of<dT, decltype(std::declval<E>().get_operator_type())>::value;
^
= false
Problem seems related to some apple-clang
aspects which are ignored when compiling with gcc
.
Compiler details:
─ installing source package ‘fdaPDE2’ ...
** using staged installation
** libs
using C++ compiler: ‘Apple clang version 15.0.0 (clang-1500.0.40.1)’
using C++17
using SDK: ‘MacOSX14.0.sdk’
When using BFGS as optimization method, the R wrapper crashes with cause 'memory not mapped'
MWE
data("unit_square", package = "fdaPDE2")
unit_square <- Mesh(unit_square)
df <- ## some data...
model <- SRPDE(y ~ f, domain = unit_square, data = df)
## fit with BFGS optimization
model$fit(lambda = gcv(
optimizer = "bfgs",
lambda = 1e-4,
step = 1e-6
))
The problem is releated to the R
wrapper, as performing a BFGS
optimization of the GCV from the C++ layer does not cause any segfault.
You can reproduce the test gcv_srpde_newton_test, laplacian_nonparametric_samplingatnodes_newton_fd_exact
with BFGS
in place of Netwon
, and obtain the correct result using a wolfe line search approach for the adaptive step.
auto GCV = model.gcv<ExactEDF>();
GCV.set_step(4e-08);
// optimize GCV
BFGS<fdapde::Dynamic> opt(10, 0.05, 1);
DVector<double> pt = SVector<1>(6.25e-06);
opt.optimize(GCV, pt, WolfeLineSearch());
FunctionSpace()
does not complain when an object of a type different from MeshObject
is passed as the first argument. Instead, it returns an error that is not clear.
Code
library(fdaPDE2)
data("unit_square", package = "fdaPDE2")
domain <- Mesh(unit_square)
Vh <- FunctionSpace(domain, fe_order = 1)
Error
> data("unit_square", package = "fdaPDE2")
> domain <- Mesh(unit_square)
>
> ## the functional space of finite element functions of order 1, over the unit square
> Vh <- FunctionSpace(unit_square, fe_order = 1)
Error in eval(parse(text = paste("cpp_lagrange_basis_", mesh$domain_type, :
object 'cpp_lagrange_basis__fe1' not found
fdaPDE must be able to support many different data format as input, well established in the R language and scientific community. Is quiet annoying to input data in low-level matrix
or array
data formats. This is true for statistical data, but also for the domain geometry (this is a critical aspect which must be fixed sooner or later).
This issue wants to keep a list of all data format we should (or wish) support to enhance the fdaPDE usage. Each iter reports the data format, its supporting R package and possibly some specific documentation:
ncdf4
, raster
.raster
, terra
(https://github.com/rspatial/terra)tibble
would be nice (https://tibble.tidyverse.org/).A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.