decompose.h
来自「The Spectral Toolkit is a C++ spectral t」· C头文件 代码 · 共 42 行
H
42 行
//// spectral toolkit // copyright (c) 2005 university corporation for atmospheric research// licensed under the gnu general public license//#ifndef __decompose__#define __decompose__namespace spectral{ /// Decomposition function template. Partitions a list of items linearly /// with remainders distributed evenly. /// \param n length of list /// \param size number of partitions /// \param rank index of parition in \f$ [0,n-1] \f$ /// \param length partition length (output) /// \param offset partition offset relative to zero (output) template<typename T> void decompose(T n,T size,T rank,T& length,T& offset) { T remainder=n%size; T chunk=n/size; if(rank<remainder) { length=chunk+1; offset=(chunk+1)*rank; } else { length=chunk; offset=(chunk+1)*remainder+(rank-remainder)*chunk; } }}#endif// Local Variables:// mode:C++// End:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?