Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposing: removing lines with more than one statements. #1114

Open
wants to merge 3 commits into
base: v2.9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 13 additions & 1 deletion .astyle.options
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
-n --indent=spaces=2 --keep-one-line-statements --keep-one-line-blocks
# long options can be written without the preceding '--'
suffix=none #equivalent to "-n"
style=attach
add-braces
indent=spaces=2
break-one-line-headers

# old options
#suffix=none
#indent=spaces=2
#keep-one-line-statements
#keep-one-line-blocks
# end old options
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# .git-blame-ignore-revs
# https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view
# new astyle applied to v2.9
33f1cb86c61c13ef7c545444113ae60f6dd628fd
66 changes: 47 additions & 19 deletions src/adjmat/ActionWithInputMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,38 @@ void ActionWithInputMatrix::registerKeywords( Keywords& keys ) {
ActionWithInputMatrix::ActionWithInputMatrix(const ActionOptions& ao):
Action(ao),
MultiColvarBase(ao),
mymatrix(NULL)
{
mymatrix(NULL) {
matsums=true;
if( keywords.exists("MATRIX") ) {
std::vector<AtomNumber> fake_atoms;
if( !parseMultiColvarAtomList("MATRIX",-1,fake_atoms ) ) error("unable to interpret input matrix");
if( mybasemulticolvars.size()!=1 ) error("should be exactly one matrix input");
if( !parseMultiColvarAtomList("MATRIX",-1,fake_atoms ) ) {
error("unable to interpret input matrix");
}
if( mybasemulticolvars.size()!=1 ) {
error("should be exactly one matrix input");
}

// Retrieve the adjacency matrix of interest
for(unsigned i=0; i<mybasemulticolvars[0]->getNumberOfVessels(); ++i) {
mymatrix = dynamic_cast<AdjacencyMatrixVessel*>( mybasemulticolvars[0]->getPntrToVessel(i) );
if( mymatrix ) break ;
if( mymatrix ) {
break ;
}
}
if( !mymatrix ) {
error( mybasemulticolvars[0]->getLabel() + " does not calculate an adjacency matrix");
}
if( !mymatrix ) error( mybasemulticolvars[0]->getLabel() + " does not calculate an adjacency matrix");

atom_lab.resize(0); unsigned nnodes; // Delete all the atom labels that have been created
if( mymatrix->undirectedGraph() ) nnodes = (mymatrix->function)->ablocks[0].size();
else nnodes = (mymatrix->function)->ablocks[0].size() + (mymatrix->function)->ablocks[1].size();
for(unsigned i=0; i<nnodes; ++i) atom_lab.push_back( std::pair<unsigned,unsigned>( 1, i ) );
atom_lab.resize(0);
unsigned nnodes; // Delete all the atom labels that have been created
if( mymatrix->undirectedGraph() ) {
nnodes = (mymatrix->function)->ablocks[0].size();
} else {
nnodes = (mymatrix->function)->ablocks[0].size() + (mymatrix->function)->ablocks[1].size();
}
for(unsigned i=0; i<nnodes; ++i) {
atom_lab.push_back( std::pair<unsigned,unsigned>( 1, i ) );
}
}
}

Expand All @@ -77,7 +90,9 @@ AtomNumber ActionWithInputMatrix::getAbsoluteIndexOfCentralAtom(const unsigned&
}

double ActionWithInputMatrix::retrieveConnectionValue( const unsigned& i, const unsigned& j, std::vector<double>& vals ) const {
if( !mymatrix->matrixElementIsActive( i, j ) ) return 0;
if( !mymatrix->matrixElementIsActive( i, j ) ) {
return 0;
}
unsigned myelem = mymatrix->getStoreIndexFromMatrixIndices( i, j );

// unsigned vi; double df;
Expand All @@ -87,18 +102,24 @@ double ActionWithInputMatrix::retrieveConnectionValue( const unsigned& i, const

void ActionWithInputMatrix::getInputData( const unsigned& ind, const bool& normed, const multicolvar::AtomValuePack& myatoms, std::vector<double>& orient0 ) const {
if( (mymatrix->function)->mybasemulticolvars.size()==0 ) {
std::vector<double> tvals( mymatrix->getNumberOfComponents() ); orient0.assign(orient0.size(),0);
std::vector<double> tvals( mymatrix->getNumberOfComponents() );
orient0.assign(orient0.size(),0);
for(unsigned i=0; i<mymatrix->getNumberOfColumns(); ++i) {
if( mymatrix->undirectedGraph() && ind==i ) continue;
if( mymatrix->undirectedGraph() && ind==i ) {
continue;
}
orient0[1]+=retrieveConnectionValue( ind, i, tvals );
}
orient0[0]=1.0; return;
orient0[0]=1.0;
return;
}
(mymatrix->function)->getInputData( ind, normed, myatoms, orient0 );
}

void ActionWithInputMatrix::addConnectionDerivatives( const unsigned& i, const unsigned& j, MultiValue& myvals, MultiValue& myvout ) const {
if( !mymatrix->matrixElementIsActive( i, j ) ) return;
if( !mymatrix->matrixElementIsActive( i, j ) ) {
return;
}
unsigned myelem = mymatrix->getStoreIndexFromMatrixIndices( i, j );
// Get derivatives and add
mymatrix->retrieveDerivatives( myelem, false, myvals );
Expand All @@ -117,22 +138,29 @@ MultiValue& ActionWithInputMatrix::getInputDerivatives( const unsigned& ind, con
myder.clearAll();
MultiValue myvals( (mymatrix->function)->getNumberOfQuantities(), (mymatrix->function)->getNumberOfDerivatives() );
for(unsigned i=0; i<mymatrix->getNumberOfColumns(); ++i) {
if( mymatrix->undirectedGraph() && ind==i ) continue;
if( mymatrix->undirectedGraph() && ind==i ) {
continue;
}
addConnectionDerivatives( ind, i, myvals, myder );
}
myder.updateDynamicList(); return myder;
myder.updateDynamicList();
return myder;
}
return (mymatrix->function)->getInputDerivatives( ind, normed, myatoms );
}

unsigned ActionWithInputMatrix::getNumberOfNodeTypes() const {
unsigned size = (mymatrix->function)->mybasemulticolvars.size();
if( size==0 ) return 1;
if( size==0 ) {
return 1;
}
return size;
}

unsigned ActionWithInputMatrix::getNumberOfQuantities() const {
if( (mymatrix->function)->mybasemulticolvars.size()==0 ) return 2;
if( (mymatrix->function)->mybasemulticolvars.size()==0 ) {
return 2;
}
return (mymatrix->function)->mybasemulticolvars[0]->getNumberOfQuantities();
}

Expand Down
8 changes: 6 additions & 2 deletions src/adjmat/ActionWithInputMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ class ActionWithInputMatrix : public multicolvar::MultiColvarBase {
unsigned getNumberOfDerivatives() override;
/// Get the number of rows/cols in the adjacency matrix vessel
virtual unsigned getNumberOfNodes() const;
bool isPeriodic() override { return false; }
bool isPeriodic() override {
return false;
}
unsigned getNumberOfQuantities() const override;
///
AtomNumber getAbsoluteIndexOfCentralAtom(const unsigned& i) const override;
/// No loop over tasks for ActionWithInputMatrix
double compute( const unsigned& tindex, multicolvar::AtomValuePack& myatoms ) const override { plumed_error(); }
double compute( const unsigned& tindex, multicolvar::AtomValuePack& myatoms ) const override {
plumed_error();
}
///
Vector getPositionOfAtomForLinkCells( const unsigned& iatom ) const override;
};
Expand Down
Loading
Loading