主题
Search

折叠函数


折叠函数是将整数 Z={...,-3,-2,-1,0,1,2,3,...} 映射到非负整数 Z^*={0,1,2,3,...} 的函数。这种类型的函数自然出现在需要移除整数符号的情况中(例如,为了展示 |Z|=|Z^*|=aleph_0,或者当使用仅适用于非负整数的技术编码有符号整数时(例如,在数据压缩中)。

常用的折叠函数 f 由下式给出

 f(n)={2n   if n>=0; 2|n|-1   otherwise,
(1)

其逆为

 f^(-1)(n)={-1/2(i+1)   if i=1 (mod 2); 1/2i   otherwise.
(2)
0-11-22-33-44-55-66-77-8...
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v...
0123456789101112131415...

f(n) 计算上述映射。

另一个变体可以定义为

 g(n)={2n-1   if n>0; 2|n|   if n<=0,
(3)

其逆为

 g^(-1)(n)={1/2(i+1)   if i=1 (mod 2); -1/2i   otherwise.
(4)
01-12-23-34-45-56-67-78...
^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v...
0123456789101112131415...

g(n) 计算上述映射。


另请参阅

配对函数

此条目由 Steven Pigeon 贡献

使用 Wolfram|Alpha 探索

请引用为

Pigeon, Steven. "折叠函数." 来自 MathWorld--Wolfram Web 资源, 由 Eric W. Weisstein 创建. https://mathworld.net.cn/FoldingFunction.html

主题分类