1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch, M. Oliveira
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
21module loct_math_oct_m
22  implicit none
23
24  !> Define which routines can be seen from the outside.
25  private
26  public ::                    &
27    loct_gamma,                &
28    loct_incomplete_gamma,     &
29    loct_erf,                  &
30    loct_erfc,                 &
31    loct_ylm,                  &
32    loct_bessel,               &
33    loct_bessel_in,            &
34    loct_bessel_j0,            &
35    loct_bessel_j1,            &
36    loct_bessel_k0,            &
37    loct_bessel_k1,            &
38    loct_sph_bessel,           &
39    loct_legendre_sphplm,      &
40    loct_sf_laguerre_n,        &
41    loct_ran_init,             &
42    loct_ran_end,              &
43    loct_ran_gaussian,         &
44    loct_ran_flat,             &
45    loct_fft_optimize,         &
46    loct_combination_init,     &
47    loct_combination_end,      &
48    loct_combination_next,     &
49    loct_get_combination
50
51
52  ! ---------------------------------------------------------
53  !> Special functions
54  interface loct_gamma
55    function oct_gamma(x)
56      implicit none
57      real(8) :: oct_gamma
58      real(8), intent(in) :: x
59    end function oct_gamma
60  end interface loct_gamma
61
62  interface loct_incomplete_gamma
63    function oct_incomplete_gamma(a, x)
64      implicit none
65      real(8) :: oct_incomplete_gamma
66      real(8), intent(in) :: a, x
67    end function oct_incomplete_gamma
68  end interface loct_incomplete_gamma
69
70  interface loct_bessel
71    function oct_bessel(n, x)
72      implicit none
73      real(8) :: oct_bessel
74      integer, intent(in) :: n
75      real(8), intent(in) :: x
76    end function oct_bessel
77  end interface loct_bessel
78
79  interface loct_bessel_in
80    function oct_bessel_in(n, x)
81      implicit none
82      real(8) :: oct_bessel_in
83      integer, intent(in) :: n
84      real(8), intent(in) :: x
85    end function oct_bessel_in
86  end interface loct_bessel_in
87
88  interface loct_sph_bessel
89    function oct_sph_bessel(l, x)
90      implicit none
91      real(8) :: oct_sph_bessel
92      integer, intent(in) :: l
93      real(8), intent(in) :: x
94    end function oct_sph_bessel
95  end interface loct_sph_bessel
96
97  interface loct_bessel_j0
98    function oct_bessel_j0(x)
99      implicit none
100      real(8) :: oct_bessel_j0
101      real(8), intent(in) :: x
102    end function oct_bessel_j0
103  end interface loct_bessel_j0
104
105  interface loct_bessel_j1
106    function oct_bessel_j1(x)
107      implicit none
108      real(8) :: oct_bessel_j1
109      real(8), intent(in) :: x
110    end function oct_bessel_j1
111  end interface loct_bessel_j1
112
113  interface loct_bessel_k0
114    function oct_bessel_k0(x)
115      implicit none
116      real(8) :: oct_bessel_k0
117      real(8), intent(in) :: x
118    end function oct_bessel_k0
119  end interface loct_bessel_k0
120
121  interface loct_bessel_k1
122    function oct_bessel_k1(x)
123      implicit none
124      real(8) :: oct_bessel_k1
125      real(8), intent(in) :: x
126    end function oct_bessel_k1
127  end interface loct_bessel_k1
128
129  interface loct_erf
130    function oct_erf(x)
131      implicit none
132      real(8) :: oct_erf
133      real(8), intent(in) :: x
134    end function oct_erf
135  end interface loct_erf
136
137  interface loct_erfc
138    function oct_erfc(x)
139      implicit none
140      real(8) oct_erfc
141      real(8), intent(in) :: x
142    end function oct_erfc
143  end interface loct_erfc
144
145  interface loct_legendre_sphplm
146    function oct_legendre_sphplm(l, m, x)
147      implicit none
148      real(8) :: oct_legendre_sphplm
149      integer, intent(in) :: l, m
150      real(8), intent(in) :: x
151    end function oct_legendre_sphplm
152  end interface loct_legendre_sphplm
153
154  interface loct_sf_laguerre_n
155    function oct_sf_laguerre_n(n, a, x)
156      implicit none
157      real(8) :: oct_sf_laguerre_n
158      integer, intent(in) :: n
159      real(8), intent(in) :: a
160      real(8), intent(in) :: x
161    end function oct_sf_laguerre_n
162  end interface loct_sf_laguerre_n
163
164  interface loct_ylm
165    subroutine oct_ylm(n, x, y, z, l, m, ylm)
166      implicit none
167      integer, intent(in)  :: n
168      real(8), intent(in)  :: x, y, z
169      integer, intent(in)  :: l, m
170      real(8), intent(out) :: ylm
171    end subroutine oct_ylm
172  end interface loct_ylm
173
174  ! ---------------------------------------------------------
175  !> Functions to generate combinations
176  interface loct_combination_init
177    subroutine oct_combination_init(c, n, k)
178      use iso_c_binding
179      implicit none
180      type(c_ptr), intent(out) :: c
181      integer,     intent(in)  :: n, k
182    end subroutine oct_combination_init
183  end interface loct_combination_init
184
185  interface loct_combination_end
186    subroutine oct_combination_end(c)
187      use iso_c_binding
188      implicit none
189      type(c_ptr), intent(in) :: c
190    end subroutine oct_combination_end
191  end interface loct_combination_end
192
193  interface loct_combination_next
194    subroutine oct_combination_next(c, next)
195      use iso_c_binding
196      implicit none
197      type(c_ptr), intent(inout) :: c
198      integer,     intent(out)  :: next
199    end subroutine oct_combination_next
200  end interface loct_combination_next
201
202  interface
203    subroutine oct_get_combination(c, comb)
204      use iso_c_binding
205      type(c_ptr), intent(in)  :: c
206      integer,     intent(out) :: comb
207    end subroutine oct_get_combination
208  end interface
209
210  ! ---------------------------------------------------------
211  !> Functions to generate random numbers
212  interface loct_ran_init
213    subroutine oct_ran_init(r)
214      use iso_c_binding
215      implicit none
216      type(c_ptr), intent(out) :: r
217    end subroutine oct_ran_init
218  end interface loct_ran_init
219
220  interface loct_ran_end
221    subroutine oct_ran_end(r)
222      use iso_c_binding
223      implicit none
224      type(c_ptr), intent(inout) :: r
225    end subroutine oct_ran_end
226  end interface loct_ran_end
227
228  interface loct_ran_gaussian
229    function oct_ran_gaussian(r, sigma)
230      use iso_c_binding
231      implicit none
232      real(8) :: oct_ran_gaussian
233      type(c_ptr), intent(in) :: r
234      real(8),     intent(in) :: sigma
235    end function oct_ran_gaussian
236  end interface loct_ran_gaussian
237
238  interface loct_ran_flat
239    function oct_ran_flat(r, a, b)
240      use iso_c_binding
241      implicit none
242      real(8) :: oct_ran_flat
243      type(c_ptr), intent(in) :: r
244      real(8),     intent(in) :: a
245      real(8),     intent(in) :: b
246    end function oct_ran_flat
247  end interface loct_ran_flat
248
249  interface loct_fft_optimize
250    subroutine oct_fft_optimize(n, par)
251      implicit none
252      integer, intent(inout) :: n
253      integer, intent(in)    :: par
254    end subroutine oct_fft_optimize
255  end interface loct_fft_optimize
256
257contains
258
259  subroutine loct_get_combination(c, comb)
260    use iso_c_binding
261    type(c_ptr),      intent(in)  :: c
262    integer,          intent(out) :: comb(0:) !< Assume C-style array indices (i.e. start from 0)
263
264    call oct_get_combination(c, comb(0))
265  end subroutine loct_get_combination
266
267end module loct_math_oct_m
268
269!! Local Variables:
270!! mode: f90
271!! coding: utf-8
272!! End:
273