📄 decompose.h
字号:
//// 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -