PLaSK library

Loading...
Searching...
No Matches
besselj.hpp
Go to the documentation of this file.
1/*
2 * This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
3 * Copyright (c) 2022 Lodz University of Technology
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14#ifndef PLASK__SOLVER__SLAB_BESSELJ_H
15#define PLASK__SOLVER__SLAB_BESSELJ_H
16
17
18#include <plask/optical/modal/config.hpp>
19
20
21#ifdef USE_GSL
22# include <gsl/gsl_sf_bessel.h>
23
24 inline double cyl_bessel_j(int m, double x) {
25 return gsl_sf_bessel_Jn(m, x);
26 }
27
28 template <typename It>
29 inline void cyl_bessel_j_zero(int m, size_t i, size_t n, It dst) {
30 if (m == 0) {
31 for (n = n+i; i < n; ++i, ++dst) *dst = gsl_sf_bessel_zero_J0(i);
32 } else if (m == 1) {
33 for (n = n+i; i < n; ++i, ++dst) *dst = gsl_sf_bessel_zero_J1(i);
34 } else {
35 double nu = m;
36 for (n = n+i; i < n; ++i, ++dst) *dst = gsl_sf_bessel_zero_Jnu(nu, i);
37 }
38 }
39
40#else
41# include <boost/math/special_functions/bessel.hpp>
42 using boost::math::cyl_bessel_j;
43 using boost::math::cyl_bessel_j_zero;
44#endif
45
46
47#endif // PLASK__SOLVER__SLAB_BESSELJ_H