joeydumont / complex_bessel Goto Github PK
View Code? Open in Web Editor NEWA C++ library to evaluate Bessel functions of all kinds.
License: GNU Lesser General Public License v3.0
A C++ library to evaluate Bessel functions of all kinds.
License: GNU Lesser General Public License v3.0
Hi valandil, thank you very much for your work porting complex bessel functions to c++ library.
I've encountered a problem here, when I try to compile tests/simpleTest.cpp with command "g++ -lgfortran -lcomplex_bessel simpleTest.cpp " to check if the library installed successfully or not, I got this errors:
/tmp/ccGbRgNM.o: In function sp_bessel::besselJ(double, std::complex<double>)': simpleTest.cpp:(.text._ZN9sp_bessel7besselJEdSt7complexIdE[_ZN9sp_bessel7besselJEdSt7complexIdE]+0x101): undefined reference to
zbesj_wrap'
simpleTest.cpp:(.text._ZN9sp_bessel7besselJEdSt7complexIdE[_ZN9sp_bessel7besselJEdSt7complexIdE]+0x250): undefined reference to zbesy_wrap' /tmp/ccGbRgNM.o: In function
sp_bessel::besselY(double, std::complex)':
simpleTest.cpp:(.text._ZN9sp_bessel7besselYEdSt7complexIdE[_ZN9sp_bessel7besselYEdSt7complexIdE]+0x116): undefined reference to zbesy_wrap' simpleTest.cpp:(.text._ZN9sp_bessel7besselYEdSt7complexIdE[_ZN9sp_bessel7besselYEdSt7complexIdE]+0x254): undefined reference to
zbesj_wrap'
/tmp/ccGbRgNM.o: In function sp_bessel::besselK(double, std::complex<double>)': simpleTest.cpp:(.text._ZN9sp_bessel7besselKEdSt7complexIdE[_ZN9sp_bessel7besselKEdSt7complexIdE]+0xcb): undefined reference to
zbesk_wrap'
collect2: error: ld returned 1 exit status
I don't know what's wrong with it. Hope you can have time to look into it.
FYI, my os is Ubuntu 15.04. Also I've commented the lines containing besselH1 and besselH1p.
Thank you again!
Regards!
From [email protected] on December 22, 2013 23:57:12
What steps will reproduce the problem? 1. while i type ./configure i get no command found 2. 3. What is the expected output? What do you see instead? What version of the product are you using? On what operating system? Please provide any additional information below.
Original issue: http://code.google.com/p/complex-bessel/issues/detail?id=1
Can you please add convenience functions for spherical hankel/bessel functions?
Regards
Thomas
Not so much as issue but , is the library thread safe?
Hi, i'm currently working on a similar project in rust and i used a lot of your code in it,
Do you mind telling me how do you wish to be cited ?
I'm sorry but i'm fairly new and i don't want to make mistakes before publishing on crates.io
here's the repo: https://github.com/ChristianBelloni/complex-bessel-rs
Have a nice day!
From [email protected] on May 15, 2014 17:33:35
What steps will reproduce the problem? 1. Compile a test code that outputs sp_bessel::airy(s) or airyp(s) where complex s[s1,s2] ranges from [0,0] to [100000, 100000](using 2 for- loops, 1 for real and 1 for imag parts of s). Set the optimization option -O3.
2. Repeat the above without the optimization option to build a debug version with -ggdb. 3. What is the expected output? What do you see instead? Expected output is the one obtained from Step 2 above. With Step 1, I instead see a constant, same output of the airy function for all complex s when arg(s) crosses the "underflow" line corresponding to arg = -pi/3.
Basically, optimization option breaks underflow handling in the fortran code. This could be related to the way the library is compiled from the fortran code (which is a good thing) or could be simply inherent to the code (which is a bad thing). What version of the product are you using? On what operating system? Using the release-0.3.1 on Intel(R) Xeon(R) CPU E7540 @ 2.00GHz with Linux version 2.6.32-431.11.2.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) Please provide any additional information below. Please get back to me if you need any more information. I can provide you with a sample code to do this.
Original issue: http://code.google.com/p/complex-bessel/issues/detail?id=2
For low |z|
, it seems that the real part of the Hankel functions, i.e. zbesh
, overflow instead of going to zero. The original documentation indicates that tests are performed to limit overflows, but I need to confirm this.
My initial tests show that SciPy also suffers the same issue.
The code below shows the issue:
#include <complex_bessel.h>
#include <iostream>
#include <array>
using namespace std::complex_literals;
using namespace sp_bessel;
static constexpr int size = 20;
static constexpr double exp_min = -15;
static constexpr double exp_max = 1;
static constexpr double dx = (exp_max-exp_min)/size;
static const int nu = 4;
int main (int argc, char* argv[])
{
std::array<double,size> exponent;
std::array<double,size> z;
for (auto i = 0; i < size; i++)
{
exponent[i] = exp_min + i*dx;
z[i] = std::pow(10,exponent[i]);
std::cout << "Hankel function: z[i]" << z[i] << ", " << hankelH2(nu, z[i]) << std::endl;
std::cout << "Bessel function: z[i]" << z[i] << ", " << besselJ(nu, z[i])-1i*besselY(nu,z[i]) << std::endl;
//std::cout << "Bessel function of the second kind: " << besselY(nu, z[i]) << std::endl;
}
//double z = 8.693214466689956e-11;
return 0;
}
Thanks to @NiDingRte for reporting the issue.
As title
First Kudos to D.E. Amos, and Dumont and McNogginson for making the original Fortran code and supplying a wrapper for c+. Since c / c++ is the only code I know at a moderately advanced level, your work has been of great benefit to me and I hope many others. I did need to translate the Amos code given in the github link into c / c++ as I spent a lot of time trying to get the wrapper to work using Visual Studio Community 2022 (64-bit) Version 19.9.6 but was not able to do so as my understanding of doing so is rather limited.
After completing all subroutines (now functions completely called by reference) required for Bessel Functions of the 1st kind, as well as the partially redundant Hanke1 and 2 functions, I tested the c code (both the translated Fortran as well as the original Fortran. They seem to work almost alright, but I I am having a problem when the argument to these functions is a pure real number. In this case, the return value for bessj() always contains an imaginary component (for example argument 1.328, with fnu = 1 and N = 100). This is a disappointment for me because I have been looking for a robust manner to calculate complex Bessel Functions for some time in order to design laser light scattering program that will work with absorbing particles in order to design and interpret phase Doppler Anamometry experiments for particle sizing. Can anyone offer me an explanation for the behavior I am observing as well as a way around the problem. Thanks again.
I may try to introduce a modern CMake (3.16+) configuration files according to https://cliutils.gitlab.io/modern-cmake/ This will make it much easier to include this package to other modern CMake projects, however, it will break compatibility for existing users (as we need to link it using namespaces in modern CMake). @joeydumont Are you interested in such a contribution?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.