⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utility.hpp

📁 矩阵运算源码最新版本
💻 HPP
字号:
// Software License for MTL// // Copyright (c) 2007 The Trustees of Indiana University. All rights reserved.// Authors: Peter Gottschling and Andrew Lumsdaine// // This file is part of the Matrix Template Library// // See also license.mtl.txt in the distribution.#ifndef MTL_RECURSION_UTILITIES_INCLUDE#define MTL_RECURSION_UTILITIES_INCLUDE#include <limits>#include <cmath>namespace mtl { namespace recursion {// Splits a number into a next-smallest power of 2 and reststd::size_t inline first_part(std::size_t n){    if (n == 0) return 0;    std::size_t i= std::numeric_limits<std::size_t>::max()/2 + 1;    while(i >= n) i>>= 1;    return i;}// The remainder of first partstd::size_t inline second_part(std::size_t n){    return n - first_part(n);}template <typename Matrix>std::size_t inline outer_bound(Matrix const& matrix){  std::size_t max_dim=std::max(matrix.num_rows(), matrix.num_cols()), bound= 1;  for (; bound < max_dim;) bound<<= 1;  return bound;}template <typename Integral>Integral inline least_significant_one_bit(Integral x){  return ((x ^ x-1) + 1) >> 1;}template <typename Integral>bool inline is_power_of_2(Integral x){  return x == least_significant_one_bit(x);}}} // namespace mtl::recursion#endif // MTL_RECURSION_UTILITIES_INCLUDE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -