"UnsignedMachineInteger" (编译类型)
"UnsignedMachineInteger"
表示一个机器范围的无符号整数原子类型说明符.
更多信息
- "UnsignedMachineInteger" 可用于 Typed 和相关架构以指定一种类型.
- 在 64 位平台上,"UnsignedMachineInteger" 是一个 "UnsignedInteger64".
- 在 32 位平台上,"UnsignedMachineInteger" 是一个 "UnsignedInteger32".
范例
基本范例 (4)
"UnsignedMachineInteger" 可用作 CompiledCodeFunction 的输入和输出:
cf = FunctionCompile[Function[Typed[arg, "UnsignedMachineInteger"], arg]]cf[ 100]"UnsignedMachineInteger" 的大小与 $SystemWordLength 相同:
$SystemWordLength在运行函数时,溢出会导致错误发生. 计算停止,消息发送并使用 Wolfram Engine 来计算结果:
cf = FunctionCompile[Function[Typed[arg, "UnsignedMachineInteger"], arg ^ arg]];
cf[2^5]"UnsignedMachineInteger" 参数在与实数结合时会自动提升:
cf = FunctionCompile[Function[{Typed[arg1, "UnsignedMachineInteger"], Typed[arg2, "Real64"]}, arg1 + arg2]];
Information[cf, "Signature"]"UnsignedMachineInteger" 参数在与较小存储范围的整数结合时,较小的类型会自动提升:
cf = FunctionCompile[Function[{Typed[arg1, "UnsignedMachineInteger"], Typed[arg2, "Integer8"]}, arg1 + arg2]];
Information[cf, "Signature"]"UnsignedMachineInteger" 由于其可取架构原生范围的整数因此可与 "PackedArray" 一起使用:
cf = FunctionCompile[Function[Typed[arg, TypeSpecifier["PackedArray"]["MachineInteger", 1]], arg]]cf[{1, 2, 3}]技术笔记
历史
2019年引入 (12.0)