NTRU Prime: more unary negations
This commit is contained in:
parent
a5b5633534
commit
7f3228a9b3
@ -15,7 +15,7 @@
|
|||||||
static int int16_nonzero_mask(int16 x) {
|
static int int16_nonzero_mask(int16 x) {
|
||||||
uint16 u = (uint16) x; /* 0, else 1...65535 */
|
uint16 u = (uint16) x; /* 0, else 1...65535 */
|
||||||
uint32 v = u; /* 0, else 1...65535 */
|
uint32 v = u; /* 0, else 1...65535 */
|
||||||
v = -v; /* 0, else 2^32-65535...2^32-1 */
|
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
|
||||||
v >>= 31; /* 0, else 1 */
|
v >>= 31; /* 0, else 1 */
|
||||||
return -(int) v; /* 0, else -1 */
|
return -(int) v; /* 0, else -1 */
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
static int int16_nonzero_mask(int16 x) {
|
static int int16_nonzero_mask(int16 x) {
|
||||||
uint16 u = (uint16) x; /* 0, else 1...65535 */
|
uint16 u = (uint16) x; /* 0, else 1...65535 */
|
||||||
uint32 v = u; /* 0, else 1...65535 */
|
uint32 v = u; /* 0, else 1...65535 */
|
||||||
v = -v; /* 0, else 2^32-65535...2^32-1 */
|
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
|
||||||
v >>= 31; /* 0, else 1 */
|
v >>= 31; /* 0, else 1 */
|
||||||
return -(int) v; /* 0, else -1 */
|
return -(int) v; /* 0, else -1 */
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
static int int16_nonzero_mask(int16 x) {
|
static int int16_nonzero_mask(int16 x) {
|
||||||
uint16 u = (uint16) x; /* 0, else 1...65535 */
|
uint16 u = (uint16) x; /* 0, else 1...65535 */
|
||||||
uint32 v = u; /* 0, else 1...65535 */
|
uint32 v = u; /* 0, else 1...65535 */
|
||||||
v = -v; /* 0, else 2^32-65535...2^32-1 */
|
v = ~v + 1; /* 0, else 2^32-65535...2^32-1 */
|
||||||
v >>= 31; /* 0, else 1 */
|
v >>= 31; /* 0, else 1 */
|
||||||
return -(int) v; /* 0, else -1 */
|
return -(int) v; /* 0, else -1 */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user