CiFEr
normal.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_H
18 #define CIFER_NORMAL_H
19 
20 #include <gmp.h>
21 #include "cifer/data/vec.h"
22 #include "cifer/data/vec_float.h"
23 
34 typedef struct cfe_normal {
35  mpf_t sigma; // Standard deviation
36  size_t n; // Precision parameter
37  cfe_vec_float pre_exp; // Precomputed values of exponential function with precision n
38  mpz_t pow_n; // Precomputed values for quicker sampling
39  mpf_t pow_nf;
40 } cfe_normal;
41 
45 void cfe_normal_init(cfe_normal *s, mpf_t sigma, size_t n);
46 
52 
61 
67 bool cfe_normal_is_exp_greater(cfe_normal *s, mpf_t y, mpz_t x);
68 
73 void cfe_taylor_exp(mpf_t res, mpz_t x, mpf_t alpha, size_t k, size_t n);
74 
89 bool cfe_bernoulli(mpz_t t, mpf_t k_square_inv);
90 
94 void cfe_mean(mpf_t res, cfe_vec *vec);
95 
99 void cfe_variance(mpf_t res, cfe_vec *vec);
100 
101 #endif
cfe_mean
void cfe_mean(mpf_t res, cfe_vec *vec)
cfe_vec
Definition: vec.h:41
cfe_variance
void cfe_variance(mpf_t res, cfe_vec *vec)
cfe_normal_free
void cfe_normal_free(cfe_normal *s)
cfe_vec_float
Definition: vec_float.h:34
vec_float.h
Vector float struct.
cfe_normal_init
void cfe_normal_init(cfe_normal *s, mpf_t sigma, size_t n)
cfe_taylor_exp
void cfe_taylor_exp(mpf_t res, mpz_t x, mpf_t alpha, size_t k, size_t n)
cfe_normal
struct cfe_normal cfe_normal
cfe_bernoulli
bool cfe_bernoulli(mpz_t t, mpf_t k_square_inv)
cfe_normal_is_exp_greater
bool cfe_normal_is_exp_greater(cfe_normal *s, mpf_t y, mpz_t x)
vec.h
Vector struct and operations.
cfe_normal
Definition: normal.h:34
cfe_normal_precomp_exp
void cfe_normal_precomp_exp(cfe_normal *s)