本文整理汇总了C++中Wavefunction::GetAvailableDataBufferName方法的典型用法代码示例。如果您正苦于以下问题:C++ Wavefunction::GetAvailableDataBufferName方法的具体用法?C++ Wavefunction::GetAvailableDataBufferName怎么用?C++ Wavefunction::GetAvailableDataBufferName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wavefunction
的用法示例。
在下文中一共展示了Wavefunction::GetAvailableDataBufferName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
cplx CombinedRepresentation<Rank>::InnerProduct(const Wavefunction<Rank>& w1, const Wavefunction<Rank>& w2)
{
blitz::Array<cplx, Rank> d1(w1.GetData());
blitz::Array<cplx, Rank> d2(w2.GetData());
/*
* Algorithm1 is faster for orthogonal basises
* Algorithm2 is faster for nonorthogonal basies
* Algorithm3 is the only one working for parallel problems, but require
* more memory
*
* For a combination of orthogonal and non-orthogonal
* basises, 1 and 2 are most likely almost equally fast
*
* Conclusion: Algo 3 is default
*/
if (Algorithm == 1)
{
return InnerProductImpl_Algo1(d1, d2);
}
else if (Algorithm == 2)
{
return InnerProductImpl_Algo2(d1, d2);
}
else if (Algorithm == 3)
{
blitz::TinyVector<int, Rank> shape = d1.shape();
blitz::Array<cplx, Rank> temp1;
blitz::Array<cplx, Rank> temp2;
int tempName[2];
int tempNamePsi[2];
Wavefunction<Rank>* psiList[2];
for (int i=0; i<2; i++)
{
tempName[i] = -1;
tempNamePsi[i] = -1;
}
psiList[0] = const_cast<Wavefunction<Rank>*>(&w1);
psiList[1] = const_cast<Wavefunction<Rank>*>(&w2);
//Find any available buffers of correct size on any of the wavefunctions
for (int i=0; i<2; i++)
{
//See if there is an available buffer in psi j
for (int j=0; j<2; j++)
{
int name = psiList[j]->GetAvailableDataBufferName(shape);
if (name != -1)
{
tempName[i] = name;
tempNamePsi[i] = j;
psiList[j]->LockBuffer(name);
break;
}
}
}
//If we didnt find two available buffers, we must allocate
//We'll allocate on w2
for (int i=0; i<2; i++)
{
if (tempName[i] == -1)
{
tempName[i] = psiList[1]->AllocateData(shape);
tempNamePsi[i] = 1;
psiList[1]->LockBuffer(tempName[i]);
}
}
//Get the actual data buffers
temp1.reference(psiList[tempNamePsi[0]]->GetData(tempName[0]));
temp2.reference(psiList[tempNamePsi[1]]->GetData(tempName[1]));
//Perform MatrixVector multiplication
//first step
//
for (int i=0; i<Rank; i++)
{
if (this->GetDistributedModel()->IsDistributedRank(i) && !this->IsOrthogonalBasis(i))
{
throw std::runtime_error("This inner product only supports parallelization for orthogonal ranks");
}
if (this->IsOrthogonalBasis(i))
{
if (i == 0)
{
temp1 = d2;
}
//TODO: Make this faster by moving it to TensorMultiply
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
{
//.........这里部分代码省略.........