Basis conversion should normally (always?) use centered representatives in (-q/2, q/2). However, it currently relies on ModArith:ExtractOp, which yields the standard representative in [0,q) (assuming it was normalized with ModArith:ReduceOp first?). I'm proposing the following design to resolve this situtation:
I propose a new ModArith:LiftOp which is similar to ExtractOp, but parameterized by a new ModArith Enum with values centered or standard. There would be a transform that lowers LiftOp into other ModArith and Arith ops. If the parameter is standard, LiftOp lowers to ReduceOp followed by ExtractOp. If the parameter is centered, it lowers to ReduceOp, ExtractOp, and a conditional subtraction by q.
Basis conversion should normally (always?) use centered representatives in (-q/2, q/2). However, it currently relies on ModArith:ExtractOp, which yields the standard representative in [0,q) (assuming it was normalized with ModArith:ReduceOp first?). I'm proposing the following design to resolve this situtation:
I propose a new ModArith:LiftOp which is similar to ExtractOp, but parameterized by a new ModArith Enum with values
centeredorstandard. There would be a transform that lowers LiftOp into other ModArith and Arith ops. If the parameter isstandard, LiftOp lowers to ReduceOp followed by ExtractOp. If the parameter iscentered, it lowers to ReduceOp, ExtractOp, and a conditional subtraction by q.