LCOV - code coverage report
Current view: top level - function - Product.cpp (source / functions) Hit Total Coverage
Test: plumed test coverage Lines: 16 16 100.0 %
Date: 2025-04-08 21:11:17 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       2             :    Copyright (c) 2014-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             : #include "core/ActionRegister.h"
      23             : #include "core/ActionShortcut.h"
      24             : 
      25             : //+PLUMEDOC FUNCTION PRODUCT
      26             : /*
      27             : Calculate the product of the input quantities
      28             : 
      29             : This shortcut can be used to calculate the product of a collection of scalar inputs as illustrated by the following
      30             : simple example.
      31             : 
      32             : ```plumed
      33             : d1: DISTANCE ATOMS=1,2
      34             : d2: DISTANCE ATOMS=3,4
      35             : p: PRODUCT ARG=d1,d2
      36             : ```
      37             : 
      38             : This action is currently only used in the [DETERMINANT](DETERMINANT.md) shortcut. In that
      39             : action the determinant of the input square matrix is found by finding the eigenvalues of the
      40             : input matrix using [DIAGONALIZE](DIAGONALIZE.md). The determinant is then found by evaluating
      41             : the product of these eigenvalues.
      42             : 
      43             : */
      44             : //+ENDPLUMEDOC
      45             : 
      46             : namespace PLMD {
      47             : namespace function {
      48             : 
      49             : class Product : public ActionShortcut {
      50             : public:
      51             :   static void registerKeywords( Keywords& keys );
      52             :   explicit Product(const ActionOptions&ao);
      53             : };
      54             : 
      55             : PLUMED_REGISTER_ACTION(Product,"PRODUCT")
      56             : 
      57         129 : void Product::registerKeywords( Keywords& keys ) {
      58         129 :   ActionShortcut::registerKeywords(keys);
      59         129 :   keys.add("compulsory","ARG","The set of scalars that you would like to multiply together");
      60         258 :   keys.setValueDescription("scalar","the product of all the elements in the input vector");
      61         129 :   keys.needsAction("CONCATENATE");
      62         129 :   keys.needsAction("CUSTOM");
      63         129 :   keys.needsAction("SUM");
      64         129 : }
      65             : 
      66         114 : Product::Product( const ActionOptions& ao):
      67             :   Action(ao),
      68         114 :   ActionShortcut(ao) {
      69             :   std::string arg;
      70         114 :   parse("ARG",arg);
      71         228 :   readInputLine( getShortcutLabel() + "_vec: CONCATENATE ARG=" + arg );
      72         228 :   readInputLine( getShortcutLabel() + "_logs: CUSTOM ARG=" + getShortcutLabel() + "_vec FUNC=log(x) PERIODIC=NO");
      73         228 :   readInputLine( getShortcutLabel() + "_logsum: SUM ARG=" + getShortcutLabel() + "_logs PERIODIC=NO");
      74         228 :   readInputLine( getShortcutLabel() + ": CUSTOM ARG=" + getShortcutLabel() + "_logsum FUNC=exp(x) PERIODIC=NO");
      75         114 : }
      76             : 
      77             : }
      78             : }

Generated by: LCOV version 1.16