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

          Line data    Source code
       1             : 
       2             : /* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       3             :    Copyright (c) 2011-2023 The plumed team
       4             :    (see the PEOPLE file at the root of the distribution for a list of names)
       5             : 
       6             :    See http://www.plumed.org for more information.
       7             : 
       8             :    This file is part of plumed, version 2.
       9             : 
      10             :    plumed is free software: you can redistribute it and/or modify
      11             :    it under the terms of the GNU Lesser General Public License as published by
      12             :    the Free Software Foundation, either version 3 of the License, or
      13             :    (at your option) any later version.
      14             : 
      15             :    plumed is distributed in the hope that it will be useful,
      16             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      17             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18             :    GNU Lesser General Public License for more details.
      19             : 
      20             :    You should have received a copy of the GNU Lesser General Public License
      21             :    along with plumed.  If not, see <http://www.gnu.org/licenses/>.
      22             : +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
      23             : #ifndef __PLUMED_matrixtools_MatrixProduct_h
      24             : #define __PLUMED_matrixtools_MatrixProduct_h
      25             : #include "MatrixTimesMatrix.h"
      26             : 
      27             : namespace PLMD {
      28             : namespace matrixtools {
      29             : 
      30             : struct MatrixProduct {
      31             :   static void registerKeywords( Keywords& keys );
      32             :   template <typename PTM>
      33             :   void setup( MatrixTimesMatrix<MatrixProduct,PTM>* action,
      34             :               const Value* myval ) {}
      35             :   static void calculate( bool noderiv,
      36             :                          const MatrixProduct& actdata,
      37             :                          const InputVectors& vectors,
      38             :                          MatrixElementOutput& output );
      39             : #ifdef __PLUMED_HAS_OPENACC
      40             :   void toACCDevice() const {
      41             : #pragma acc enter data copyin(this[0:1])
      42             :   }
      43             :   void removeFromACCDevice() const {
      44             : #pragma acc exit data delete(this[0:1])
      45             :   }
      46             : #endif //__PLUMED_HAS_OPENACC
      47             : };
      48             : 
      49             : 
      50         287 : void MatrixProduct::registerKeywords( Keywords& keys ) {
      51         287 :   keys.setDisplayName("MATRIX_PRODUCT");
      52         574 :   keys.setValueDescription("matrix","the product of the two input matrices");
      53         287 :   keys.addFlag("ELEMENTS_ON_DIAGONAL_ARE_ZERO",false,"set all diagonal elements to zero");
      54         287 : }
      55             : 
      56      930780 : void MatrixProduct::calculate(  const bool noderiv,
      57             :                                 const MatrixProduct& actdata,
      58             :                                 const InputVectors& vectors,
      59             :                                 MatrixElementOutput& output ) {
      60    22637674 :   for(unsigned i=0; i<vectors.nelem; ++i) {
      61    21706894 :     output.values[0] += vectors.arg1[i]*vectors.arg2[i];
      62    21706894 :     output.derivs[0][i] = vectors.arg2[i];
      63    21706894 :     output.derivs[0][vectors.vec2start+i] = vectors.arg1[i];
      64             :   }
      65      930780 : }
      66             : } //namespace matrixtools
      67             : } //PLMD
      68             : #endif //__PLUMED_matrixtools_MatrixProduct_h

Generated by: LCOV version 1.16