forked from OpenCL/GEGL-OpenCL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gegl-random.h
162 lines (147 loc) · 4.89 KB
/
gegl-random.h
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
/* This file is part of GEGL
*
* GEGL is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* GEGL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2006 Øyvind Kolås
* Copyright 2013 Téo Mazars <[email protected]>
*/
#ifndef __GEGL_RANDOM_H__
#define __GEGL_RANDOM_H__
#include "gegl-types.h"
G_BEGIN_DECLS
/***
* Random numbers:
*
* GEGL provides functions to generate deterministic random numbers,
* based on a seed and on 2D coordinates. It allows to reproduce the
* same sequence of random numbers in both CPU and GPU devices where
* operations are not done in the same order.
*/
/**
* gegl_random_new_with_seed:
* @seed: an integer seed, change for different permutation.
*
* Return an opaque structure associated to the seed.
* This structure needs to be freed by the user with gegl_random_free();
*/
GeglRandom* gegl_random_new_with_seed (guint32 seed);
/**
* gegl_random_new:
*
* Creates a new random number generator initialized with a random seed.
* This structure needs to be freed by the user with gegl_random_free();
*/
GeglRandom* gegl_random_new (void);
/**
* gegl_random_duplicate:
* @rand: The GeglRandom to duplicate
*
* Return a new copy of an existing GeglRandom
*/
GeglRandom* gegl_random_duplicate (GeglRandom *rand);
/**
* gegl_random_free:
* @rand: The GeglRandom structure to free
*
* Free a GeglRandom structure created with gegl_random_new() or
* gegl_random_new_with_seed()
*/
void gegl_random_free (GeglRandom *rand);
/**
* gegl_random_set_seed:
* @rand: The GeglRandom to set
* @seed: an integer seed, change for different permutation.
*
* Change the seed of an existing GeglRandom.
*/
void gegl_random_set_seed (GeglRandom *rand,
guint32 seed);
/**
* gegl_random_float_range:
* @rand: a GeglRandom
* @x: x coordinate
* @y: y coordinate
* @z: z coordinate (mipmap level)
* @n: number no (each x,y coordinate provides its own sequence of
* numbers
* @min: minimum value
* @max: maxmimum value
*
* Return a random floating point number in the range specified,
* for the given x,y coordinates and GeglRandom provided, if multiple different
* numbers are needed pass in incrementing n's.
*/
gfloat gegl_random_float_range (const GeglRandom *rand,
gint x,
gint y,
gint z,
gint n,
gfloat min,
gfloat max);
/**
* gegl_random_int_range:
* @rand: a GeglRandom
* @x: x coordinate
* @y: y coordinate
* @z: z coordinate (mipmap level)
* @n: number no (each x,y coordinate provides its own sequence of
* numbers
* @min: minimum value
* @max: maxmimum value+1
*
* Return a random integer point number in the range specified,
* for the given x,y coordinates and GeglRandom provided, if multiple different
* numbers are needed pass in incrementing n's.
*/
gint32 gegl_random_int_range (const GeglRandom *rand,
gint x,
gint y,
gint z,
gint n,
gint min,
gint max);
/**
* gegl_random_int:
* @rand: a GeglRandom
* @x: x coordinate
* @y: y coordinate
* @z: z coordinate (mipmap level)
* @n: number no (each x,y coordinate provides its own sequence of
* numbers
*
* Return a random integer number in range 0 .. MAX_UINT
*/
guint32 gegl_random_int (const GeglRandom *rand,
gint x,
gint y,
gint z,
gint n);
/**
* gegl_random_float:
* @rand: a GeglRandom
* @x: x coordinate
* @y: y coordinate
* @z: z coordinate (mipmap level)
* @n: number no (each x,y coordinate provides its own sequence of
* numbers
*
* Return a random floating point number in range 0.0 .. 1.0.
*/
gfloat gegl_random_float (const GeglRandom *rand,
gint x,
gint y,
gint z,
gint n);
G_END_DECLS
#endif /* __GEGL_RANDOM_H__ */