本文整理汇总了C++中SiconosVector::num方法的典型用法代码示例。如果您正苦于以下问题:C++ SiconosVector::num方法的具体用法?C++ SiconosVector::num怎么用?C++ SiconosVector::num使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiconosVector
的用法示例。
在下文中一共展示了SiconosVector::num方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toBlock
void SiconosVector::toBlock(SiconosVector& vOut, unsigned int sizeB, unsigned int startIn, unsigned int startOut) const
{
// To copy a subBlock of the vector (from position startIn to startIn+sizeB) into vOut (from pos. startOut to startOut+sizeB).
// Check dim ...
assert(startIn < size() && "vector toBlock(v1,v2,...): start position in input vector is out of range.");
assert(startOut < vOut.size() && "vector toBlock(v1,v2,...): start position in output vector is out of range.");
assert(startIn + sizeB <= size() && "vector toBlock(v1,v2,...): end position in input vector is out of range.");
assert(startOut + sizeB <= vOut.size() && "vector toBlock(v1,v2,...): end position in output vector is out of range.");
unsigned int endOut = startOut + sizeB;
unsigned int numIn = num();
unsigned int numOut = vOut.num();
if (numIn == numOut)
{
if (numIn == 1) // vIn / vOut are Dense
noalias(ublas::subrange(*vOut.dense(), startOut, endOut)) = ublas::subrange(*vect.Dense, startIn, startIn + sizeB);
else // if(numIn == 4)// vIn / vOut are Sparse
noalias(ublas::subrange(*vOut.sparse(), startOut, endOut)) = ublas::subrange(*vect.Sparse, startIn, startIn + sizeB);
}
else // vIn and vout of different types ...
{
if (numIn == 1) // vIn Dense
noalias(ublas::subrange(*vOut.sparse(), startOut, endOut)) = ublas::subrange(*vect.Dense, startIn, startIn + sizeB);
else // if(numIn == 4)// vIn Sparse
noalias(ublas::subrange(*vOut.dense(), startOut, endOut)) = ublas::subrange(*vect.Sparse, startIn, startIn + sizeB);
}
}
示例2: subBlock
void SiconosVector::subBlock(unsigned int index, const SiconosVector& vIn)
{
// Add vIn from the current vector, starting from position "index".
// vIn may be a BlockVector.
// if ( num != 1 ) SiconosVectorException::selfThrow("SiconosVector::subBlock : vector should be dense");
unsigned int end = vIn.size();
if ((index + end) > size()) SiconosVectorException::selfThrow("SiconosVector::subBlock : invalid ranges");
unsigned int numVin = vIn.num();
if (numVin != num()) SiconosVectorException::selfThrow("SiconosVector::subBlock : inconsistent types.");
if (_dense)
noalias(ublas::subrange(*vect.Dense, index, index + end)) -= *vIn.dense();
else
noalias(ublas::subrange(*vect.Sparse, index, index + end)) -= *vIn.sparse();
}
示例3: setBlock
void SiconosVector::setBlock(unsigned int index, const SiconosVector& vIn)
{
// Set current vector elements, starting from position "index", to the values of vector vIn
// Exceptions ...
assert(&vIn != this && "SiconosVector::this->setBlock(pos,vIn): vIn = this.");
assert(index < size() && "SiconosVector::setBlock : invalid ranges");
unsigned int end = vIn.size() + index;
assert(end <= size() && "SiconosVector::setBlock : invalid ranges");
assert (vIn.num() == num() && "SiconosVector::setBlock: inconsistent types.");
if (_dense)
noalias(ublas::subrange(*vect.Dense, index, end)) = *vIn.dense();
else
noalias(ublas::subrange(*vect.Sparse, index, end)) = *vIn.sparse();
}