diff --git a/include/tadah/models/functions/basis_functions/bf_base.h b/include/tadah/models/functions/basis_functions/bf_base.h index c68da2165b4f6a67c8ee3b6b91da4f9dc23b602f..19f76fbffd572123332908d8d010f243c5112797 100644 --- a/include/tadah/models/functions/basis_functions/bf_base.h +++ b/include/tadah/models/functions/basis_functions/bf_base.h @@ -8,11 +8,14 @@ /** \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_type2& ) const=0; - virtual double fpredict(const t_type &, const fd_type &, - const aed_type2& , const size_t ) const=0; - virtual force_type fpredict(const t_type &, const fd_type &, - const aed_type2& ) const=0; + BF_Base(); + BF_Base(const Config &c); + virtual ~BF_Base(); + + // virtual double epredict(const t_type &, const aed_type2& ) const=0; + // virtual double fpredict(const t_type &, const fd_type &, + // const aed_type2& , const size_t ) const=0; + // virtual force_type fpredict(const t_type &, const fd_type &, + // const aed_type2& ) const=0; }; #endif diff --git a/include/tadah/models/functions/basis_functions/bf_linear.h b/include/tadah/models/functions/basis_functions/bf_linear.h index ca3609797fb182f0e396132a22e7b44ef56297d4..4595199d8a8aa1fd4010e61eabc427bddeea5e13 100644 --- a/include/tadah/models/functions/basis_functions/bf_linear.h +++ b/include/tadah/models/functions/basis_functions/bf_linear.h @@ -24,7 +24,7 @@ struct BF_Linear : public virtual BF_Base { * @brief Retrieve the label of the basis function. * @return String label of the basis function. */ - std::string get_label() const; + std::string get_label() const override; std::string label = "BF_Linear"; ///< Label identifying the basis function. @@ -34,7 +34,7 @@ struct BF_Linear : public virtual BF_Base { * @param aed Atomic descriptors. * @return Predicted energy. */ - double epredict(const t_type &weights, const aed_type2 &aed) const; + double epredict(const t_type &weights, const aed_type2 &aed) const override; /** * @brief Predicts force for a specific dimension using the linear basis function. @@ -45,7 +45,7 @@ struct BF_Linear : public virtual BF_Base { * @return Predicted force component. */ double fpredict(const t_type &weights, const fd_type &fdij, - const aed_type2 &aedi, const size_t k) const; + const aed_type2 &aedi, const size_t k) const override; /** * @brief Predicts forces using the linear basis function. @@ -55,6 +55,6 @@ struct BF_Linear : public virtual BF_Base { * @return Predicted forces. */ force_type fpredict(const t_type &weights, const fd_type &fdij, - const aed_type2 &aedi) const; + const aed_type2 &aedi) const override; }; #endif diff --git a/include/tadah/models/functions/basis_functions/bf_polynomial2.h b/include/tadah/models/functions/basis_functions/bf_polynomial2.h index f8dcd9f6d29f69e47bbf20a6a4160c0a71a47489..59400d5b55a2bbaa46c686529dd6d4acba35547e 100644 --- a/include/tadah/models/functions/basis_functions/bf_polynomial2.h +++ b/include/tadah/models/functions/basis_functions/bf_polynomial2.h @@ -26,7 +26,7 @@ struct BF_Polynomial2 : public virtual BF_Base { * @brief Retrieve the label of the basis function. * @return String label of the basis function. */ - std::string get_label() const; + std::string get_label() const override; /** * @brief Predicts energy using the polynomial basis function. @@ -34,7 +34,7 @@ struct BF_Polynomial2 : public virtual BF_Base { * @param aed Atomic descriptors. * @return Predicted energy. */ - double epredict(const t_type &weights, const aed_type2 &aed) const; + double epredict(const t_type &weights, const aed_type2 &aed) const override; /** * @brief Predicts force for a specific dimension using the polynomial basis function. @@ -45,7 +45,7 @@ struct BF_Polynomial2 : public virtual BF_Base { * @return Predicted force component. */ double fpredict(const t_type &weights, const fd_type &fdij, - const aed_type2 &aedi, const size_t k) const; + const aed_type2 &aedi, const size_t k) const override; /** * @brief Predicts forces using the polynomial basis function. @@ -55,6 +55,6 @@ struct BF_Polynomial2 : public virtual BF_Base { * @return Predicted forces. */ force_type fpredict(const t_type &weights, const fd_type &fdij, - const aed_type2 &aedi) const; + const aed_type2 &aedi) const override; }; #endif diff --git a/include/tadah/models/functions/function_base.h b/include/tadah/models/functions/function_base.h index 01d73b7d9789b40d38ab52fed24dd0605a690024..d9486c8a36c63cb034798849e73a337905173df3 100644 --- a/include/tadah/models/functions/function_base.h +++ b/include/tadah/models/functions/function_base.h @@ -8,35 +8,31 @@ /** Base class for Kernels and Basis Functions */ struct Function_Base { - private: - int verbose; - - public: - Function_Base() { - verbose=0; - } - Function_Base(const Config &c) { - verbose = c.get<int>("VERBOSE"); - } - void set_verbose(int v) { verbose=v; } - int get_verbose() { return verbose; } - - // Derived classes must implement Derived() and Derived(Config) - virtual ~Function_Base() {}; - - // For Kernels - 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 Matrix ) {}; - - /** \brief Return label of this object */ - virtual std::string get_label() const=0; - virtual double epredict(const t_type &, const aed_type2& ) const=0; - virtual double fpredict(const t_type &, const fd_type &, - const aed_type2&, const size_t ) const=0; - virtual force_type fpredict(const t_type &, const fd_type &, - const aed_type2& ) const=0; +private: + int verbose; + +public: + Function_Base(); + Function_Base(const Config &c); + void set_verbose(int v); + int get_verbose(); + + // Derived classes must implement Derived() and Derived(Config) + virtual ~Function_Base(); + + // For Kernels + virtual double operator() (const aed_type2& , const aed_type2& ) const; + virtual aed_type2 derivative(const aed_type2& , const aed_type2& ) const; + virtual double prime(const aed_type2& , const aed_type2& , + const aed_type2& ) const; + virtual void set_basis(const Matrix ); + + /** \brief Return label of this object */ + virtual std::string get_label() const=0; + virtual double epredict(const t_type &, const aed_type2& ) const=0; + virtual double fpredict(const t_type &, const fd_type &, + const aed_type2&, const size_t ) const=0; + virtual force_type fpredict(const t_type &, const fd_type &, + const aed_type2& ) const=0; }; #endif diff --git a/include/tadah/models/functions/kernels/kern_base.h b/include/tadah/models/functions/kernels/kern_base.h index 41da02ea2f2218cdf862763fc03aabf32f8fa25a..aac4d9494aa0afb08ccd0c2072ed38108ca0d622 100644 --- a/include/tadah/models/functions/kernels/kern_base.h +++ b/include/tadah/models/functions/kernels/kern_base.h @@ -16,22 +16,24 @@ class Kern_Base: public virtual Function_Base { public: Matrix basis; + Kern_Base(); + Kern_Base(const Config &c); virtual ~Kern_Base(); - /** - * Calculate kernel value given two vectors - * - * - b = basis vector - * - af = atomic energy descriptor - */ + // /** + // * Calculate kernel value given two vectors + // * + // * - b = basis vector + // * - af = atomic energy descriptor + // */ virtual double operator() (const aed_type2 &b, const aed_type2 &af) const=0; - - /** - * Calculate the kernel derivative wrt to the second argument - * - * - b = basis vector - * - af = atomic energy descriptor - */ + // + // /** + // * Calculate the kernel derivative wrt to the second argument + // * + // * - b = basis vector + // * - af = atomic energy descriptor + // */ virtual aed_type2 derivative(const aed_type2 &b, const aed_type2 &af) const=0; /** diff --git a/include/tadah/models/functions/kernels/kern_linear.h b/include/tadah/models/functions/kernels/kern_linear.h index 697d85f8f3466cc6b1f6cf5bba8068a302513168..83090cb40381f42c246c2a317ae9d93a18d91394 100644 --- a/include/tadah/models/functions/kernels/kern_linear.h +++ b/include/tadah/models/functions/kernels/kern_linear.h @@ -18,21 +18,21 @@ class Kern_Linear : public virtual Kern_Base { public: Kern_Linear (); Kern_Linear (const Config &c); - std::string get_label() const; + std::string get_label() const override; /** * Label used for this class */ std::string label = "Kern_Linear"; - double operator() (const aed_type2& b, const aed_type2& af) const; - aed_type2 derivative(const aed_type2& b, const aed_type2& ) const; - double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const; - void set_basis(const Matrix ) {} + double operator() (const aed_type2& b, const aed_type2& af) const override; + aed_type2 derivative(const aed_type2& b, const aed_type2& ) const override; + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const override; + void set_basis(const Matrix ) override {} - double epredict(const t_type &weights, const aed_type2& aed) const; + double epredict(const t_type &weights, const aed_type2& aed) const override; double fpredict(const t_type &weights, const fd_type &fdij, - const aed_type2& aedi, const size_t k) const; + const aed_type2& aedi, const size_t k) const override; force_type fpredict(const t_type &weights, const fd_type &fdij, - const aed_type2& aedi) const; + const aed_type2& aedi) const override; }; #endif diff --git a/include/tadah/models/functions/kernels/kern_lq.h b/include/tadah/models/functions/kernels/kern_lq.h index 7dbfb7edeadf128662464313a18bbb4a02576b0e..126da98fd5c130e76cab7ab65129c5c550bccbcf 100644 --- a/include/tadah/models/functions/kernels/kern_lq.h +++ b/include/tadah/models/functions/kernels/kern_lq.h @@ -24,10 +24,10 @@ class Kern_LQ : public virtual Kern_Base { * Label used for this class */ std::string label = "Kern_LQ"; - double operator() (const aed_type2& b, const aed_type2& af) const; - aed_type2 derivative(const aed_type2& b, const aed_type2& af) const; - double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const; - std::string get_label() const; + double operator() (const aed_type2& b, const aed_type2& af) const override; + aed_type2 derivative(const aed_type2& b, const aed_type2& af) const override; + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const override; + std::string get_label() const override; }; #endif diff --git a/include/tadah/models/functions/kernels/kern_polynomial.h b/include/tadah/models/functions/kernels/kern_polynomial.h index 246724921c4705196fa72f9ad360c6ec515d5f64..cc105abfd1774b9f663236e168bda3f4430e2e94 100644 --- a/include/tadah/models/functions/kernels/kern_polynomial.h +++ b/include/tadah/models/functions/kernels/kern_polynomial.h @@ -27,10 +27,10 @@ class Kern_Polynomial : public virtual Kern_Base { * Label used for this class */ std::string label = "Kern_Polynomial"; - std::string get_label() const; - double operator() (const aed_type2& b, const aed_type2& af) const; - aed_type2 derivative(const aed_type2& b, const aed_type2& af) const; - double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const; + std::string get_label() const override; + double operator() (const aed_type2& b, const aed_type2& af) const override; + aed_type2 derivative(const aed_type2& b, const aed_type2& af) const override; + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const override; }; #endif diff --git a/include/tadah/models/functions/kernels/kern_quadratic.h b/include/tadah/models/functions/kernels/kern_quadratic.h index 187c3e8ccd3564c2ec2edd5a9e202e6acbae96f4..150efa1765b177e2005da12e158ee5f1ed99aa18 100644 --- a/include/tadah/models/functions/kernels/kern_quadratic.h +++ b/include/tadah/models/functions/kernels/kern_quadratic.h @@ -23,10 +23,10 @@ class Kern_Quadratic : public virtual Kern_Base { * Label used for this class */ std::string label = "Kern_Quadratic"; - double operator() (const aed_type2& b, const aed_type2& af) const; - aed_type2 derivative(const aed_type2& b, const aed_type2& af) const; - double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const; - std::string get_label() const; + double operator() (const aed_type2& b, const aed_type2& af) const override; + aed_type2 derivative(const aed_type2& b, const aed_type2& af) const override; + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const override; + std::string get_label() const override; }; #endif diff --git a/include/tadah/models/functions/kernels/kern_rbf.h b/include/tadah/models/functions/kernels/kern_rbf.h index 340d45726dc400c9dd2e9024ed65e70073621e28..b746bd3b4e3c16db9a1eff66eb9a723570fd9f1c 100644 --- a/include/tadah/models/functions/kernels/kern_rbf.h +++ b/include/tadah/models/functions/kernels/kern_rbf.h @@ -25,10 +25,10 @@ class Kern_RBF : public virtual Kern_Base { Kern_RBF (); Kern_RBF (const Config &c); std::string label = "Kern_RBF"; - double operator() (const aed_type2& b, const aed_type2& af) const; - aed_type2 derivative(const aed_type2& b, const aed_type2& af) const; - double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const; - std::string get_label() const; + double operator() (const aed_type2& b, const aed_type2& af) const override; + aed_type2 derivative(const aed_type2& b, const aed_type2& af) const override; + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const override; + std::string get_label() const override; private: double gamma; diff --git a/include/tadah/models/functions/kernels/kern_sigmoid.h b/include/tadah/models/functions/kernels/kern_sigmoid.h index 7f9c0f6971288943b1a0281ea8eff531197c02a2..072f20850127b2c84f0b0cdfacd88f281ba5d5b2 100644 --- a/include/tadah/models/functions/kernels/kern_sigmoid.h +++ b/include/tadah/models/functions/kernels/kern_sigmoid.h @@ -26,10 +26,10 @@ class Kern_Sigmoid : public virtual Kern_Base { Kern_Sigmoid (); Kern_Sigmoid (const Config &c); std::string label = "Kern_Sigmoid"; - double operator() (const aed_type2& b, const aed_type2& af) const; - aed_type2 derivative(const aed_type2& b, const aed_type2& af) const; - double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const; - std::string get_label() const; + double operator() (const aed_type2& b, const aed_type2& af) const override; + aed_type2 derivative(const aed_type2& b, const aed_type2& af) const override; + double prime(const aed_type2& b, const aed_type2& af, const aed_type2& ff) const override; + std::string get_label() const override; }; #endif diff --git a/src/bf_base.cpp b/src/bf_base.cpp index 043999f13df608d87e3e3898b943daa3162dd772..67b6d57af50cb9b0971b8fec95e4800b667e70cd 100644 --- a/src/bf_base.cpp +++ b/src/bf_base.cpp @@ -1,2 +1,4 @@ #include <tadah/models/functions/basis_functions/bf_base.h> +BF_Base::BF_Base(const Config &c): Function_Base(c) {} +BF_Base::BF_Base() {} BF_Base::~BF_Base() {} diff --git a/src/bf_linear.cpp b/src/bf_linear.cpp index 50a612bc42f3b25e6e61d4f12d56e288689f6a56..b9e73ce1391d611f3ff9a5a3cbaf0998ccee40e0 100644 --- a/src/bf_linear.cpp +++ b/src/bf_linear.cpp @@ -1,7 +1,7 @@ #include <tadah/models/functions/basis_functions/bf_linear.h> BF_Linear::BF_Linear() {} -BF_Linear::BF_Linear(const Config &c): Function_Base(c) {} +BF_Linear::BF_Linear(const Config &c): BF_Base(c) {} std::string BF_Linear::get_label() const { return label; } diff --git a/src/bf_polynomial2.cpp b/src/bf_polynomial2.cpp index 8d6e6fc037e11220fa1dd03e0541a2fc090bcfab..387e3f1b7a2325b2d242b5e5173f160e5967959c 100644 --- a/src/bf_polynomial2.cpp +++ b/src/bf_polynomial2.cpp @@ -1,8 +1,7 @@ #include <tadah/models/functions/basis_functions/bf_polynomial2.h> - BF_Polynomial2::BF_Polynomial2() {} -BF_Polynomial2::BF_Polynomial2(const Config &c): Function_Base(c) +BF_Polynomial2::BF_Polynomial2(const Config &c): BF_Base(c) {} std::string BF_Polynomial2::get_label() const { diff --git a/src/function_base.cpp b/src/function_base.cpp index 8e80b849351153537c6986563dac26e5d447d3b7..748af7150e9b22136d23182491eb85b7471c575e 100644 --- a/src/function_base.cpp +++ b/src/function_base.cpp @@ -1,2 +1,17 @@ #include <tadah/models/functions/function_base.h> +Function_Base::Function_Base(): verbose(0) { +} +Function_Base::Function_Base(const Config &c) { + verbose = (c.exist("VERBOSE")) ? c.get<int>("VERBOSE") : 0; +} +void Function_Base::set_verbose(int v) { verbose=v; } +int Function_Base::get_verbose() { return verbose; } + +Function_Base::~Function_Base() {}; + +double Function_Base::operator() (const aed_type2& , const aed_type2& ) const {std::cout << "FB" <<std::endl; return 0.0; }; +aed_type2 Function_Base::derivative(const aed_type2& , const aed_type2& ) const { return aed_type2(); }; +double Function_Base::prime(const aed_type2& , const aed_type2& , + const aed_type2& ) const { return 0.0; } +void Function_Base::set_basis(const Matrix ) {}; diff --git a/src/kern_base.cpp b/src/kern_base.cpp index 557cfd1964a3ee8c9c5fa0c8b5bafa1e92a62c6a..105de45340ec32f3919c7b39d47a3cadb395aae8 100644 --- a/src/kern_base.cpp +++ b/src/kern_base.cpp @@ -1,5 +1,7 @@ #include <tadah/models/functions/kernels/kern_base.h> +Kern_Base::Kern_Base() {} +Kern_Base::Kern_Base(const Config &c): Function_Base(c) {} Kern_Base::~Kern_Base() {} void Kern_Base::set_basis(const Matrix b) { diff --git a/src/kern_linear.cpp b/src/kern_linear.cpp index 52e6ee0563c58b64a160b6a9bad9cc9232700047..ef7203811c10655e88d03e727c3c8f18584713c4 100644 --- a/src/kern_linear.cpp +++ b/src/kern_linear.cpp @@ -2,7 +2,7 @@ Kern_Linear::Kern_Linear() {} Kern_Linear::Kern_Linear (const Config &c): - Function_Base(c) + Kern_Base(c) {} double Kern_Linear::operator() (const aed_type2& b, const aed_type2& af) const { diff --git a/src/kern_lq.cpp b/src/kern_lq.cpp index 4a4733d011ff47b9435e762fd3401ae418215680..7bb370ae41895f847b6b9e560cd2015ab2e67106 100644 --- a/src/kern_lq.cpp +++ b/src/kern_lq.cpp @@ -2,7 +2,7 @@ Kern_LQ::Kern_LQ () {} Kern_LQ::Kern_LQ (const Config &c): - Function_Base(c) + Kern_Base(c) { if (get_verbose()) std::cout << std::endl << label << std::endl; read_basis_from_config(c,basis); diff --git a/src/kern_polynomial.cpp b/src/kern_polynomial.cpp index cdc3a625f99ec1c14eaaa0c58015e87305256a2a..84a615b731177a19ccd84a9cdb900a3646c1dc0e 100644 --- a/src/kern_polynomial.cpp +++ b/src/kern_polynomial.cpp @@ -2,7 +2,7 @@ Kern_Polynomial::Kern_Polynomial () {} Kern_Polynomial::Kern_Polynomial (const Config &config): - Function_Base(config), + Kern_Base(config), d(config.get<int>("MPARAMS",0)), gamma(config.get<double>("MPARAMS",1)), c(config.get<double>("MPARAMS",2)) diff --git a/src/kern_quadratic.cpp b/src/kern_quadratic.cpp index 1f1961533c5c63c898296cd8938ab3cc39f224ab..3852a96e8a228f91bcd7a48134eb3e71d4a4e5d9 100644 --- a/src/kern_quadratic.cpp +++ b/src/kern_quadratic.cpp @@ -2,7 +2,7 @@ Kern_Quadratic::Kern_Quadratic () {} Kern_Quadratic::Kern_Quadratic (const Config &c): - Function_Base(c) + Kern_Base(c) { if (get_verbose()) std::cout << std::endl << label << std::endl; diff --git a/src/kern_rbf.cpp b/src/kern_rbf.cpp index f8fb5132de4cfb39388febf24eb8f75d315a514d..9a374ac8333d425a8c76b5e645f8b8a3ef5fdd2f 100644 --- a/src/kern_rbf.cpp +++ b/src/kern_rbf.cpp @@ -2,7 +2,7 @@ Kern_RBF::Kern_RBF () {} Kern_RBF::Kern_RBF (const Config &c): - Function_Base(c), + Kern_Base(c), sigma(c.get<double>("MPARAMS")), gamma(1.0/(2.0*sigma*sigma)) { diff --git a/src/kern_sigmoid.cpp b/src/kern_sigmoid.cpp index b3fbd49b57b8d9b5cfe75cc9e0609910c6608af0..1586030a5628a3bbd007a6015d06264451ed35af 100644 --- a/src/kern_sigmoid.cpp +++ b/src/kern_sigmoid.cpp @@ -2,7 +2,7 @@ Kern_Sigmoid::Kern_Sigmoid () {} Kern_Sigmoid::Kern_Sigmoid (const Config &config): - Function_Base(config), + Kern_Base(config), gamma(config.get<double>("MPARAMS",0)), c(config.get<double>("MPARAMS",1)) {