blob: dc40c5975242aa990fdf942ecef2bbf8158b0ea4 (
plain)
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
|
#+TITLE: n-sphere Monte Carlo Method
This repository is the source code accompanying the papers [[https://arxiv.org/abs/2101.00936][An O(n)
algorithm for generating uniform random vectors in n-dimensional cones]]
and [[https://arxiv.org/abs/2007.06808][An algorithm for estimating volumes and other integrals in n
dimensions]].
* Build
Build dependencies are
- cmake and make (for the build system)
- [[https://github.com/sph-mn/sph-sc][sph-sc]] (to generate C sources from SC sources)
- [[https://www.gnu.org/software/indent/][indent]] (optional; to indent the generated sources)
- [[https://www.gnu.org/software/gsl/][GNU Scientific Library]] (for vector and scientific functions)
- [[https://gnu.org/software/guile][GNU Guile]] (for the scheme wrappers)
The easiest way to install these dependencies is to use a [[https://guix.gnu.org/][guix]]
environment.
#+BEGIN_SRC shell
$ guix environment -l guix.scm
#+END_SRC
To build, run the following commands.
#+BEGIN_SRC shell
$ cmake -B build
$ make -C build
#+END_SRC
* Usage
See examples in the /examples/ directory. You can build and run them,
for example, using the following commands. /pre-inst-env/ is a shell
wrapper that sets the necessary environment variables so that headers
and dynamic libraries are found correctly.
#+BEGIN_SRC shell
$ ./build/pre-inst-env gcc -lgsl -lgslcblas -lnsmc examples/generate-cone-vector.c -o generate-cone-vector
$ ./build/pre-inst-env ./generate-cone-vector
#+END_SRC
* Citing
If you use this code for your research, please cite one or more of the
following papers as relevant.
- [[https://arxiv.org/abs/2101.00936][An O(n) algorithm for generating uniform random vectors in n-dimensional cones]]
- [[https://arxiv.org/abs/2007.06808][An algorithm for estimating volumes and other integrals in n dimensions]]
* License
The source code is free software released under the terms of the [[https://www.gnu.org/licenses/gpl.html][GNU
General Public License]], either version 3 of the License, or (at your
option) any later version.
|