From f311c16c7efe81d1232a097a382b75f92ad27946 Mon Sep 17 00:00:00 2001 From: mkirsz <s1351949@sms.ed.ac.uk> Date: Wed, 31 Jan 2024 17:47:50 +0000 Subject: [PATCH] Getting rid of Eigen aeds. --- descriptors/d2/d2_base.cpp | 4 ++-- descriptors/d2/d2_base.h | 8 ++++---- descriptors/d2/d2_blip.cpp | 4 ++-- descriptors/d2/d2_blip.h | 4 ++-- descriptors/d2/d2_bp.cpp | 4 ++-- descriptors/d2/d2_bp.h | 4 ++-- descriptors/d2/d2_dummy.cpp | 4 ++-- descriptors/d2/d2_dummy.h | 4 ++-- descriptors/d2/d2_eam.cpp | 4 ++-- descriptors/d2/d2_eam.h | 4 ++-- descriptors/d2/d2_lj.cpp | 4 ++-- descriptors/d2/d2_lj.h | 4 ++-- descriptors/d2/d2_mie.cpp | 4 ++-- descriptors/d2/d2_mie.h | 4 ++-- descriptors/d3/d3_base.h | 4 ++-- descriptors/d3/d3_dummy.cpp | 4 ++-- descriptors/d3/d3_dummy.h | 4 ++-- descriptors/dm/dm_base.h | 2 +- descriptors/dm/dm_blip.cpp | 2 +- descriptors/dm/dm_blip.h | 2 +- descriptors/dm/dm_dummy.cpp | 2 +- descriptors/dm/dm_dummy.h | 2 +- descriptors/dm/dm_ead.cpp | 2 +- descriptors/dm/dm_ead.h | 2 +- descriptors/dm/dm_eam.cpp | 2 +- descriptors/dm/dm_eam.h | 2 +- descriptors/dm/dm_mEAD.cpp | 2 +- descriptors/dm/dm_mEAD.h | 2 +- ekm.h | 4 ++-- functions/basis_functions/bf_base.h | 6 +++--- functions/basis_functions/bf_linear.cpp | 6 +++--- functions/basis_functions/bf_linear.h | 6 +++--- functions/basis_functions/bf_polynomial2.cpp | 10 +++++----- functions/basis_functions/bf_polynomial2.h | 6 +++--- functions/function_base.h | 16 ++++++++-------- functions/kernels/kern_base.cpp | 14 +++++++------- functions/kernels/kern_base.h | 18 +++++++++--------- functions/kernels/kern_linear.cpp | 12 ++++++------ functions/kernels/kern_linear.h | 14 +++++++------- functions/kernels/kern_lq.cpp | 6 +++--- functions/kernels/kern_lq.h | 6 +++--- functions/kernels/kern_polynomial.cpp | 10 +++++----- functions/kernels/kern_polynomial.h | 6 +++--- functions/kernels/kern_quadratic.cpp | 6 +++--- functions/kernels/kern_quadratic.h | 6 +++--- functions/kernels/kern_rbf.cpp | 10 +++++----- functions/kernels/kern_rbf.h | 6 +++--- functions/kernels/kern_sigmoid.cpp | 8 ++++---- functions/kernels/kern_sigmoid.h | 6 +++--- m_core.h | 6 +++--- m_krr_core.h | 6 +++--- 51 files changed, 144 insertions(+), 144 deletions(-) diff --git a/descriptors/d2/d2_base.cpp b/descriptors/d2/d2_base.cpp index 017b0ce..c1b6561 100644 --- a/descriptors/d2/d2_base.cpp +++ b/descriptors/d2/d2_base.cpp @@ -4,8 +4,8 @@ void D2_Base::calc_fd_approx( const double , const double , const double , - aed_rtype aedp, - aed_rtype aedn, + aed_type2& aedp, + aed_type2& aedn, fd_type &fd_ij, const double h) { diff --git a/descriptors/d2/d2_base.h b/descriptors/d2/d2_base.h index 6ff85db..2ca5df4 100644 --- a/descriptors/d2/d2_base.h +++ b/descriptors/d2/d2_base.h @@ -20,7 +20,7 @@ class D2_Base: public D_Base { const double rij, const double rij_sq, const double fc_ij, - aed_rtype aed)=0; + aed_type2& aed)=0; /** \brief Calculate \ref FD * @@ -49,8 +49,8 @@ class D2_Base: public D_Base { const double rij, const double fcijp, const double fcijn, - aed_rtype aedp, - aed_rtype aedn, + aed_type2& aedp, + aed_type2& aedn, fd_type &fd_ij, const double h); @@ -60,7 +60,7 @@ class D2_Base: public D_Base { const double rij_sq, const double fc_ij, const double fcp_ij, - aed_rtype aed, + aed_type2& aed, fd_type &fd_ij)=0; virtual std::string label()=0; }; diff --git a/descriptors/d2/d2_blip.cpp b/descriptors/d2/d2_blip.cpp index 35640da..d8571b1 100644 --- a/descriptors/d2/d2_blip.cpp +++ b/descriptors/d2/d2_blip.cpp @@ -35,7 +35,7 @@ void D2_Blip::calc_aed( const double rij, const double , const double fc_ij, - aed_rtype aed) + aed_type2 &aed) { size_t i=fidx; @@ -62,7 +62,7 @@ void D2_Blip::calc_all( const double , const double fc_ij, const double fcp_ij, - aed_rtype aed, + aed_type2 &aed, fd_type &fd_ij) { diff --git a/descriptors/d2/d2_blip.h b/descriptors/d2/d2_blip.h index beb7d76..50a4454 100644 --- a/descriptors/d2/d2_blip.h +++ b/descriptors/d2/d2_blip.h @@ -57,7 +57,7 @@ class D2_Blip : public D2_Base { const double rij, const double rij_sq, const double fc_ij, - aed_rtype aed); + aed_type2 &aed); void calc_dXijdri( const double rij, const double rij_sq, @@ -69,7 +69,7 @@ class D2_Blip : public D2_Base { const double rij_sq, const double fc_ij, const double fcp_ij, - aed_rtype aed, + aed_type2 &aed, fd_type &fd_ij); size_t size(); std::string label(); diff --git a/descriptors/d2/d2_bp.cpp b/descriptors/d2/d2_bp.cpp index abdce9d..9ab3863 100644 --- a/descriptors/d2/d2_bp.cpp +++ b/descriptors/d2/d2_bp.cpp @@ -34,7 +34,7 @@ void D2_BP::calc_aed( const double rij, const double , const double fc_ij, - aed_rtype aed) + aed_type2 &aed) { size_t i=fidx; @@ -60,7 +60,7 @@ void D2_BP::calc_all( const double , const double fc_ij, const double fcp_ij, - aed_rtype aed, + aed_type2 &aed, fd_type &fd_ij) { diff --git a/descriptors/d2/d2_bp.h b/descriptors/d2/d2_bp.h index d73e873..26ea63e 100644 --- a/descriptors/d2/d2_bp.h +++ b/descriptors/d2/d2_bp.h @@ -38,7 +38,7 @@ class D2_BP : public D2_Base { const double rij, const double , const double fc_ij, - aed_rtype aed); + aed_type2 &aed); void calc_dXijdri( const double rij, const double , @@ -50,7 +50,7 @@ class D2_BP : public D2_Base { const double , const double fc_ij, const double fcp_ij, - aed_rtype aed, + aed_type2 &aed, fd_type &fd_ij); size_t size(); std::string label(); diff --git a/descriptors/d2/d2_dummy.cpp b/descriptors/d2/d2_dummy.cpp index 4ea73ba..7c0383a 100644 --- a/descriptors/d2/d2_dummy.cpp +++ b/descriptors/d2/d2_dummy.cpp @@ -11,7 +11,7 @@ void D2_Dummy::calc_aed( const double, const double, const double, - aed_rtype ) {} + aed_type2 & ) {} void D2_Dummy::calc_dXijdri( const double, const double, @@ -23,7 +23,7 @@ void D2_Dummy::calc_all( const double, const double, const double, - aed_rtype , + aed_type2 & , fd_type &) {} size_t D2_Dummy::size() { return s; } std::string D2_Dummy::label() { return lab; } diff --git a/descriptors/d2/d2_dummy.h b/descriptors/d2/d2_dummy.h index 87a73fd..df4e145 100644 --- a/descriptors/d2/d2_dummy.h +++ b/descriptors/d2/d2_dummy.h @@ -21,7 +21,7 @@ class D2_Dummy : public D2_Base { const double, const double, const double, - aed_rtype aed); + aed_type2 &aed); void calc_dXijdri( const double, const double, @@ -33,7 +33,7 @@ class D2_Dummy : public D2_Base { const double, const double, const double, - aed_rtype aed, + aed_type2 &aed, fd_type &fd_ij); size_t size(); std::string label(); diff --git a/descriptors/d2/d2_eam.cpp b/descriptors/d2/d2_eam.cpp index 99bcbf1..47be89a 100644 --- a/descriptors/d2/d2_eam.cpp +++ b/descriptors/d2/d2_eam.cpp @@ -40,7 +40,7 @@ void D2_EAM::calc_aed( const double rij, const double, const double, - aed_rtype aed) + aed_type2 &aed) { double r = rij; @@ -83,7 +83,7 @@ void D2_EAM::calc_all( const double, const double, const double, - aed_rtype aed, + aed_type2 &aed, fd_type &fd_ij) { double r = rij; diff --git a/descriptors/d2/d2_eam.h b/descriptors/d2/d2_eam.h index 6a8545d..35f9fe1 100644 --- a/descriptors/d2/d2_eam.h +++ b/descriptors/d2/d2_eam.h @@ -59,7 +59,7 @@ class D2_EAM : public D2_Base { double rij, const double rij_sq, const double, - aed_rtype aed); + aed_type2 &aed); void calc_dXijdri( double rij, const double rij_sq, @@ -71,7 +71,7 @@ class D2_EAM : public D2_Base { const double rij_sq, const double, const double, - aed_rtype aed, + aed_type2 &aed, fd_type &fd_ij); size_t size(); std::string label(); diff --git a/descriptors/d2/d2_lj.cpp b/descriptors/d2/d2_lj.cpp index b052348..05eedd6 100644 --- a/descriptors/d2/d2_lj.cpp +++ b/descriptors/d2/d2_lj.cpp @@ -14,7 +14,7 @@ void D2_LJ::calc_aed( const double, const double rij_sq, const double fc_ij, - aed_rtype aed) + aed_type2 &aed) { double r2_inv = 1.0/rij_sq; double r6_inv = r2_inv*r2_inv*r2_inv; @@ -41,7 +41,7 @@ void D2_LJ::calc_all( const double rij_sq, const double fc_ij, const double fcp_ij, - aed_rtype aed, + aed_type2 &aed, fd_type &fd_ij) { double r2_inv = 1.0/rij_sq; diff --git a/descriptors/d2/d2_lj.h b/descriptors/d2/d2_lj.h index a1a3f8d..93bce92 100644 --- a/descriptors/d2/d2_lj.h +++ b/descriptors/d2/d2_lj.h @@ -39,7 +39,7 @@ class D2_LJ : public D2_Base { const double, const double rij_sq, const double fc_ij, - aed_rtype aed); + aed_type2 &aed); void calc_dXijdri( const double rij, const double rij_sq, @@ -51,7 +51,7 @@ class D2_LJ : public D2_Base { const double rij_sq, const double fc_ij, const double fcp_ij, - aed_rtype aed, + aed_type2 &aed, fd_type &fd_ij); size_t size(); std::string label(); diff --git a/descriptors/d2/d2_mie.cpp b/descriptors/d2/d2_mie.cpp index d173664..cf43d9f 100644 --- a/descriptors/d2/d2_mie.cpp +++ b/descriptors/d2/d2_mie.cpp @@ -25,7 +25,7 @@ void D2_MIE::calc_aed( const double rij, const double, const double fc_ij, - aed_rtype aed) + aed_type2 &aed) { double rn_inv = 1.0/pow(rij,n); double rm_inv = 1.0/pow(rij,m); @@ -50,7 +50,7 @@ void D2_MIE::calc_all( const double, const double fc_ij, const double fcp_ij, - aed_rtype aed, + aed_type2 &aed, fd_type &fd_ij) { diff --git a/descriptors/d2/d2_mie.h b/descriptors/d2/d2_mie.h index 054fb22..073e2d7 100644 --- a/descriptors/d2/d2_mie.h +++ b/descriptors/d2/d2_mie.h @@ -34,7 +34,7 @@ class D2_MIE : public D2_Base { const double, const double rij_sq, const double fc_ij, - aed_rtype aed); + aed_type2 &aed); void calc_dXijdri( const double rij, const double rij_sq, @@ -46,7 +46,7 @@ class D2_MIE : public D2_Base { const double rij_sq, const double fc_ij, const double fcp_ij, - aed_rtype aed, + aed_type2 &aed, fd_type &fd_ij); size_t size(); std::string label(); diff --git a/descriptors/d3/d3_base.h b/descriptors/d3/d3_base.h index 281932a..837b247 100644 --- a/descriptors/d3/d3_base.h +++ b/descriptors/d3/d3_base.h @@ -13,7 +13,7 @@ class D3_Base: public D_Base { const double rik, const double fc_ij, const double fc_ik, - aed_rtype aed)=0; + aed_type2& aed)=0; virtual void calc_fd( const size_t fidx, const double rij, @@ -31,7 +31,7 @@ class D3_Base: public D_Base { const double fc_ik, const double fcp_ij, const double fcp_ik, - aed_rtype aed, + aed_type2& aed, fd_type &fd_ij)=0; virtual size_t size()=0; virtual std::string label()=0; diff --git a/descriptors/d3/d3_dummy.cpp b/descriptors/d3/d3_dummy.cpp index c145bfd..12d0074 100644 --- a/descriptors/d3/d3_dummy.cpp +++ b/descriptors/d3/d3_dummy.cpp @@ -11,7 +11,7 @@ void D3_Dummy::calc_aed( const double, const double, const double, - aed_rtype ) {} + aed_type2& ) {} void D3_Dummy::calc_fd( const size_t, const double, @@ -29,7 +29,7 @@ void D3_Dummy::calc_all( const double, const double, const double, - aed_rtype , + aed_type2& , fd_type &) {} size_t D3_Dummy::size() { return s;} std::string D3_Dummy::label() {return lab;} diff --git a/descriptors/d3/d3_dummy.h b/descriptors/d3/d3_dummy.h index 616b08a..d4d4925 100644 --- a/descriptors/d3/d3_dummy.h +++ b/descriptors/d3/d3_dummy.h @@ -14,7 +14,7 @@ class D3_Dummy: public D3_Base { const double rik, const double fc_ij, const double fc_ik, - aed_rtype aed); + aed_type2& aed); void calc_fd( const size_t fidx, const double rij, @@ -32,7 +32,7 @@ class D3_Dummy: public D3_Base { const double fc_ik, const double fcp_ij, const double fcp_ik, - aed_rtype aed, + aed_type2& aed, fd_type &fd_ij); size_t size(); std::string label(); diff --git a/descriptors/dm/dm_base.h b/descriptors/dm/dm_base.h index 5062a7b..89ac3b6 100644 --- a/descriptors/dm/dm_base.h +++ b/descriptors/dm/dm_base.h @@ -19,7 +19,7 @@ class DM_Base: public D_Base { */ virtual void calc_aed( rho_rtype rho, - aed_rtype aed)=0; + aed_type2 &aed)=0; /** \brief Calculate \ref FD * diff --git a/descriptors/dm/dm_blip.cpp b/descriptors/dm/dm_blip.cpp index abd287e..68b1adb 100644 --- a/descriptors/dm/dm_blip.cpp +++ b/descriptors/dm/dm_blip.cpp @@ -39,7 +39,7 @@ DM_Blip::DM_Blip(Config &c): void DM_Blip::calc_aed( rho_rtype rhoi, - aed_rtype aed) + aed_type2 &aed) { size_t Lshift = 0; size_t ii=0; diff --git a/descriptors/dm/dm_blip.h b/descriptors/dm/dm_blip.h index 9f6eab4..a95c510 100644 --- a/descriptors/dm/dm_blip.h +++ b/descriptors/dm/dm_blip.h @@ -55,7 +55,7 @@ class DM_Blip: public DM_Base { DM_Blip(Config&); void calc_aed( rho_rtype rho, - aed_rtype aed); + aed_type2 &aed); int calc_dXijdri_dXjidri( const double rij, const double rij_sq, diff --git a/descriptors/dm/dm_dummy.cpp b/descriptors/dm/dm_dummy.cpp index e104902..8ff4852 100644 --- a/descriptors/dm/dm_dummy.cpp +++ b/descriptors/dm/dm_dummy.cpp @@ -6,7 +6,7 @@ DM_Dummy::DM_Dummy() {} DM_Dummy::DM_Dummy(Config&) {} void DM_Dummy::calc_aed( rho_rtype, - aed_rtype ) {} + aed_type2 & ) {} int DM_Dummy::calc_dXijdri_dXjidri( const double, const double, diff --git a/descriptors/dm/dm_dummy.h b/descriptors/dm/dm_dummy.h index dab6979..3d69926 100644 --- a/descriptors/dm/dm_dummy.h +++ b/descriptors/dm/dm_dummy.h @@ -18,7 +18,7 @@ class DM_Dummy: public DM_Base { DM_Dummy(Config&); void calc_aed( rho_rtype rho, - aed_rtype aed); + aed_type2 &aed); int calc_dXijdri_dXjidri( const double rij, const double rij_sq, diff --git a/descriptors/dm/dm_ead.cpp b/descriptors/dm/dm_ead.cpp index 0ad4862..7b4d1d2 100644 --- a/descriptors/dm/dm_ead.cpp +++ b/descriptors/dm/dm_ead.cpp @@ -43,7 +43,7 @@ DM_EAD::DM_EAD(Config &config): void DM_EAD::calc_aed( rho_rtype rhoi, - aed_rtype aed) + aed_type2 &aed) { size_t Lshift = 0; size_t ii=0; diff --git a/descriptors/dm/dm_ead.h b/descriptors/dm/dm_ead.h index bc93bc9..508ab7d 100644 --- a/descriptors/dm/dm_ead.h +++ b/descriptors/dm/dm_ead.h @@ -54,7 +54,7 @@ class DM_EAD: public DM_Base { DM_EAD(Config&); void calc_aed( rho_rtype rho, - aed_rtype aed); + aed_type2 &aed); int calc_dXijdri_dXjidri( const double rij, const double rij_sq, diff --git a/descriptors/dm/dm_eam.cpp b/descriptors/dm/dm_eam.cpp index b2ea2ff..98b681f 100644 --- a/descriptors/dm/dm_eam.cpp +++ b/descriptors/dm/dm_eam.cpp @@ -37,7 +37,7 @@ DM_EAM::DM_EAM(Config &c): void DM_EAM::calc_aed( rho_rtype rho, - aed_rtype aed) + aed_type2 &aed) { //std::cout << "rho[i]: " << rho(0) << std::endl; double p = rho(0)*ef.rdrho + 1.0; diff --git a/descriptors/dm/dm_eam.h b/descriptors/dm/dm_eam.h index 62c3c29..9d92f01 100644 --- a/descriptors/dm/dm_eam.h +++ b/descriptors/dm/dm_eam.h @@ -58,7 +58,7 @@ class DM_EAM: public DM_Base { DM_EAM(Config&); void calc_aed( rho_rtype rho, - aed_rtype aed); + aed_type2 &aed); int calc_dXijdri_dXjidri( const double rij, const double rij_sq, diff --git a/descriptors/dm/dm_mEAD.cpp b/descriptors/dm/dm_mEAD.cpp index 74ba53a..a6e3e51 100644 --- a/descriptors/dm/dm_mEAD.cpp +++ b/descriptors/dm/dm_mEAD.cpp @@ -47,7 +47,7 @@ DM_mEAD<F>::DM_mEAD(Config &config): template <typename F> void DM_mEAD<F>::calc_aed( rho_rtype rhoi, - aed_rtype aed) + aed_type2 &aed) { size_t Lshift = 0; size_t ii=0; diff --git a/descriptors/dm/dm_mEAD.h b/descriptors/dm/dm_mEAD.h index 45224e9..0ccdd23 100644 --- a/descriptors/dm/dm_mEAD.h +++ b/descriptors/dm/dm_mEAD.h @@ -111,7 +111,7 @@ class DM_mEAD: public DM_Base, public F { DM_mEAD(Config&); void calc_aed( rho_rtype rho, - aed_rtype aed); + aed_type2 &aed); int calc_dXijdri_dXjidri( const double rij, const double rij_sq, diff --git a/ekm.h b/ekm.h index 5f60bc4..562c0f5 100644 --- a/ekm.h +++ b/ekm.h @@ -14,7 +14,7 @@ class EKM { EKM(T &t): kernel(t) {} - void configure(aeds_type &basis) { + void configure(aeds_type2 &basis) { // KK is temp matrix KK = Eigen::MatrixXd(basis.size(), basis.size()); @@ -39,7 +39,7 @@ class EKM { Phi.row(i)= KK*Phi.row(i).transpose(); } } - aed_type project(aed_rtype aed, aeds_type &basis) { + aed_type project(aed_type2 &aed, aeds_type2 &basis) { aed_type temp(basis.size()); for (long int b=0; b<basis.cols(); b++) { temp(b) = kernel(aed,basis[b]); diff --git a/functions/basis_functions/bf_base.h b/functions/basis_functions/bf_base.h index d76cd71..533cf63 100644 --- a/functions/basis_functions/bf_base.h +++ b/functions/basis_functions/bf_base.h @@ -9,10 +9,10 @@ /** \brief Base class to be used by all basis functions */ struct BF_Base: public virtual Function_Base { virtual ~BF_Base(); - virtual double epredict(const t_type &, const aed_rctype& )=0; + virtual double epredict(const t_type &, const aed_type2& )=0; virtual double fpredict(const t_type &, const fd_type &, - const aed_rctype& , const size_t )=0; + const aed_type2& , const size_t )=0; virtual force_type fpredict(const t_type &, const fd_type &, - const aed_rctype& )=0; + const aed_type2& )=0; }; #endif diff --git a/functions/basis_functions/bf_linear.cpp b/functions/basis_functions/bf_linear.cpp index 1b427b1..6daabe0 100644 --- a/functions/basis_functions/bf_linear.cpp +++ b/functions/basis_functions/bf_linear.cpp @@ -9,17 +9,17 @@ BF_Linear::BF_Linear(const Config &c): Function_Base(c) {} std::string BF_Linear::get_label() { return label; } -double BF_Linear::epredict(const t_type &weights, const aed_rctype& aed) +double BF_Linear::epredict(const t_type &weights, const aed_type2& aed) { return weights.transpose()*aed; } double BF_Linear::fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& , const size_t k) + const aed_type2& , const size_t k) { return -fdij.col(k).transpose() * weights; } force_type BF_Linear::fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& ) + const aed_type2& ) { return -Vec3d(fdij.transpose() * weights); } diff --git a/functions/basis_functions/bf_linear.h b/functions/basis_functions/bf_linear.h index 6355fbb..7548c38 100644 --- a/functions/basis_functions/bf_linear.h +++ b/functions/basis_functions/bf_linear.h @@ -9,10 +9,10 @@ struct BF_Linear: public virtual BF_Base BF_Linear(const Config &c); std::string get_label(); std::string label = "BF_Linear"; - double epredict(const t_type &weights, const aed_rctype& aed); + double epredict(const t_type &weights, const aed_type2& aed); double fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& aedi, const size_t k); + const aed_type2& aedi, const size_t k); force_type fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& aedi); + const aed_type2& aedi); }; #endif diff --git a/functions/basis_functions/bf_polynomial2.cpp b/functions/basis_functions/bf_polynomial2.cpp index 107b4c2..d30e522 100644 --- a/functions/basis_functions/bf_polynomial2.cpp +++ b/functions/basis_functions/bf_polynomial2.cpp @@ -10,19 +10,19 @@ std::string BF_Polynomial2::get_label() { return label; } -double BF_Polynomial2::epredict(const t_type &weights, const aed_rctype& aed) +double BF_Polynomial2::epredict(const t_type &weights, const aed_type2& aed) { size_t b=0; double res=0.0; - for (long int i=0; i<aed.size(); ++i) { - for (long int ii=i; ii<aed.size(); ++ii) { + for (size_t i=0; i<aed.size(); ++i) { + for (size_t ii=i; ii<aed.size(); ++ii) { res+= weights(b++)*aed(i)*aed(ii); } } return res; } double BF_Polynomial2::fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& aedi, const size_t k) + const aed_type2& aedi, const size_t k) { double res=0.0; size_t b=0; @@ -35,7 +35,7 @@ double BF_Polynomial2::fpredict(const t_type &weights, const fd_type &fdij, return res; } force_type BF_Polynomial2::fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& aedi) + const aed_type2& aedi) { force_type v; v.setZero(); diff --git a/functions/basis_functions/bf_polynomial2.h b/functions/basis_functions/bf_polynomial2.h index 65f4212..9508423 100644 --- a/functions/basis_functions/bf_polynomial2.h +++ b/functions/basis_functions/bf_polynomial2.h @@ -9,10 +9,10 @@ struct BF_Polynomial2: public virtual BF_Base BF_Polynomial2(const Config &c); std::string label = "BF_Polynomial2"; std::string get_label(); - double epredict(const t_type &weights, const aed_rctype& aed); + double epredict(const t_type &weights, const aed_type2& aed); double fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& aedi, const size_t k); + const aed_type2& aedi, const size_t k); force_type fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& aedi); + const aed_type2& aedi); }; #endif diff --git a/functions/function_base.h b/functions/function_base.h index 66d5823..e1f6c5b 100644 --- a/functions/function_base.h +++ b/functions/function_base.h @@ -30,19 +30,19 @@ struct Function_Base { virtual ~Function_Base() {}; // For Kernels - virtual double operator() (const aed_rctype& , const aed_rctype& ) { return 0.0; }; - virtual aed_type derivative(const aed_rctype& , const aed_rctype& ) { return aed_type(); }; - virtual double prime(const aed_rctype& , const aed_rctype& , - const aed_rctype& ) { return 0.0; } - virtual void set_basis(const aeds_type ) {}; + virtual double operator() (const aed_type2& , const aed_type2& ) { return 0.0; }; + virtual aed_type2 derivative(const aed_type2& , const aed_type2& ) { return aed_type2(); }; + virtual double prime(const aed_type2& , const aed_type2& , + const aed_type2& ) { return 0.0; } + virtual void set_basis(const aeds_type2 ) {}; /** \brief Return label of this object */ virtual std::string get_label()=0; - virtual double epredict(const t_type &, const aed_rctype& )=0; + virtual double epredict(const t_type &, const aed_type2& )=0; virtual double fpredict(const t_type &, const fd_type &, - const aed_rctype&, const size_t )=0; + const aed_type2&, const size_t )=0; virtual force_type fpredict(const t_type &, const fd_type &, - const aed_rctype& )=0; + const aed_type2& )=0; }; template<> inline Registry<Function_Base>::Map Registry<Function_Base>::registry{}; template<> inline Registry<Function_Base,Config&>::Map Registry<Function_Base,Config&>::registry{}; diff --git a/functions/kernels/kern_base.cpp b/functions/kernels/kern_base.cpp index 171af0c..6e132db 100644 --- a/functions/kernels/kern_base.cpp +++ b/functions/kernels/kern_base.cpp @@ -1,33 +1,33 @@ #include "kern_base.h" Kern_Base::~Kern_Base() {} -void Kern_Base::set_basis(const aeds_type b) +void Kern_Base::set_basis(const aeds_type2 b) { basis = b; } -double Kern_Base::epredict(const t_type &kweights, const aed_rctype &aed) +double Kern_Base::epredict(const t_type &kweights, const aed_type2 &aed) { double energy=0; - for (long int b=0; b<basis.cols(); ++b) { + for (size_t b=0; b<basis.cols(); ++b) { energy += kweights[b]*(*this)(basis.col(b),aed); } return energy; } double Kern_Base::fpredict(const t_type &kweights, const fd_type &fdij, - const aed_rctype &aedi, const size_t k) + const aed_type2 &aedi, const size_t k) { double res=0.0; - for (long int b=0; b<basis.cols(); ++b) { + for (size_t b=0; b<basis.cols(); ++b) { res -= kweights[b]*(*this).prime(basis.col(b),aedi,fdij.col(k)); } return res; } force_type Kern_Base::fpredict(const t_type &kweights, const fd_type &fdij, - const aed_rctype &aedi) + const aed_type2 &aedi) { force_type v; v.setZero(); - for (long int b=0; b<basis.cols(); ++b) { + for (size_t b=0; b<basis.cols(); ++b) { for (size_t k=0; k<3; ++k) { v(k) -= kweights[b]*(*this).prime(basis.col(b),aedi,fdij.col(k)); } diff --git a/functions/kernels/kern_base.h b/functions/kernels/kern_base.h index 4a62048..fc94fba 100644 --- a/functions/kernels/kern_base.h +++ b/functions/kernels/kern_base.h @@ -15,7 +15,7 @@ */ class Kern_Base: public virtual Function_Base { public: - aeds_type basis; + aeds_type2 basis; virtual ~Kern_Base(); /** @@ -24,7 +24,7 @@ class Kern_Base: public virtual Function_Base { * - b = basis vector * - af = atomic energy descriptor */ - virtual double operator() (const aed_rctype &b, const aed_rctype &af)=0; + virtual double operator() (const aed_type2 &b, const aed_type2 &af)=0; /** * Calculate the kernel derivative wrt to the second argument @@ -32,7 +32,7 @@ class Kern_Base: public virtual Function_Base { * - b = basis vector * - af = atomic energy descriptor */ - virtual aed_type derivative(const aed_rctype &b, const aed_rctype &af)=0; + virtual aed_type2 derivative(const aed_type2 &b, const aed_type2 &af)=0; /** * Calculate inner product of the kernel derivative @@ -43,16 +43,16 @@ class Kern_Base: public virtual Function_Base { * - ff = force descriptor (TODO i-th dir component of it) * TODO consider calculating all 3-directions at once */ - virtual double prime(const aed_rctype &b, const aed_rctype &af, - const aed_rctype &ff)=0; + virtual double prime(const aed_type2 &b, const aed_type2 &af, + const aed_type2 &ff)=0; /** \brief Set basis for calculations */ - virtual void set_basis(const aeds_type b); + virtual void set_basis(const aeds_type2 b); - virtual double epredict(const t_type &kweights, const aed_rctype &aed); + virtual double epredict(const t_type &kweights, const aed_type2 &aed); virtual double fpredict(const t_type &kweights, const fd_type &fdij, - const aed_rctype &aedi, const size_t k); + const aed_type2 &aedi, const size_t k); virtual force_type fpredict(const t_type &kweights, const fd_type &fdij, - const aed_rctype &aedi); + const aed_type2 &aedi); }; #endif diff --git a/functions/kernels/kern_linear.cpp b/functions/kernels/kern_linear.cpp index 3c80fb7..201cc34 100644 --- a/functions/kernels/kern_linear.cpp +++ b/functions/kernels/kern_linear.cpp @@ -7,15 +7,15 @@ Kern_Linear::Kern_Linear() {} Kern_Linear::Kern_Linear (const Config &c): Function_Base(c) {} -double Kern_Linear::operator() (const aed_rctype& b, const aed_rctype& af) +double Kern_Linear::operator() (const aed_type2& b, const aed_type2& af) { return b.transpose()*af;; } -aed_type Kern_Linear::derivative(const aed_rctype& b, const aed_rctype&) +aed_type2 Kern_Linear::derivative(const aed_type2& b, const aed_type2&) { return b; } -double Kern_Linear::prime(const aed_rctype& b, const aed_rctype& , const aed_rctype& ff) +double Kern_Linear::prime(const aed_type2& b, const aed_type2& , const aed_type2& ff) { // return derivative(b,af).transpose() * ff; return b.transpose() * ff; @@ -24,17 +24,17 @@ std::string Kern_Linear::get_label() { return label; } -double Kern_Linear::epredict(const t_type &weights, const aed_rctype& aed) +double Kern_Linear::epredict(const t_type &weights, const aed_type2& aed) { return weights.transpose()*aed; } double Kern_Linear::fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& , const size_t k) + const aed_type2& , const size_t k) { return -fdij.col(k).transpose() * weights; } force_type Kern_Linear::fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& ) + const aed_type2& ) { return -fdij.transpose() * weights; } diff --git a/functions/kernels/kern_linear.h b/functions/kernels/kern_linear.h index cbad9db..aa90767 100644 --- a/functions/kernels/kern_linear.h +++ b/functions/kernels/kern_linear.h @@ -22,15 +22,15 @@ class Kern_Linear : public virtual Kern_Base { * Label used for this class */ std::string label = "Kern_Linear"; - double operator() (const aed_rctype& b, const aed_rctype& af); - aed_type derivative(const aed_rctype& b, const aed_rctype& ); - double prime(const aed_rctype& b, const aed_rctype& af, const aed_rctype& ff); - void set_basis(const aeds_type ) {} + double operator() (const aed_type2& b, const aed_type2& af); + aed_type2 derivative(const aed_type2& b, const aed_type2& ); + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff); + void set_basis(const aeds_type2 ) {} - double epredict(const t_type &weights, const aed_rctype& aed); + double epredict(const t_type &weights, const aed_type2& aed); double fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& aedi, const size_t k); + const aed_type2& aedi, const size_t k); force_type fpredict(const t_type &weights, const fd_type &fdij, - const aed_rctype& aedi); + const aed_type2& aedi); }; #endif diff --git a/functions/kernels/kern_lq.cpp b/functions/kernels/kern_lq.cpp index 82b3db7..3b2f7ef 100644 --- a/functions/kernels/kern_lq.cpp +++ b/functions/kernels/kern_lq.cpp @@ -9,17 +9,17 @@ Kern_LQ::Kern_LQ (const Config &c): { if (get_verbose()) std::cout << std::endl << label << std::endl; } -double Kern_LQ::operator() (const aed_rctype& b, const aed_rctype& af) +double Kern_LQ::operator() (const aed_type2& b, const aed_type2& af) { double x = b.transpose()*af; return x*x + x; } -aed_type Kern_LQ::derivative(const aed_rctype& b, const aed_rctype& af) +aed_type2 Kern_LQ::derivative(const aed_type2& b, const aed_type2& af) { double temp = 2.0 * b.transpose()*af; return temp*b + b; } -double Kern_LQ::prime(const aed_rctype& b, const aed_rctype& af, const aed_rctype& ff) +double Kern_LQ::prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) { return derivative(b, af).transpose()*ff; } diff --git a/functions/kernels/kern_lq.h b/functions/kernels/kern_lq.h index 9d5bd19..62f582d 100644 --- a/functions/kernels/kern_lq.h +++ b/functions/kernels/kern_lq.h @@ -23,9 +23,9 @@ class Kern_LQ : public virtual Kern_Base { * Label used for this class */ std::string label = "Kern_LQ"; - double operator() (const aed_rctype& b, const aed_rctype& af); - aed_type derivative(const aed_rctype& b, const aed_rctype& af); - double prime(const aed_rctype& b, const aed_rctype& af, const aed_rctype& ff); + double operator() (const aed_type2& b, const aed_type2& af); + aed_type2 derivative(const aed_type2& b, const aed_type2& af); + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff); std::string get_label(); }; diff --git a/functions/kernels/kern_polynomial.cpp b/functions/kernels/kern_polynomial.cpp index 01dcf5e..4b2f5d1 100644 --- a/functions/kernels/kern_polynomial.cpp +++ b/functions/kernels/kern_polynomial.cpp @@ -13,15 +13,15 @@ Kern_Polynomial::Kern_Polynomial (const Config &c): if (get_verbose()) std::cout << std::endl << label << " | degree: " << d <<" | gamma: " << gamma << " | c: " << c << std::endl; } -double Kern_Polynomial::operator() (const aed_rctype& b, const aed_rctype& af) +double Kern_Polynomial::operator() (const aed_type2& b, const aed_type2& af) { - return std::pow(gamma*(b.dot(af))+c,d); + return std::pow(gamma*(b*af)+c,d); } -aed_type Kern_Polynomial::derivative(const aed_rctype& b, const aed_rctype& af) +aed_type2 Kern_Polynomial::derivative(const aed_type2& b, const aed_type2& af) { - return d*gamma*std::pow(gamma*(b.dot(af))+c,d-1)*b; + return d*gamma*std::pow(gamma*(b*af)+c,d-1)*b; } -double Kern_Polynomial::prime(const aed_rctype& b, const aed_rctype& af, const aed_rctype& ff) +double Kern_Polynomial::prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) { return derivative(b, af).transpose()*ff; } diff --git a/functions/kernels/kern_polynomial.h b/functions/kernels/kern_polynomial.h index 02bf262..4d281ce 100644 --- a/functions/kernels/kern_polynomial.h +++ b/functions/kernels/kern_polynomial.h @@ -26,9 +26,9 @@ class Kern_Polynomial : public virtual Kern_Base { */ std::string label = "Kern_Polynomial"; std::string get_label(); - double operator() (const aed_rctype& b, const aed_rctype& af); - aed_type derivative(const aed_rctype& b, const aed_rctype& af); - double prime(const aed_rctype& b, const aed_rctype& af, const aed_rctype& ff); + double operator() (const aed_type2& b, const aed_type2& af); + aed_type2 derivative(const aed_type2& b, const aed_type2& af); + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff); }; #endif diff --git a/functions/kernels/kern_quadratic.cpp b/functions/kernels/kern_quadratic.cpp index 0d61f73..60ba58c 100644 --- a/functions/kernels/kern_quadratic.cpp +++ b/functions/kernels/kern_quadratic.cpp @@ -9,17 +9,17 @@ Kern_Quadratic::Kern_Quadratic (const Config &c): { if (get_verbose()) std::cout << std::endl << label << std::endl; } -double Kern_Quadratic::operator() (const aed_rctype& b, const aed_rctype& af) +double Kern_Quadratic::operator() (const aed_type2& b, const aed_type2& af) { double x = b.transpose()*af; return x*x; } -aed_type Kern_Quadratic::derivative(const aed_rctype& b, const aed_rctype& af) +aed_type2 Kern_Quadratic::derivative(const aed_type2& b, const aed_type2& af) { double temp = 2.0 * b.transpose()*af; return b*temp;; } -double Kern_Quadratic::prime(const aed_rctype& b, const aed_rctype& af, const aed_rctype& ff) +double Kern_Quadratic::prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) { //return dot(derivative(b, af), ff); // it is faster this way diff --git a/functions/kernels/kern_quadratic.h b/functions/kernels/kern_quadratic.h index d9e886b..fef8b5b 100644 --- a/functions/kernels/kern_quadratic.h +++ b/functions/kernels/kern_quadratic.h @@ -21,9 +21,9 @@ class Kern_Quadratic : public virtual Kern_Base { * Label used for this class */ std::string label = "Kern_Quadratic"; - double operator() (const aed_rctype& b, const aed_rctype& af); - aed_type derivative(const aed_rctype& b, const aed_rctype& af); - double prime(const aed_rctype& b, const aed_rctype& af, const aed_rctype& ff); + double operator() (const aed_type2& b, const aed_type2& af); + aed_type2 derivative(const aed_type2& b, const aed_type2& af); + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff); std::string get_label(); }; diff --git a/functions/kernels/kern_rbf.cpp b/functions/kernels/kern_rbf.cpp index a96a935..b26dfe5 100644 --- a/functions/kernels/kern_rbf.cpp +++ b/functions/kernels/kern_rbf.cpp @@ -12,16 +12,16 @@ Kern_RBF::Kern_RBF (const Config &c): if (get_verbose()) std::cout << std::endl << label << " | sigma: " << sigma << " | gamma: " << gamma << std::endl; } -double Kern_RBF::operator() (const aed_rctype& b, const aed_rctype& af) +double Kern_RBF::operator() (const aed_type2& b, const aed_type2& af) { - const aed_type v = af-b; - return exp(-gamma*(v.dot(v))); + const aed_type2 v = af-b; + return exp(-gamma*(v*v)); } -aed_type Kern_RBF::derivative(const aed_rctype& b, const aed_rctype& af) +aed_type2 Kern_RBF::derivative(const aed_type2& b, const aed_type2& af) { return -2.0*gamma*(af-b)*(*this)(af,b); } -double Kern_RBF::prime(const aed_rctype& b, const aed_rctype& af, const aed_rctype& ff) +double Kern_RBF::prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) { return derivative(b, af).transpose()*ff; } diff --git a/functions/kernels/kern_rbf.h b/functions/kernels/kern_rbf.h index d91c493..6b76845 100644 --- a/functions/kernels/kern_rbf.h +++ b/functions/kernels/kern_rbf.h @@ -23,9 +23,9 @@ class Kern_RBF : public virtual Kern_Base { Kern_RBF (); Kern_RBF (const Config &c); std::string label = "Kern_RBF"; - double operator() (const aed_rctype& b, const aed_rctype& af); - aed_type derivative(const aed_rctype& b, const aed_rctype& af); - double prime(const aed_rctype& b, const aed_rctype& af, const aed_rctype& ff); + double operator() (const aed_type2& b, const aed_type2& af); + aed_type2 derivative(const aed_type2& b, const aed_type2& af); + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff); std::string get_label(); private: diff --git a/functions/kernels/kern_sigmoid.cpp b/functions/kernels/kern_sigmoid.cpp index 6f0c947..8ce2e83 100644 --- a/functions/kernels/kern_sigmoid.cpp +++ b/functions/kernels/kern_sigmoid.cpp @@ -12,15 +12,15 @@ Kern_Sigmoid::Kern_Sigmoid (const Config &c): if (get_verbose()) std::cout << std::endl << label << " | gamma: " << gamma << " | c: " << c << std::endl; } -double Kern_Sigmoid::operator() (const aed_rctype& b, const aed_rctype& af) +double Kern_Sigmoid::operator() (const aed_type2& b, const aed_type2& af) { - return std::tanh(gamma*(b.dot(af))+c); + return std::tanh(gamma*(b*af)+c); } -aed_type Kern_Sigmoid::derivative(const aed_rctype& b, const aed_rctype& af) +aed_type2 Kern_Sigmoid::derivative(const aed_type2& b, const aed_type2& af) { return gamma*(1.0-std::pow((*this)(af,b),2))*b; } -double Kern_Sigmoid::prime(const aed_rctype& b, const aed_rctype& af, const aed_rctype& ff) +double Kern_Sigmoid::prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) { return derivative(b, af).transpose()*ff; } diff --git a/functions/kernels/kern_sigmoid.h b/functions/kernels/kern_sigmoid.h index 600251a..e94c79a 100644 --- a/functions/kernels/kern_sigmoid.h +++ b/functions/kernels/kern_sigmoid.h @@ -24,9 +24,9 @@ class Kern_Sigmoid : public virtual Kern_Base { Kern_Sigmoid (); Kern_Sigmoid (const Config &c); std::string label = "Kern_Sigmoid"; - double operator() (const aed_rctype& b, const aed_rctype& af); - aed_type derivative(const aed_rctype& b, const aed_rctype& af); - double prime(const aed_rctype& b, const aed_rctype& af, const aed_rctype& ff); + double operator() (const aed_type2& b, const aed_type2& af); + aed_type2 derivative(const aed_type2& b, const aed_type2& af); + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff); std::string get_label(); }; diff --git a/m_core.h b/m_core.h index c2783bd..0d9c042 100644 --- a/m_core.h +++ b/m_core.h @@ -38,14 +38,14 @@ class M_Predict { * If aed contains sum over all nearest neighbours than the result is * a local atomic energy \f$ E_i \f$. * */ - virtual double epredict(const aed_rctype &aed)=0; + virtual double epredict(const aed_type2 &aed)=0; /** \brief Predict force between a pair of atoms in a k-direction. */ - virtual double fpredict(const fd_type &fdij, const aed_rctype &aedi, size_t k)=0; + virtual double fpredict(const fd_type &fdij, const aed_type2 &aedi, size_t k)=0; /** \brief Predict force between a pair of atoms. */ virtual force_type fpredict(const fd_type &fdij, - const aed_rctype &aedi)=0; + const aed_type2 &aedi)=0; }; class M_Train { public: diff --git a/m_krr_core.h b/m_krr_core.h index ff7b370..e228141 100644 --- a/m_krr_core.h +++ b/m_krr_core.h @@ -83,15 +83,15 @@ class M_KRR_Core: // M_KRR_Core<K>(kernel, c) // {} // -// double epredict(const aed_rctype &aed) { +// double epredict(const aed_type2 &aed) { // return kernel.epredict(weights,aed); // }; // -// double fpredict(const fd_type &fdij, const aed_rctype &aedi, const size_t k) { +// double fpredict(const fd_type &fdij, const aed_type2 &aedi, const size_t k) { // return kernel.fpredict(weights,fdij,aedi,k); // } // -// force_type fpredict(const fd_type &fdij, const aed_rctype &aedi) { +// force_type fpredict(const fd_type &fdij, const aed_type2 &aedi) { // return kernel.fpredict(weights,fdij,aedi).array(); // } // -- GitLab