# 取整截断函数及其在PBC中的使用

2013-08-13 14:05:39

 函数 Fortran C 向下取整⌊x⌋ Floor Floor 向上取整⌈x⌉ Ceiling Ceil 截断取整[x] int/aint Int 四舍五入 nint/anint Round 模/取余 Mod(x,p)=x-int(x/p)*p modulo(x,p)=x-floor(x/p)*p x%p 绝对值|x| Abs Abs 符号 Sign(x，y)

$frac(x)={x}=x-lfloor x rfloor=mod(x,1)$

$int(x) = [x] = left{^{lfloor x rfloor, x>0}_{lceil x rceil, x<0}right.$
$nint(x) = left{^{int(x+1/2) = lfloor x+1/2 rfloor, x>0}_{int(x-1/2) =lceil x-1/2 rceil, x<0} right.$

1  以左下角为坐标原点，坐标$xin [0,L)$，为使粒子处于盒内，须
$x=x-lfloor x/L rfloor L$

2  以中心为原点，坐标$xin [-L/2,L/2)$，常用于计算粒子之间距离，此时又分两种情况

x满足$x in [0,L)$
$x = left{^{x-L, x>L/2}_{x+L, x<-L/2} right.$

x未必满足$x in [0,L)$，一般情况
$x=x-nint({x over L})L=left{ begin{matrix} x-[x/L+1/2]L = x-lfloor x/L+1/2 rfloor L, x>0 & \ x-[x/L-1/2]L = x-lfloor x/L-1/2 rfloor L, x<0 end{matrix} right.$

 X Floor ceiling int nint int(x+0.5) int(x-0.5) -2.00 -2 -2 -2 -2 -1 -2 -1.80 -1 -1 -1.50 -1.20 -1 0 -1 -1.00 -1 -0.90 0 0 -0.80 -0.70 -0.60 -0.50 -0.40 0 0 -0.30 -0.20 -0.10 0.00 0 0.10 1 0.20 0.30 0.40 0.50 1 1 0.60 0.70 0.80 0.90 1.00 1 1 1.10 2 1.20 1.50 2 2 1 1.80 2.00 2 2

https://blog.sciencenet.cn/blog-548663-717442.html

## 全部精选博文导读

GMT+8, 2023-3-31 23:29