Skip to content

How to compute the maximum value of a vector and its index #257

Closed Answered by Pro7ech
macknight asked this question in Q&A
Discussion options

You must be logged in to vote

To compute max(a,b):

If you are using BFV/BGV: https://petsymposium.org/popets/2021/popets-2021-0046.pdf

If you are using CKKS: https://www.computer.org/csdl/journal/tq/5555/01/09517029/1wau0zex2z6 (eprint is down at the time of this post)
Else you can compose CKKS with lookup tables to evaluate non-linear functions, such as sign or ReLU. See the example in lattigo/examples/ckks/advanced/lut -> max(a, b) = b + ReLU(a-b) and ReLU(x) = x * sign(x) where sign(x) = 0 if x < 0 else 1.

To compute index_max(vector):

Compose the above with an FFT-like algorithm, comparing pairs of elements. After log2(vector_size) iterations, you'll end up with a vector encrypting all zero except 1 a the index of…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@macknight
Comment options

@Pro7ech
Comment options

Answer selected by macknight
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #256 on August 31, 2022 10:46.