diff --git a/src/core/ActionWithMatrix.cpp b/src/core/ActionWithMatrix.cpp index c8bdfe01b5..c67eb136ad 100644 --- a/src/core/ActionWithMatrix.cpp +++ b/src/core/ActionWithMatrix.cpp @@ -99,15 +99,15 @@ void ActionWithMatrix::setupMatrixStore() { } int ActionWithMatrix::checkTaskIsActive( const unsigned& itask ) const { - int nm = getNumberOfMasks(); if( nm<0 ) return 1; + int nm = getNumberOfMasks(); if( nm<0 ) return 1; // This checks for matrices that are masking some elements - unsigned nargs = getNumberOfArguments(); + unsigned nargs = getNumberOfArguments(); if( nm==1 && getPntrToArgument(nargs-1)->getRank()==2 ) return 1; for(unsigned j=nargs-nm; jgetRank()==1 ); - if( fabs(getPntrToArgument(j)->get(itask))>0 ) return 1; + plumed_assert( getPntrToArgument(j)->getRank()==1 ); + if( fabs(getPntrToArgument(j)->get(itask))>0 ) return 1; } return 0; } diff --git a/src/core/ActionWithVector.cpp b/src/core/ActionWithVector.cpp index ed93cfe9b1..e820f46ec7 100644 --- a/src/core/ActionWithVector.cpp +++ b/src/core/ActionWithVector.cpp @@ -80,29 +80,29 @@ ActionWithVector::ActionWithVector(const ActionOptions&ao): std::vector mask; parseArgumentList("MASK",mask); if( mask.size()>0 ) { if( nmask>=0 && getNumberOfArguments()==1 ) { - ActionWithVector* av=dynamic_cast( getPntrToArgument(0)->getPntrToAction() ); - plumed_massert( av, "input should be a vector from ActionWithVector" ); unsigned j=0, nargs = av->getNumberOfArguments(); - for(unsigned i=nargs-av->nmask; igetPntrToArgument(i)!=mask[j] ) error("the masks in subsequent actions do not match"); - j++; - } + ActionWithVector* av=dynamic_cast( getPntrToArgument(0)->getPntrToAction() ); + plumed_massert( av, "input should be a vector from ActionWithVector" ); unsigned j=0, nargs = av->getNumberOfArguments(); + for(unsigned i=nargs-av->nmask; igetPntrToArgument(i)!=mask[j] ) error("the masks in subsequent actions do not match"); + j++; + } } else if( nmask>=0 ) error("should not have a mask if you have read the mask keyword"); if( getNumberOfArguments()>0 && getPntrToArgument(0)->hasDerivatives() ) error("input for mask should be vector or matrix"); else if( mask[0]->getRank()==2 ) { - if( mask.size()>1 ) error("MASK should only have one argument"); - log.printf(" only computing elements of matrix that correspond to non-zero elements of matrix %s \n", mask[0]->getName().c_str() ); + if( mask.size()>1 ) error("MASK should only have one argument"); + log.printf(" only computing elements of matrix that correspond to non-zero elements of matrix %s \n", mask[0]->getName().c_str() ); } else if( mask[0]->getRank()==1 ) { - log.printf(" only computing elements of vector that correspond to non-zero elements of vectors %s", mask[0]->getName().c_str() ); - for(unsigned i=1; igetRank()!=1 ) { log.printf("\n"); error("input to mask should be vector"); } - log.printf(", %s", mask[i]->getName().c_str() ); - } - log.printf("\n"); + log.printf(" only computing elements of vector that correspond to non-zero elements of vectors %s", mask[0]->getName().c_str() ); + for(unsigned i=1; igetRank()!=1 ) { log.printf("\n"); error("input to mask should be vector"); } + log.printf(", %s", mask[i]->getName().c_str() ); + } + log.printf("\n"); } std::vector allargs( getArguments() ); nmask=mask.size(); - for(unsigned i=0; igetRank()==0 ) continue; - else if( myarg->getRank()==1 && !myarg->hasDerivatives() ) { - if( fabs(myarg->get(itask))>0 ) return 1; - } else plumed_merror("should not be in action " + getName() ); + Value* myarg = getPntrToArgument(i); + if( myarg->getRank()==0 ) continue; + else if( myarg->getRank()==1 && !myarg->hasDerivatives() ) { + if( fabs(myarg->get(itask))>0 ) return 1; + } else plumed_merror("should not be in action " + getName() ); } return -1; } @@ -451,24 +451,24 @@ std::vector& ActionWithVector::getListOfActiveTasks( ActionWithVector* unsigned ntasks=0; getNumberOfTasks( ntasks ); if( getenvChainForbidden()==Option::yes ) { - if( getNumberOfArguments()==0 ) { - active_tasks.resize( ntasks ); - for(unsigned i=0; i taskFlags( ntasks, -1 ); - for(unsigned i=0; i0 ) nt++; - } - active_tasks.resize(nt); nt=0; - for(unsigned i=0; i0 ) { active_tasks[nt]=i; nt++; } - } + if( getNumberOfArguments()==0 ) { + active_tasks.resize( ntasks ); + for(unsigned i=0; i taskFlags( ntasks, -1 ); + for(unsigned i=0; i0 ) nt++; + } + active_tasks.resize(nt); nt=0; + for(unsigned i=0; i0 ) { active_tasks[nt]=i; nt++; } + } + return active_tasks; + } unsigned stride=comm.Get_size(); unsigned rank=comm.Get_rank(); diff --git a/src/function/Bessel.cpp b/src/function/Bessel.cpp index 1eb0841c76..9d62badf49 100644 --- a/src/function/Bessel.cpp +++ b/src/function/Bessel.cpp @@ -90,8 +90,8 @@ void Bessel::registerKeywords(Keywords& keys) { void Bessel::read( ActionWithArguments* action ) { if( action->getNumberOfArguments()!=1 ) { - ActionWithVector* av = dynamic_cast( action ); - if( !av || (av && action->getNumberOfArguments()-av->getNumberOfMasks()!=1) ) action->error("should only be one argument to less_than actions"); + ActionWithVector* av = dynamic_cast( action ); + if( !av || (av && action->getNumberOfArguments()-av->getNumberOfMasks()!=1) ) action->error("should only be one argument to less_than actions"); } if( action->getPntrToArgument(0)->isPeriodic() ) action->error("cannot use this function on periodic functions"); action->parse("ORDER",order); action->log.printf(" computing %dth order bessel function \n", order ); diff --git a/src/function/Between.cpp b/src/function/Between.cpp index ffe5ee8cb6..5a59fb148a 100644 --- a/src/function/Between.cpp +++ b/src/function/Between.cpp @@ -76,8 +76,8 @@ void Between::registerKeywords(Keywords& keys) { void Between::read( ActionWithArguments* action ) { if( action->getNumberOfArguments()!=1 ) { - ActionWithVector* av = dynamic_cast( action ); - if( !av || (av && action->getNumberOfArguments()-av->getNumberOfMasks()!=1) ) action->error("should only be one argument to less_than actions"); + ActionWithVector* av = dynamic_cast( action ); + if( !av || (av && action->getNumberOfArguments()-av->getNumberOfMasks()!=1) ) action->error("should only be one argument to less_than actions"); } if( action->getNumberOfArguments()!=1 ) action->error("should only be one argument to between actions"); diff --git a/src/function/Custom.cpp b/src/function/Custom.cpp index 92cc15dcb0..aa84517878 100644 --- a/src/function/Custom.cpp +++ b/src/function/Custom.cpp @@ -345,10 +345,10 @@ bool Custom::checkIfMaskAllowed( const std::vector& args ) const { if( av && av->getNumberOfMasks()>=0 ) { unsigned nargs = av->getNumberOfArguments(), nm = av->getNumberOfMasks(); for(unsigned k=nargs-nm; kgetPntrToArgument( k ); - for(unsigned j=0; jgetPntrToArgument( k ); + for(unsigned j=0; j::getNumberOfColumns() const { template int FunctionOfMatrix::checkTaskIsActive( const unsigned& itask ) const { - const ActionWithVector* av=dynamic_cast( getPntrToArgument(0)->getPntrToAction() ); + const ActionWithVector* av=dynamic_cast( getPntrToArgument(0)->getPntrToAction() ); unsigned status=1; if( av ) status = av->checkTaskIsActive( itask ); for(unsigned i=1; i( getPntrToArgument(i)->getPntrToAction() ); - if( av && status!=av->checkTaskIsActive( itask ) ) plumed_merror("this doesn't work"); - } + const ActionWithVector* av=dynamic_cast( getPntrToArgument(i)->getPntrToAction() ); + if( av && status!=av->checkTaskIsActive( itask ) ) plumed_merror("this doesn't work"); + } return status; } diff --git a/src/function/LessThan.cpp b/src/function/LessThan.cpp index f25be7ced4..d4c390a153 100644 --- a/src/function/LessThan.cpp +++ b/src/function/LessThan.cpp @@ -78,8 +78,8 @@ void LessThan::registerKeywords(Keywords& keys) { void LessThan::read( ActionWithArguments* action ) { if( action->getNumberOfArguments()!=1 ) { - ActionWithVector* av = dynamic_cast( action ); - if( !av || (av && action->getNumberOfArguments()-av->getNumberOfMasks()!=1) ) action->error("should only be one argument to less_than actions"); + ActionWithVector* av = dynamic_cast( action ); + if( !av || (av && action->getNumberOfArguments()-av->getNumberOfMasks()!=1) ) action->error("should only be one argument to less_than actions"); } if( action->getPntrToArgument(0)->isPeriodic() ) action->error("cannot use this function on periodic functions"); diff --git a/src/function/MoreThan.cpp b/src/function/MoreThan.cpp index cd31c606ff..4bea127112 100644 --- a/src/function/MoreThan.cpp +++ b/src/function/MoreThan.cpp @@ -78,8 +78,8 @@ void MoreThan::registerKeywords(Keywords& keys) { void MoreThan::read( ActionWithArguments* action ) { if( action->getNumberOfArguments()!=1 ) { - ActionWithVector* av = dynamic_cast( action ); - if( !av || (av && action->getNumberOfArguments()-av->getNumberOfMasks()!=1) ) action->error("should only be one argument to less_than actions"); + ActionWithVector* av = dynamic_cast( action ); + if( !av || (av && action->getNumberOfArguments()-av->getNumberOfMasks()!=1) ) action->error("should only be one argument to less_than actions"); } if( action->getPntrToArgument(0)->isPeriodic() ) action->error("cannot use this function on periodic functions"); diff --git a/src/function/MoreThan.h b/src/function/MoreThan.h index b36aeaa61a..964a157570 100644 --- a/src/function/MoreThan.h +++ b/src/function/MoreThan.h @@ -34,7 +34,7 @@ class MoreThan : public FunctionTemplateBase { public: void registerKeywords( Keywords& keys ) override; void read( ActionWithArguments* action ) override; - bool checkIfMaskAllowed( const std::vector& args ) const override { return args.size()>1; } + bool checkIfMaskAllowed( const std::vector& args ) const override { return args.size()>1; } bool getDerivativeZeroIfValueIsZero() const override { return true; } void calc( const ActionWithArguments* action, const std::vector& args, std::vector& vals, Matrix& derivatives ) const override; }; diff --git a/src/matrixtools/MatrixTimesVector.cpp b/src/matrixtools/MatrixTimesVector.cpp index 64a600c0fb..addabc5a29 100644 --- a/src/matrixtools/MatrixTimesVector.cpp +++ b/src/matrixtools/MatrixTimesVector.cpp @@ -171,14 +171,14 @@ void MatrixTimesVector::prepare() { int MatrixTimesVector::checkTaskIsActive( const unsigned& itask ) const { if( getPntrToArgument(1)->getRank()==1 ) { - ActionWithMatrix* am=dynamic_cast( getPntrToArgument(0)->getPntrToAction() ); - plumed_assert( am ); return am->checkTaskIsActive(itask); + ActionWithMatrix* am=dynamic_cast( getPntrToArgument(0)->getPntrToAction() ); + plumed_assert( am ); return am->checkTaskIsActive(itask); } else { - unsigned n=getNumberOfArguments()-1; - for(unsigned i=0; i( getPntrToArgument(i)->getPntrToAction() ); - plumed_assert( am ); if( am->checkTaskIsActive(itask)>0 ) return 1; - } + unsigned n=getNumberOfArguments()-1; + for(unsigned i=0; i( getPntrToArgument(i)->getPntrToAction() ); + plumed_assert( am ); if( am->checkTaskIsActive(itask)>0 ) return 1; + } } } diff --git a/src/symfunc/CoordinationNumbers.cpp b/src/symfunc/CoordinationNumbers.cpp index 0fc891ea47..1b9fabd6ac 100644 --- a/src/symfunc/CoordinationNumbers.cpp +++ b/src/symfunc/CoordinationNumbers.cpp @@ -183,11 +183,11 @@ CoordinationNumbers::CoordinationNumbers(const ActionOptions& ao): readInputLine( getShortcutLabel() + ": MATRIX_VECTOR_PRODUCT ARG=" + matlab + "," + getShortcutLabel() + "_ones"); std::vector moments; parseVector("MOMENTS",moments); Tools::interpretRanges( moments ); if( moments.size()>0 ) { - readInputLine( getShortcutLabel() + "_caverage: MEAN ARG=" + getShortcutLabel() + " PERIODIC=NO"); - for(unsigned i=0; i keymap; multicolvar::MultiColvarShortcuts::readShortcutKeywords( keymap, this );