CiFEr
normal_cumulative.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 XLAB d.o.o.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CIFER_NORMAL_CUMULATIVE_H
18 #define CIFER_NORMAL_CUMULATIVE_H
19 
20 #include "cifer/sample/normal.h"
21 
36 typedef struct cfe_normal_cumulative {
37  cfe_normal nor;
38  cfe_vec precomputed; // table of precomputed values relative to the cumulative distribution
39  bool two_sided; // twoSided defines if we limit sampling only to non-negative integers or to all
40  mpz_t sample_size; // integer defining from how big of an interval do we need to sample uniformly to sample according to discrete Gauss
42 
53 void cfe_normal_cumulative_init(cfe_normal_cumulative *s, mpf_t sigma, size_t n, bool two_sided);
54 
63 
72 
81 
94 size_t cfe_locate_int(mpz_t sample, size_t start, size_t end, cfe_vec *v, mpz_t middle_value);
95 
100 
105 
106 #endif
cfe_normal_cumulative_free
void cfe_normal_cumulative_free(cfe_normal_cumulative *s)
cfe_normal_cumulative
struct cfe_normal_cumulative cfe_normal_cumulative
cfe_vec
Definition: vec.h:41
cfe_locate_int
size_t cfe_locate_int(mpz_t sample, size_t start, size_t end, cfe_vec *v, mpz_t middle_value)
cfe_normal_cumulative_precompute
void cfe_normal_cumulative_precompute(cfe_normal_cumulative *s)
cfe_normal_cumulative_sample
void cfe_normal_cumulative_sample(mpz_t res, cfe_normal_cumulative *s)
cfe_normal_cumulative_sample_vec
void cfe_normal_cumulative_sample_vec(cfe_vec *res, cfe_normal_cumulative *s)
cfe_normal_cumulative_sample_mat
void cfe_normal_cumulative_sample_mat(cfe_mat *res, cfe_normal_cumulative *s)
cfe_normal
Definition: normal.h:34
cfe_normal_cumulative_init
void cfe_normal_cumulative_init(cfe_normal_cumulative *s, mpf_t sigma, size_t n, bool two_sided)
normal.h
Normal sampler.
cfe_mat
Definition: mat.h:44
cfe_normal_cumulative
Definition: normal_cumulative.h:36