LCOV - code coverage report
Current view: top level - tools - LeptonCall.h (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 3 3 100.0 %
Date: 2026-11-05 10:19:04 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2012-2023 The plumed team
       3             :    (see the PEOPLE file at the root of the distribution for a list of names)
       4             : 
       5             :    See http://www.plumed.org for more information.
       6             : 
       7             :    This file is part of plumed, version 2.
       8             : 
       9             :    plumed is free software: you can redistribute it and/or modify
      10             :    it under the terms of the GNU Lesser General Public License as published by
      11             :    the Free Software Foundation, either version 3 of the License, or
      12             :    (at your option) any later version.
      13             : 
      14             :    plumed is distributed in the hope that it will be useful,
      15             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             :    GNU Lesser General Public License for more details.
      18             : 
      19             :    You should have received a copy of the GNU Lesser General Public License
      20             :    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
      21             : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
      22             : #ifndef __PLUMED_tools_LeptonCall_h
      23             : #define __PLUMED_tools_LeptonCall_h
      24             : 
      25             : #include "core/Action.h"
      26             : #include "lepton/Lepton.h"
      27             : #include "View.h"
      28             : 
      29             : namespace PLMD {
      30             : 
      31             : /// \ingroup TOOLBOX
      32             : class LeptonCall {
      33             : private:
      34             :   unsigned nargs{0};
      35             :   bool allow_extra_args{false};
      36             : /// The names of the variables
      37             :   std::vector<std::string> varnames;
      38             : /// Lepton expression.
      39             : /// \warning Since lepton::CompiledExpression is mutable, a vector is necessary for multithreading!
      40             :   std::vector<lepton::CompiledExpression> expression;
      41             : /// Lepton expression for derivative
      42             : /// \warning Since lepton::CompiledExpression is mutable, a vector is necessary for multithreading!
      43             :   std::vector<std::vector<lepton::CompiledExpression> > expression_deriv;
      44             :   std::vector<double*> lepton_ref;
      45             :   std::vector<double*> lepton_ref_deriv;
      46             : /// Point lepton_ref and lepton_ref_deriv to the variables of the expressions owned by this object
      47             :   void linkVariables();
      48             : public:
      49        7106 :   LeptonCall() = default;
      50             : /// A copy must not point to the variables of the original expressions
      51             :   LeptonCall(const LeptonCall&);
      52             :   LeptonCall& operator=(const LeptonCall&);
      53             : /// Moving the vectors keeps the expressions at the same address, so the references stay valid
      54          32 :   LeptonCall(LeptonCall&&) = default;
      55             :   LeptonCall& operator=(LeptonCall&&) = default;
      56             :   void set(const std::string & func,
      57             :            const std::vector<std::string>& var,
      58             :            Action* action=nullptr,
      59             :            bool extraArgs=false );
      60             :   unsigned getNumberOfArguments() const ;
      61             :   double evaluate( const std::vector<double>& args ) const ;
      62             :   double evaluate( View<const double> args ) const ;
      63             :   double evaluateDeriv( unsigned ider, View<const double> args ) const ;
      64             :   double evaluateDeriv( unsigned ider, const std::vector<double>& args ) const ;
      65             : };
      66             : 
      67             : inline
      68             : unsigned LeptonCall::getNumberOfArguments() const {
      69      567230 :   return nargs;
      70             : }
      71             : 
      72             : }
      73             : 
      74             : #endif
      75             : 

Generated by: LCOV version 1.16