ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
math_functions.h
Go to the documentation of this file.
1#pragma once
2
3#include <driver_types.h>
4
5#define M_PI 3.14159265358979323846
6#define M_PI_2 1.57079632679489661923132169164 // Pi/2
7#define NEPERIANO 2.718281828
8#define PREC 1e-16
9
10// Module Single Precision Mathematical Functions
11
12__device__ float exp10f(float x);
13
15 float x,
16 float y); // powf_gpu para não confundir com pow definida por c++ em math.h
17
18float __exp10f(float x);
19
20float __powf_gpu(float x, float y);
21
22__device__ float exp10f(float x)
23{
24 return __exp10f(x);
25}
26
27__device__ float powf_gpu(float a, float b)
28{
29 return __powf_gpu(a, b);
30}
31
32float __exp10f(float x)
33{
34 return __powf_gpu(10, x);
35}
36
37float __powf_gpu(float x, float y)
38{
39 int result = 1;
40
41 if (y == 0)
42 return result;
43
44 if (y < 0)
45 return 1 / __powf_gpu(x, -y);
46 else
47 {
48 for (int i = 0; i < y; ++i)
49 result *= x;
50
51 return result;
52 }
53}
54
55int __mul24(int x, int y);
56
57unsigned int __umul24(unsigned int x, unsigned int y);
58
59int __mul24(int x, int y)
60{
61 int cx;
62 int cy;
63 cx = x & 0x0000000000111111;
64 cy = y & 0x0000000000111111;
65 return cx * cy;
66}
67
68unsigned int __umul24(unsigned int x, unsigned int y)
69{
70 unsigned cx;
71 unsigned cy;
72 cx = x & 0x0000000000111111;
73 cy = y & 0x0000000000111111;
74 return cx * cy;
75}
#define __device__
Definition host_defines.h:113
__device__ float powf_gpu(float x, float y)
Definition math_functions.h:27
__device__ float exp10f(float x)
Definition math_functions.h:22
unsigned int __umul24(unsigned int x, unsigned int y)
Definition math_functions.h:68
float __exp10f(float x)
Definition math_functions.h:32
int __mul24(int x, int y)
Definition math_functions.h:59
float __powf_gpu(float x, float y)
Definition math_functions.h:37