本文整理汇总了C++中MatrixT::transposed方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixT::transposed方法的具体用法?C++ MatrixT::transposed怎么用?C++ MatrixT::transposed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixT
的用法示例。
在下文中一共展示了MatrixT::transposed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: multiply
SMPMatrixElf::MatrixT SMPMatrixElf::multiply(const MatrixT& left, const MatrixT& right)
{
if (left.empty() || right.empty()) return MatrixT();
MatrixT c(left.rows(), right.columns());
size_t elementsPerBlock = 10*10;
size_t columnsPerBlock = (size_t)ceil(sqrt(elementsPerBlock));
columnsPerBlock = min(columnsPerBlock, c.columns());
size_t rowsPerBlock = div_ceil(elementsPerBlock, columnsPerBlock);
size_t blocksPerRow = div_ceil(c.columns(), columnsPerBlock);
size_t blocksPerColumns = div_ceil(c.rows(), rowsPerBlock);
size_t blockCount = blocksPerRow * blocksPerColumns;
MatrixT transposed = right.transposed();
#pragma omp parallel for
for(size_t index=0; index<blockCount; index++)
{
size_t rowStart = (index / blocksPerRow) * rowsPerBlock;
size_t columnStart = (index % blocksPerRow) * columnsPerBlock;
size_t columnEnd = min(columnStart+columnsPerBlock, c.columns());
size_t rowEnd = min(rowStart+rowsPerBlock, c.rows());
for(size_t y=rowStart; y<rowEnd; y++)
{
for(size_t x=columnStart; x<columnEnd; x++)
{
float val = 0;
for(size_t i=0; i<left.columns(); i++)
{
val += left(y,i) * transposed(x,i);
}
c(y,x) = val;
}
}
}
return c;
}