本文整理汇总了C++中ArrayType::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayType::begin方法的具体用法?C++ ArrayType::begin怎么用?C++ ArrayType::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayType
的用法示例。
在下文中一共展示了ArrayType::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: free
void parameter::free(ArrayType &vecParams)
{
for (ArrayType::iterator iter = vecParams.begin(); iter != vecParams.end(); ++iter)
{
delete *iter;
}
vecParams.clear();
}
示例2: RearrangeArrayInPlace
auto RearrangeArrayInPlace(ArrayType elements) {
for (ArrayType::size_type i = 0; i < elements.size(); ++i) {
elements[elements[i] % elements.size()] += i * elements.size();
}
std::transform(elements.cbegin(), elements.cend(),
elements.begin(), [&elements](const ArrayType::value_type v) {
return v / elements.size();
});
return elements;
}
示例3: CreateWavefunctionEpetraMap
Epetra_Map_Ptr CreateWavefunctionEpetraMap(typename Wavefunction<Rank>::Ptr psi)
{
typedef blitz::Array<cplx, Rank> ArrayType;
ArrayType data = psi->GetData();
typename DistributedModel<Rank>::Ptr distr = psi->GetRepresentation()->GetDistributedModel();
Epetra_Comm_Ptr comm = CreateDistributedModelEpetraComm<Rank>(distr);
int localSize = data.size();
int* myElems = new int[localSize*2];
//Get strides of the global Rank-dimensional array
blitz::TinyVector<int, Rank> globalShape = psi->GetRepresentation()->GetFullShape();
blitz::TinyVector<int, Rank> globalStrides;
globalStrides(Rank-1) = 1;
for (int rank=Rank-2; rank>=0; rank--)
{
globalStrides(rank) = globalStrides(rank+1) * globalShape(rank+1);
}
//Get maps to global indices for each rank
blitz::TinyVector<blitz::Range, Rank> globalIndices;
for (int rank=0; rank<Rank; rank++)
{
globalIndices(rank) = distr->GetLocalIndexRange(globalShape(rank), rank);
}
typename blitz::Array<cplx, Rank>::iterator it = data.begin();
for (int linearCount=0; linearCount<data.size(); linearCount++)
{
//Get global position for the current element
int globalPos = 0;
for (int rank=0; rank<Rank; rank++)
{
int rankPos = it.position()(rank);
globalPos += globalStrides(rank) * globalIndices(rank)(rankPos);
}
//real component
myElems[2*linearCount] = 2*globalPos;
//imaginary component
myElems[2*linearCount+1] = 2*globalPos + 1;
++it;
}
return Epetra_Map_Ptr( new Epetra_Map(-1, localSize*2, myElems, 0, *comm) );
}
示例4: ArrayComparisonFunctor
/**
* @brief Construct an ArrayComparisonFunctor for an array.
*
* @param array Array to compare values against
* @param strict Flag to use strict type comparison
*/
ArrayComparisonFunctor(const ArrayType &array, bool strict)
: itr(array.begin()),
end(array.end()),
strict(strict) { }
示例5: CountInversionsMergeSort
auto CountInversionsMergeSort(ArrayType values) {
return MergeSort(values.begin(), values.size());
}