本文整理汇总了C++中arma::mat::max方法的典型用法代码示例。如果您正苦于以下问题:C++ mat::max方法的具体用法?C++ mat::max怎么用?C++ mat::max使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arma::mat
的用法示例。
在下文中一共展示了mat::max方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Transform
void ColumnsToBlocks::Transform(const arma::mat& maximalInputs,
arma::mat& output)
{
if (!IsPerfectSquare(maximalInputs.n_rows))
{
throw std::runtime_error("maximalInputs.n_rows should be perfect square");
}
if (blockHeight == 0 || blockWidth == 0)
{
size_t const squareRows =
static_cast<size_t>(std::sqrt(maximalInputs.n_rows));
blockHeight = squareRows;
blockWidth = squareRows;
}
if (blockHeight * blockWidth != maximalInputs.n_rows)
{
throw std::runtime_error("blockHeight * blockWidth should "
"equal to maximalInputs.n_rows");
}
const size_t rowOffset = blockHeight+bufSize;
const size_t colOffset = blockWidth+bufSize;
output.ones(bufSize + rows * rowOffset,
bufSize + cols * colOffset);
output *= bufValue;
size_t k = 0;
const size_t maxSize = std::min(rows * cols, (size_t) maximalInputs.n_cols);
for (size_t i = 0; i != rows; ++i)
{
for (size_t j = 0; j != cols; ++j)
{
// Now, copy the elements of the row to the output submatrix.
const size_t minRow = bufSize + i * rowOffset;
const size_t minCol = bufSize + j * colOffset;
const size_t maxRow = i * rowOffset + blockHeight;
const size_t maxCol = j * colOffset + blockWidth;
output.submat(minRow, minCol, maxRow, maxCol) =
arma::reshape(maximalInputs.col(k++), blockHeight, blockWidth);
if (k >= maxSize)
break;
}
}
if (scale)
{
const double max = output.max();
const double min = output.min();
if ((max - min) != 0)
{
output = (output - min) / (max - min) * (maxRange - minRange) + minRange;
}
}
}
示例2: tmax_max
// [[Rcpp::export]]
int tmax_max(arma::mat m){
return m.max();
}
示例3: which_max
int which_max(arma::mat X) {
arma::uword index;
X.max(index);
return index;
}