/usr/include/numflt.h is in libapron-dev 0.9.10-5.2ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | /* ********************************************************************** */
/* numflt.h */
/* ********************************************************************** */
#ifndef _NUMFLT_H_
#define _NUMFLT_H_
#include <stdint.h>
#include "gmp.h"
#include "mpfr.h"
#include "ap_scalar.h"
#include "num_config.h"
#ifndef NUMFLT_PRINT_PREC
#define NUMFLT_PRINT_PREC 20
#endif
/* Number of significant digits used for printing.
Defaults to 20, but you can override NUMFLT_PRINT_PREC to be any other
expression (including variable and function call).
*/
#if defined(NUMFLT_DOUBLE) || defined(NUMFLT_LONGDOUBLE)
#include "numflt_native.h"
#elif defined(NUMFLT_MPFR)
#include "numflt_mpfr.h"
#else
#error "HERE"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
NUMINT_DOUBLE and NUMFLT_LONGDOUBLE also define
- NUMFLT_MAX: positive infinity value
It is assumed that (-NUMINT_MAX) is also representable
- NUMFLT_NATIVE: no heap allocated memory
*/
/* ====================================================================== */
/* Assignement */
/* ====================================================================== */
static inline void numflt_set(numflt_t a, numflt_t b);
static inline void numflt_set_array(numflt_t* a, numflt_t* b, size_t size);
static inline void numflt_set_int(numflt_t a, long int i);
/* ====================================================================== */
/* Constructors and Destructors */
/* ====================================================================== */
static inline void numflt_init(numflt_t a);
static inline void numflt_init_array(numflt_t* a, size_t size);
static inline void numflt_init_set(numflt_t a, numflt_t b);
static inline void numflt_init_set_int(numflt_t a, long int i);
static inline void numflt_clear(numflt_t a);
static inline void numflt_clear_array(numflt_t* a, size_t size);
static inline void numflt_swap(numflt_t a, numflt_t b);
/* ====================================================================== */
/* Arithmetic Operations */
/* ====================================================================== */
static inline void numflt_neg(numflt_t a, numflt_t b);
static inline void numflt_abs(numflt_t a, numflt_t b);
static inline void numflt_add(numflt_t a, numflt_t b, numflt_t c);
static inline void numflt_add_uint(numflt_t a, numflt_t b, unsigned long int c);
static inline void numflt_sub(numflt_t a, numflt_t b, numflt_t c);
static inline void numflt_sub_uint(numflt_t a, numflt_t b, unsigned long int c);
static inline void numflt_mul(numflt_t a, numflt_t b, numflt_t c);
static inline void numflt_mul_2(numflt_t a, numflt_t b);
static inline void numflt_div(numflt_t a, numflt_t b, numflt_t c);
static inline void numflt_div_2(numflt_t a, numflt_t b);
static inline void numflt_min(numflt_t a, numflt_t b, numflt_t c);
static inline void numflt_max(numflt_t a, numflt_t b, numflt_t c);
static inline void numflt_floor(numflt_t a, numflt_t b);
static inline void numflt_ceil(numflt_t a, numflt_t b);
static inline void numflt_trunc(numflt_t a, numflt_t b);
static inline void numflt_sqrt(numflt_t up, numflt_t down, numflt_t b);
static inline void numflt_mul_2exp(numflt_t a, numflt_t b, int c);
/* ====================================================================== */
/* Arithmetic Tests */
/* ====================================================================== */
static inline int numflt_sgn(numflt_t a);
static inline int numflt_cmp(numflt_t a, numflt_t b);
static inline int numflt_cmp_int(numflt_t a, long int b);
static inline bool numflt_equal(numflt_t a, numflt_t b);
static inline bool numflt_integer(numflt_t a);
/* ====================================================================== */
/* Printing */
/* ====================================================================== */
static inline void numflt_print(numflt_t a);
static inline void numflt_fprint(FILE* stream, numflt_t a);
static inline int numflt_snprint(char* s, size_t size, numflt_t a);
/* ====================================================================== */
/* Conversions */
/* ====================================================================== */
static inline bool numflt_set_int2(numflt_t a, long int i, long int j);
/* int2 -> numflt */
static inline bool numflt_set_mpz(numflt_t a, mpz_t b);
/* mpz -> numflt */
static inline bool numflt_set_mpq(numflt_t a, mpq_t b);
/* mpq -> numflt */
static inline bool numflt_set_double(numflt_t a, double b);
/* double -> numflt */
static inline bool numflt_set_mpfr(numflt_t a, mpfr_t b);
/* mpfr -> numflt */
static inline bool numflt_set_ap_scalar(numflt_t a, ap_scalar_t* b);
/* (finite) ap_scalar -> numflt */
static inline bool int_set_numflt(long int* a, numflt_t b);
/* numflt -> int */
static inline bool mpz_set_numflt(mpz_t a, numflt_t b);
/* numflt -> mpz */
static inline bool mpq_set_numflt(mpq_t a, numflt_t b);
/* numflt -> mpq */
static inline bool double_set_numflt(double* a, numflt_t b);
/* numflt -> double */
static inline bool mpfr_set_numflt(mpfr_t a, numflt_t b);
/* numflt -> mpfr */
static inline bool ap_scalar_set_numflt(ap_scalar_t* a, numflt_t b);
/* numflt -> ap_scalar */
static inline bool mpz_fits_numflt(mpz_t a);
static inline bool mpq_fits_numflt(mpq_t a);
static inline bool double_fits_numflt(double a);
static inline bool mpfr_fits_numflt(mpfr_t a);
static inline bool numflt_fits_int(numflt_t a);
static inline bool numflt_fits_float(numflt_t a);
static inline bool numflt_fits_double(numflt_t a);
static inline bool numflt_fits_mpfr(numflt_t a);
/* Optimized versions */
/* mpfr should have exactly the precision NUMFLT_MANT_DIG */
static inline bool numflt_set_mpz_tmp(numflt_t a, mpz_t b, mpfr_t mpfr);
static inline bool numflt_set_mpq_tmp(numflt_t a, mpq_t b, mpfr_t mpfr);
/* ====================================================================== */
/* Only for floating point */
/* ====================================================================== */
static inline bool numflt_infty(numflt_t a);
static inline void numflt_set_infty(numflt_t a, int sgn);
/* ====================================================================== */
/* Serialization */
/* ====================================================================== */
static inline unsigned char numflt_serialize_id(void)
{ return 0x20 + sizeof(numflt_t)/4; }
static inline size_t numflt_serialize(void* dst, numflt_t src);
static inline size_t numflt_deserialize(numflt_t dst, const void* src);
static inline size_t numflt_serialized_size(numflt_t a);
/* */
static inline bool numflt_set_ap_scalar(numflt_t a, ap_scalar_t* b)
{
assert (ap_scalar_infty(b)==0);
switch (b->discr){
case AP_SCALAR_MPQ:
return numflt_set_mpq(a,b->val.mpq);
case AP_SCALAR_DOUBLE:
return numflt_set_double(a,b->val.dbl);
case AP_SCALAR_MPFR:
return numflt_set_mpfr(a,b->val.mpfr);
default: abort();
}
}
static inline bool ap_scalar_set_numflt(ap_scalar_t* a, numflt_t b);
#ifdef __cplusplus
}
#endif
#endif
|