本文整理汇总了C++中MultiValue类的典型用法代码示例。如果您正苦于以下问题:C++ MultiValue类的具体用法?C++ MultiValue怎么用?C++ MultiValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MultiValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyScaledDerivatives
void ReferenceValuePack::copyScaledDerivatives( const unsigned& from, const double& scalef, const MultiValue& tvals ){
plumed_dbg_assert( tvals.getNumberOfDerivatives()==myvals.getNumberOfDerivatives() );
for(unsigned i=0;i<tvals.getNumberActive();++i){
unsigned ider=tvals.getActiveIndex(i);
myvals.addDerivative( oind, ider, scalef*tvals.getDerivative( from, ider ) );
}
}
示例2: compute
void MultiColvarDensity::compute( const unsigned& current, MultiValue& myvals ) const {
std::vector<double> cvals( mycolv->getNumberOfQuantities() ); stash->retrieveSequentialValue( current, false, cvals );
Vector fpos, apos = pbcDistance( origin, mycolv->getCentralAtomPos( mycolv->getPositionInFullTaskList(current) ) );
if( fractional ) { fpos = getPbc().realToScaled( apos ); } else { fpos=apos; }
myvals.setValue( 0, cweight*cvals[0] ); for(unsigned j=0; j<directions.size(); ++j) myvals.setValue( 1+j, fpos[ directions[j] ] );
myvals.setValue( 1+directions.size(), cvals[1] );
}
示例3: completeTask
void VolumeGradientBase::completeTask( const unsigned& curr, MultiValue& invals, MultiValue& outvals ) const {
if( getPntrToMultiColvar()->isDensity() ) {
outvals.setValue(0, 1.0); outvals.setValue(1, 1.0);
} else {
// Copy derivatives of the colvar and the value of the colvar
invals.copyValues( outvals );
if( derivativesAreRequired() ) invals.copyDerivatives( outvals );
}
calculateAllVolumes( curr, outvals );
}
示例4: calculate
void SpathVessel::calculate( const unsigned& current, MultiValue& myvals, std::vector<double>& buffer, std::vector<unsigned>& der_index ) const {
double pp=mymap->getPropertyValue( current, getLabel() ), weight=myvals.get(0);
if( weight<getTolerance() ) return;
unsigned nderivatives=getFinalValue()->getNumberOfDerivatives();
buffer[bufstart] += weight*pp; buffer[bufstart+1+nderivatives] += weight;
if( getAction()->derivativesAreRequired() ) {
myvals.chainRule( 0, 0, 1, 0, pp, bufstart, buffer );
myvals.chainRule( 0, 1, 1, 0, 1.0, bufstart, buffer );
}
}
示例5: calculateAllVessels
bool ActionWithVessel::calculateAllVessels( const unsigned& taskCode, MultiValue& myvals, MultiValue& bvals, std::vector<double>& buffer, std::vector<unsigned>& der_list ){
bool keep=false;
for(unsigned j=0;j<functions.size();++j){
// Calculate returns a bool that tells us if this particular
// quantity is contributing more than the tolerance
if( functions[j]->calculate( taskCode, functions[j]->transformDerivatives(taskCode, myvals, bvals), buffer, der_list ) ) keep=true;
if( !actionIsBridged && bvals.getNumberActive()>0 ) bvals.clearAll();
}
return keep;
}
示例6: addConnectionDerivatives
void ActionWithInputMatrix::addConnectionDerivatives( const unsigned& i, const unsigned& j, MultiValue& myvals, MultiValue& myvout ) const {
if( !mymatrix->matrixElementIsActive( i, j ) ) return;
unsigned myelem = mymatrix->getStoreIndexFromMatrixIndices( i, j );
// Get derivatives and add
mymatrix->retrieveDerivatives( myelem, false, myvals );
for(unsigned jd=0; jd<myvals.getNumberActive(); ++jd) {
unsigned ider=myvals.getActiveIndex(jd);
myvout.addDerivative( 1, ider, myvals.getDerivative( 1, ider ) );
}
}
示例7: performTask
void SecondaryStructureRMSD::performTask( const unsigned& task_index, const unsigned& current, MultiValue& myvals ) const {
// Retrieve the positions
std::vector<Vector> pos( references[0]->getNumberOfAtoms() );
const unsigned n=pos.size();
for(unsigned i=0;i<n;++i) pos[i]=ActionAtomistic::getPosition( getAtomIndex(current,i) );
// This does strands cutoff
Vector distance=pbcDistance( pos[align_atom_1],pos[align_atom_2] );
if( s_cutoff2>0 ){
if( distance.modulo2()>s_cutoff2 ){
myvals.setValue( 0, 0.0 );
return;
}
}
// This aligns the two strands if this is required
if( alignType!="DRMSD" && align_strands ){
Vector origin_old, origin_new; origin_old=pos[align_atom_2];
origin_new=pos[align_atom_1]+distance;
for(unsigned i=15;i<30;++i){
pos[i]+=( origin_new - origin_old );
}
}
// Create a holder for the derivatives
ReferenceValuePack mypack( 0, pos.size(), myvals ); mypack.setValIndex( 1 );
for(unsigned i=0;i<n;++i) mypack.setAtomIndex( i, getAtomIndex(current,i) );
// And now calculate the RMSD
const Pbc& pbc=getPbc();
unsigned closest=0;
double r = references[0]->calculate( pos, pbc, mypack, false );
const unsigned rs = references.size();
for(unsigned i=1;i<rs;++i){
mypack.setValIndex( i+1 );
double nr=references[i]->calculate( pos, pbc, mypack, false );
if( nr<r ){ closest=i; r=nr; }
}
// Transfer everything to the value
myvals.setValue( 0, 1.0 ); myvals.setValue( 1, r );
if( closest>0 ) mypack.moveDerivatives( closest+1, 1 );
if( !mypack.virialWasSet() ){
Tensor vir;
const unsigned cacs = colvar_atoms[current].size();
for(unsigned i=0;i<cacs;++i){
vir+=(-1.0*Tensor( pos[i], mypack.getAtomDerivative(i) ));
}
mypack.setValIndex(1); mypack.addBoxDerivatives( vir );
}
return;
}
示例8:
AtomValuePack::AtomValuePack( MultiValue& vals, MultiColvarBase const * mcolv ):
myvals(vals),
mycolv(mcolv),
natoms(0),
indices( vals.getIndices() ),
sort_vector( vals.getSortIndices() ),
myatoms( vals.getAtomVector() )
{
if( indices.size()!=mcolv->getNumberOfAtoms() ){
indices.resize( mcolv->getNumberOfAtoms() );
sort_vector.resize( mcolv->getNumberOfAtoms() );
myatoms.resize( mcolv->getNumberOfAtoms() );
}
}
示例9: storeDerivatives
void StoreDataVessel::storeDerivatives( const unsigned& myelem, MultiValue& myvals, std::vector<double>& buffer, std::vector<unsigned>& der_list ) const {
plumed_dbg_assert( vecsize>0 && getAction()->derivativesAreRequired() && myelem<getAction()->getFullNumberOfTasks() );
unsigned jelem = getAction()->getPositionInCurrentTaskList( myelem );
if( getAction()->getFullNumberOfTasks()==getNumberOfStoredValues() ){
der_list[jelem]=myvals.getNumberActive();
unsigned kder = getNumberOfStoredValues() + jelem * ( nspace - 1 );
for(unsigned j=0;j<myvals.getNumberActive();++j){ der_list[kder] = myvals.getActiveIndex(j); kder++; }
} else {
// This ensures that active indices are gathered correctly if
// we have multiple tasks contributing to a stored quantity
unsigned kder = getNumberOfStoredValues() + jelem * ( nspace - 1 );
for(unsigned j=0;j<myvals.getNumberActive();++j){
bool found=false; unsigned jder = myvals.getActiveIndex(j);
for(unsigned k=0;k<der_list[jelem];++k){
if( der_list[kder+k]==jder ){ found=true; break; }
}
if(!found){ der_list[kder+der_list[jelem]]=jder; der_list[jelem]++; }
}
}
// Store the values of the components and the derivatives
for(unsigned icomp=0;icomp<vecsize;++icomp){
unsigned ibuf = bufstart + jelem * ( vecsize*nspace ) + icomp*nspace + 1;
for(unsigned j=0;j<myvals.getNumberActive();++j){
unsigned jder=myvals.getActiveIndex(j);
buffer[ibuf] += myvals.getDerivative( icomp, jder ); ibuf++;
}
}
}
示例10: storeValues
void StoreDataVessel::storeValues( const unsigned& myelem, MultiValue& myvals, std::vector<double>& buffer ) const {
plumed_dbg_assert( vecsize>0 );
unsigned jelem = getAction()->getPositionInCurrentTaskList( myelem ); plumed_dbg_assert( jelem<getNumberOfStoredValues() );
unsigned ibuf = bufstart + jelem * vecsize * nspace;
for(unsigned icomp=0;icomp<vecsize;++icomp){
buffer[ibuf] += myvals.get(icomp); ibuf+=nspace;
}
}
示例11: retrieveDerivatives
void StoreDataVessel::retrieveDerivatives( const unsigned& myelem, const bool& normed, MultiValue& myvals ){
plumed_dbg_assert( myvals.getNumberOfValues()==vecsize && myvals.getNumberOfDerivatives()==getAction()->getNumberOfDerivatives() );
myvals.clearAll();
if( getAction()->lowmem ){
recalculateStoredQuantity( myelem, myvals );
if( normed ) getAction()->normalizeVectorDerivatives( myvals );
} else {
unsigned jelem = getAction()->getPositionInCurrentTaskList( myelem );
// Retrieve the derivatives for elements 0 and 1 - weight and norm
for(unsigned icomp=0;icomp<vecsize;++icomp){
unsigned ibuf = jelem * ( vecsize*nspace ) + icomp*nspace + 1;
unsigned kder = getNumberOfStoredValues() + jelem * ( nspace - 1 );
for(unsigned j=0;j<active_der[jelem];++j){
myvals.addDerivative( icomp, active_der[kder], local_buffer[ibuf] );
kder++; ibuf++;
}
}
if( normed ) getAction()->normalizeVectorDerivatives( myvals );
// Now ensure appropriate parts of list are activated
myvals.emptyActiveMembers();
unsigned kder = getNumberOfStoredValues() + jelem * ( nspace - 1 );
for(unsigned j=0;j<active_der[jelem];++j){ myvals.putIndexInActiveArray( active_der[kder] ); kder++; }
myvals.sortActiveList();
}
}
示例12: copyDerivatives
void MultiValue::copyDerivatives( MultiValue& outvals ) {
plumed_dbg_assert( values.size()<=outvals.getNumberOfValues() && nderivatives<=outvals.getNumberOfDerivatives() );
if( !hasDerivatives.updateComplete() ) hasDerivatives.updateActiveMembers();
outvals.atLeastOneSet=true; unsigned ndert=hasDerivatives.getNumberActive();
for(unsigned j=0; j<ndert; ++j) {
unsigned jder=hasDerivatives[j]; outvals.hasDerivatives.activate(jder);
}
unsigned base=0, obase=0;
for(unsigned i=0; i<values.size(); ++i) {
for(unsigned j=0; j<ndert; ++j) {
unsigned jder=hasDerivatives[j];
outvals.derivatives[obase+jder] += derivatives[base+jder];
}
obase+=outvals.nderivatives; base+=nderivatives;
}
}
示例13: calculate
void StoreDataVessel::calculate( const unsigned& current, MultiValue& myvals, std::vector<double>& buffer, std::vector<unsigned>& der_list ) const {
if( myvals.get(0)>epsilon ){
storeValues( current, myvals, buffer );
if( !(getAction()->lowmem) && getAction()->derivativesAreRequired() ) storeDerivatives( current, myvals, buffer, der_list );
}
return;
}
示例14:
ReferenceValuePack::ReferenceValuePack( const unsigned& nargs, const unsigned& natoms, MultiValue& vals ):
boxWasSet(false),
numberOfArgs(nargs),
oind_set(false),
myvals(vals),
atom_indices(myvals.getIndices()),
pca(false)
{
if( atom_indices.size()!=natoms ){ atom_indices.resize( natoms ); myvals.getAtomVector().resize( natoms ); }
if( vals.getNumberOfValues()==1 ){ oind=0; oind_set=true; }
}
示例15: normalizeVectorDerivatives
void VectorMultiColvar::normalizeVectorDerivatives( MultiValue& myvals ) const {
double v = myvals.get(1), weight = 1.0 / v, wdf = 1.0 / ( v*v*v );
for(unsigned j=0;j<myvals.getNumberActive();++j){
double comp2=0.0; unsigned jder=myvals.getActiveIndex(j);
for(unsigned jcomp=2;jcomp<myvals.getNumberOfValues();++jcomp) comp2 += myvals.get(jcomp)*myvals.getDerivative( jcomp, jder );
for(unsigned jcomp=2;jcomp<myvals.getNumberOfValues();++jcomp){
myvals.setDerivative( jcomp, jder, weight*myvals.getDerivative( jcomp, jder ) - wdf*comp2*myvals.get(jcomp) );
}
}
}