divergenceOfCiphertextDouble function

Ciphertext divergenceOfCiphertextDouble(
  1. Afhe fhe,
  2. Ciphertext x,
  3. Ciphertext logX,
  4. double q,
)

Kullback-Leibler Divergence between Ciphertext and double

See divergence for more details.

Implementation

Ciphertext divergenceOfCiphertextDouble(
    Afhe fhe, Ciphertext x, Ciphertext logX, double q) {
  Plaintext logQ = fhe.encodeDouble(log(q));
  Ciphertext subLog = fhe.subtractPlain(logX, logQ);
  return fhe.multiply(x, subLog);
}