diff --git a/src/core/ActionWithMatrix.cpp b/src/core/ActionWithMatrix.cpp index 9250aa9f67..6cd26945f0 100644 --- a/src/core/ActionWithMatrix.cpp +++ b/src/core/ActionWithMatrix.cpp @@ -91,7 +91,7 @@ const ActionWithMatrix* ActionWithMatrix::getFirstMatrixInChain() const { void ActionWithMatrix::setupMatrixStore() { for(int i=0; igetRank()!=2 || myval->hasDerivatives() || !myval->valueIsStored() ) continue; myval->reshapeMatrixStore( getNumberOfColumns() ); } diff --git a/src/core/ActionWithVector.cpp b/src/core/ActionWithVector.cpp index ab1f1e61cf..2bdf064a1a 100644 --- a/src/core/ActionWithVector.cpp +++ b/src/core/ActionWithVector.cpp @@ -729,7 +729,7 @@ void ActionWithVector::runTask( const unsigned& current, MultiValue& myvals ) co for(unsigned i=0; ihasDerivatives() || !myval->valueIsStored() ) continue; - Value* myv = const_cast( myval ); + Value* myv = const_cast( myval ); if( getName()=="RMSD_VECTOR" && myv->getRank()==2 ) continue; myv->set( current, myvals.get( myval->getPositionInStream() ) ); } diff --git a/src/core/ActionWithVector.h b/src/core/ActionWithVector.h index 95cadaee59..ec12409140 100644 --- a/src/core/ActionWithVector.h +++ b/src/core/ActionWithVector.h @@ -139,7 +139,7 @@ class ActionWithVector: const ActionWithVector* getFirstActionInChain() const ; ActionWithVector* getFirstActionInChain(); /// Get the list of tasks that are active - virtual std::vector& getListOfActiveTasks( ActionWithVector* action ); + virtual std::vector& getListOfActiveTasks( ActionWithVector* action ); /// This is overridden in ActionWithMatrix virtual void getAllActionLabelsInMatrixChain( std::vector& matchain ) const {} /// Get the number of derivatives in the stream diff --git a/src/crystdistrib/QuaternionBondProductMatrix.cpp b/src/crystdistrib/QuaternionBondProductMatrix.cpp index 59a2a0258d..22eae5cc85 100644 --- a/src/crystdistrib/QuaternionBondProductMatrix.cpp +++ b/src/crystdistrib/QuaternionBondProductMatrix.cpp @@ -128,9 +128,9 @@ std::vector& QuaternionBondProductMatrix::getListOfActiveTasks( Action Value* myarg = getPntrToArgument(4); unsigned base=0; unsigned nrows = myarg->getShape()[0]; for(unsigned i=0; igetRowLength(i); - for(unsigned j=0; jgetNumberOfColumns(); + unsigned ncols = myarg->getRowLength(i); + for(unsigned j=0; jgetNumberOfColumns(); } return active_tasks; } @@ -144,11 +144,11 @@ void QuaternionBondProductMatrix::performTask( const unsigned& taskno, MultiValu //[dit/dw1 dit/di1 dit/dj1 dit/dk1] etc, and dqt[1] is w.r.t the vector-turned-quaternion called bond // Retrieve the quaternion - for(unsigned i=0; i<4; ++i) quat[i] = getPntrToArgument(i)->get(index1); + for(unsigned i=0; i<4; ++i) quat[i] = getPntrToArgument(i)->get(index1); // Retrieve the components of the matrix double weight = getPntrToArgument(4)->get(taskno, false ); - for(unsigned i=1; i<4; ++i) bond[i] = getPntrToArgument(4+i)->get(taskno, false ); + for(unsigned i=1; i<4; ++i) bond[i] = getPntrToArgument(4+i)->get(taskno, false ); // calculate normalization factor bond[0]=0.0; @@ -328,7 +328,7 @@ void QuaternionBondProductMatrix::calculate() { // Copy bookeeping arrays from input matrices to output matrices for(unsigned i=0; i<4; ++i) getPntrToComponent(i)->copyBookeepingArrayFromArgument( getPntrToArgument(4+i) ); runAllTasks(); -} +} } } diff --git a/src/function/Custom.cpp b/src/function/Custom.cpp index 1a03f3cbc0..192e41b68e 100644 --- a/src/function/Custom.cpp +++ b/src/function/Custom.cpp @@ -274,7 +274,7 @@ void Custom::registerKeywords(Keywords& keys) { void Custom::read( ActionWithArguments* action ) { // Read in the variables - unsigned nargs = action->getNumberOfArguments(); ActionWithVector* av=dynamic_cast(action); + unsigned nargs = action->getNumberOfArguments(); ActionWithVector* av=dynamic_cast(action); if( av && av->getNumberOfMasks()>0 ) nargs = nargs - av->getNumberOfMasks(); std::vector var; parseVector(action,"VAR",var); parse(action,"FUNC",func); if(var.size()==0) { diff --git a/src/function/FunctionOfMatrix.h b/src/function/FunctionOfMatrix.h index 3baba553be..4340d0175e 100644 --- a/src/function/FunctionOfMatrix.h +++ b/src/function/FunctionOfMatrix.h @@ -157,7 +157,7 @@ std::vector FunctionOfMatrix::getValueShapeFromArguments() { template unsigned FunctionOfMatrix::getNumberOfDerivatives() { - unsigned nder=0, argstart = myfunc.getArgStart(); + unsigned nder=0, argstart = myfunc.getArgStart(); unsigned nargs = getNumberOfArguments(); if( getNumberOfMasks()>0 ) nargs = nargs - getNumberOfMasks(); for(unsigned i=argstart; igetNumberOfStoredValues(); return nder; @@ -175,7 +175,7 @@ void FunctionOfMatrix::prepare() { } for(unsigned i=0; igetRank()==2 && (myval->getShape()[0]!=shape[0] || myval->getShape()[1]!=shape[1]) ) myval->setShape(shape); + if( myval->getRank()==2 && (myval->getShape()[0]!=shape[0] || myval->getShape()[1]!=shape[1]) ) myval->setShape(shape); } ActionWithVector::prepare(); active_tasks.resize(0); } @@ -184,7 +184,7 @@ template Value* FunctionOfMatrix::getPntrToFirstMatrixArgument() const { unsigned argstart=myfunc.getArgStart(); for(unsigned i=argstart; igetRank()==2 ) return getPntrToArgument(i); + if( getPntrToArgument(i)->getRank()==2 ) return getPntrToArgument(i); } plumed_merror("could not find matrix argument"); return NULL; @@ -195,29 +195,29 @@ std::vector& FunctionOfMatrix::getListOfActiveTasks( ActionWithVect if( active_tasks.size()>0 ) return active_tasks; Value* myarg = NULL; - if( getNumberOfMasks()>0 ) myarg = getPntrToArgument(getNumberOfArguments()-getNumberOfMasks()); + if( getNumberOfMasks()>0 ) myarg = getPntrToArgument(getNumberOfArguments()-getNumberOfMasks()); else myarg = getPntrToFirstMatrixArgument(); unsigned base=0; unsigned nrows = myarg->getShape()[0]; for(unsigned i=0; igetRowLength(i); - for(unsigned j=0; jgetNumberOfColumns(); + unsigned ncols = myarg->getRowLength(i); + for(unsigned j=0; jgetNumberOfColumns(); } if( getNumberOfMasks()>0 && doNotCalculateDerivatives() ) return active_tasks; // All the matrices input have to have the same sparsity pattern. -// I can do everything I want to do with this limitation. If +// I can do everything I want to do with this limitation. If // anyone wants to make this smarter in the future they can #ifndef DNDEBUG unsigned argstart=myfunc.getArgStart(); for(unsigned k=argstart; kgetRank()!=2 ) continue ; - for(unsigned i=0; igetRowLength(i); - if( getNumberOfMasks()>0 && ncols==0 ) continue; - plumed_massert( ncols==getPntrToArgument(k)->getRowLength(i), "failing in " + getLabel() ); - for(unsigned j=0; jgetRowIndex(i,j)==getPntrToArgument(k)->getRowIndex(i,j) ); - } + if( getPntrToArgument(k)->getRank()!=2 ) continue ; + for(unsigned i=0; igetRowLength(i); + if( getNumberOfMasks()>0 && ncols==0 ) continue; + plumed_massert( ncols==getPntrToArgument(k)->getRowLength(i), "failing in " + getLabel() ); + for(unsigned j=0; jgetRowIndex(i,j)==getPntrToArgument(k)->getRowIndex(i,j) ); + } } #endif return active_tasks; @@ -230,23 +230,23 @@ void FunctionOfMatrix::performTask( const unsigned& taskno, MultiValue& myval // Retrieve the arguments if( getNumberOfMasks()>0 ) { - Value* maskarg = getPntrToArgument(getNumberOfArguments()-getNumberOfMasks()); - unsigned index1 = std::floor( taskno / maskarg->getNumberOfColumns() ); - unsigned index2 = taskno - index1*maskarg->getNumberOfColumns(); - unsigned tind2 = maskarg->getRowIndex( index1, index2 ); - unsigned maskncol = maskarg->getRowLength(index1); - for(unsigned i=argstart; igetRank()==2 && getPntrToArgument(i)->getRowLength(index1)>maskncol ) args[i-argstart]=getPntrToArgument(i)->get( index1*getPntrToArgument(i)->getShape()[1] + tind2 ); - else if( getPntrToArgument(i)->getRank()==2 ) { - plumed_dbg_assert( maskncol==getPntrToArgument(i)->getRowLength(index1) ); - args[i-argstart]=getPntrToArgument(i)->get( taskno, false ); - } else args[i-argstart] = getPntrToArgument(i)->get(); - } + Value* maskarg = getPntrToArgument(getNumberOfArguments()-getNumberOfMasks()); + unsigned index1 = std::floor( taskno / maskarg->getNumberOfColumns() ); + unsigned index2 = taskno - index1*maskarg->getNumberOfColumns(); + unsigned tind2 = maskarg->getRowIndex( index1, index2 ); + unsigned maskncol = maskarg->getRowLength(index1); + for(unsigned i=argstart; igetRank()==2 && getPntrToArgument(i)->getRowLength(index1)>maskncol ) args[i-argstart]=getPntrToArgument(i)->get( index1*getPntrToArgument(i)->getShape()[1] + tind2 ); + else if( getPntrToArgument(i)->getRank()==2 ) { + plumed_dbg_assert( maskncol==getPntrToArgument(i)->getRowLength(index1) ); + args[i-argstart]=getPntrToArgument(i)->get( taskno, false ); + } else args[i-argstart] = getPntrToArgument(i)->get(); + } } else { - for(unsigned i=argstart; igetRank()==2 ) args[i-argstart]=getPntrToArgument(i)->get( taskno, false ); - else args[i-argstart] = getPntrToArgument(i)->get(); - } + for(unsigned i=argstart; igetRank()==2 ) args[i-argstart]=getPntrToArgument(i)->get( taskno, false ); + else args[i-argstart] = getPntrToArgument(i)->get(); + } } // Calculate the function and its derivatives std::vector vals( getNumberOfComponents() ); Matrix derivatives( getNumberOfComponents(), nargs-argstart ); @@ -276,13 +276,13 @@ void FunctionOfMatrix::performTask( const unsigned& taskno, MultiValue& myval template void FunctionOfMatrix::calculate() { - Value* myarg = NULL; - if( getNumberOfMasks()>0 ) myarg = getPntrToArgument(getNumberOfArguments()-getNumberOfMasks()); - else myarg = getPntrToFirstMatrixArgument(); + Value* myarg = NULL; + if( getNumberOfMasks()>0 ) myarg = getPntrToArgument(getNumberOfArguments()-getNumberOfMasks()); + else myarg = getPntrToFirstMatrixArgument(); // Copy bookeeping arrays from input matrices to output matrices for(unsigned i=0; igetRank()==2 ) getPntrToComponent(i)->copyBookeepingArrayFromArgument( myarg ); - else getPntrToComponent(i)->resizeDerivatives( getNumberOfDerivatives() ); + if( getPntrToComponent(i)->getRank()==2 ) getPntrToComponent(i)->copyBookeepingArrayFromArgument( myarg ); + else getPntrToComponent(i)->resizeDerivatives( getNumberOfDerivatives() ); } runAllTasks(); } diff --git a/src/matrixtools/MatrixTimesVector.cpp b/src/matrixtools/MatrixTimesVector.cpp index a9f860d29d..6f1f1ef54f 100644 --- a/src/matrixtools/MatrixTimesVector.cpp +++ b/src/matrixtools/MatrixTimesVector.cpp @@ -145,7 +145,7 @@ MatrixTimesVector::MatrixTimesVector(const ActionOptions&ao): } unsigned MatrixTimesVector::getNumberOfDerivatives() { - unsigned nderivatives=0; + unsigned nderivatives=0; for(unsigned i=0; igetNumberOfStoredValues(); return nderivatives; }