本文整理汇总了C++中Wavefunction::UnLockBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ Wavefunction::UnLockBuffer方法的具体用法?C++ Wavefunction::UnLockBuffer怎么用?C++ Wavefunction::UnLockBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wavefunction
的用法示例。
在下文中一共展示了Wavefunction::UnLockBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
blitz::Array<double, 1> weights = this->GetLocalWeights(i);
blitz::Array<cplx, 3> temp3d = MapToRank3(temp1, i, 1);
temp3d *= weights(blitz::tensor::j) + 0*blitz::tensor::k;
}
else
{
blitz::Array<cplx, 2> overlapMatrix = this->GetGlobalOverlapMatrix(i)->GetOverlapHermitianLower();
//Reshape the overlap matrix into a N-d array suitable for TensorPotentialMultiply
blitz::TinyVector<int, Rank> overlapShape = 1;
overlapShape(i) = overlapMatrix.size();
blitz::TinyVector<int, Rank> overlapStride = 1;
for (int j=0; j<i; j++)
{
overlapStride(j) = overlapMatrix.size();
}
blitz::Array<cplx, Rank> overlapTensor(overlapMatrix.data(), overlapShape, overlapStride, blitz::neverDeleteData);
if (i==0)
{
temp1 = 0;
TensorPotentialMultiply_Rank1_Band(i, overlapTensor, 1.0, d2, temp1);
}
else
{
temp2 = 0;
TensorPotentialMultiply_Rank1_Band(i, overlapTensor, 1.0, temp1, temp2);
blitz::swap(temp1, temp2);
}
}
}
//Calculate inner product by overlap of the vectors
cplx innerProduct = VectorInnerProduct(d1, temp1);
for (int i=0; i<2; i++)
{
psiList[tempNamePsi[i]]->UnLockBuffer(tempName[i]);
}
return innerProduct;
}
else if (Algorithm == 4) //Using DistributedOverlapMatrix / Trilinos
{
Wavefunction<Rank>* psiLeft = const_cast<Wavefunction<Rank>*>(&w1);
Wavefunction<Rank>* psiRight = const_cast<Wavefunction<Rank>*>(&w2);
//Get name of available databuffer for "left" wavefunction
int nameLeft = psiLeft->GetAvailableDataBufferName(psiLeft->GetData().shape());
//Is a buffer available? If not, create one
if (nameLeft == -1)
{
nameLeft = psiLeft->AllocateData(psiLeft->GetData().shape());
}
int oldNameLeft = psiLeft->SetActiveBuffer(nameLeft);
//Lock old buffer
psiLeft->LockBuffer(oldNameLeft);
//Copy data from old buffer to work buffer
psiLeft->GetData()(blitz::Range::all()) = psiLeft->GetData(oldNameLeft)(blitz::Range::all());
//Similar procedure for "right" wavefunction
int nameRight = psiRight->GetAvailableDataBufferName(psiRight->GetData().shape());
if (nameRight == -1)
{
nameRight = psiRight->AllocateData(psiRight->GetData().shape());
}
int oldNameRight = psiRight->SetActiveBuffer(nameRight);
//Lock original data buffer
psiRight->LockBuffer(oldNameRight);
//Copy data from old to new (work) buffer
psiRight->GetData(nameRight)(blitz::Range::all()) = psiRight->GetData(oldNameRight)(blitz::Range::all());
//Multiply integration weights
MultiplyIntegrationWeights(*psiRight);
//Calculate inner product by overlap of the vectors
cplx innerProduct = VectorInnerProduct(psiLeft->GetData(oldNameLeft), psiRight->GetData(nameRight));
//Unlock and restore original buffers
psiRight->UnLockBuffer(oldNameRight);
psiRight->SetActiveBuffer(oldNameRight);
psiLeft->UnLockBuffer(oldNameLeft);
psiLeft->SetActiveBuffer(oldNameLeft);
return innerProduct;
}
else
{
cout << "Unknown InnerProduct algorithm " << Algorithm << endl;
throw std::runtime_error("Unknown InnerProduct algorithm");
}
}