Skip to content

Instantly share code, notes, and snippets.

@pathaine
Last active September 3, 2019 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pathaine/286c4adee2b1f78e1d2cda81a9365018 to your computer and use it in GitHub Desktop.
Save pathaine/286c4adee2b1f78e1d2cda81a9365018 to your computer and use it in GitHub Desktop.
Plaintext calculate_cosine_array(int n, int N, int start, int stop, CryptoContext<DCRTPoly> cc) {
vector<int64_t> *cosines = new vector<int64_t>();
for (int k = 0; k != N; k++) {
if (k < start || k >= stop) {
cosines->push_back(0);
continue;
}
int cosVal = int(cos(((2 * pi * k * n) / N)) * 100); //FOR MORE ACCURATE RESULTS, INCREASE MULTIPLE OF 10
cosines->push_back(cosVal);
}
Plaintext cosineArray = cc->MakePackedPlaintext(*cosines);
return cosineArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment