Giter Club home page Giter Club logo

complex_bessel's People

Contributors

craffael avatar gitter-badger avatar joeydumont avatar jrepan avatar kostyfisik avatar mcnoggins avatar vgiunzioni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

complex_bessel's Issues

Compile simpleTest.cpp errors

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 tozbesj_wrap'
simpleTest.cpp:(.text._ZN9sp_bessel7besselJEdSt7complexIdE[_ZN9sp_bessel7besselJEdSt7complexIdE]+0x250): undefined reference to zbesy_wrap' /tmp/ccGbRgNM.o: In functionsp_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 tozbesj_wrap'
/tmp/ccGbRgNM.o: In function sp_bessel::besselK(double, std::complex<double>)': simpleTest.cpp:(.text._ZN9sp_bessel7besselKEdSt7complexIdE[_ZN9sp_bessel7besselKEdSt7complexIdE]+0xcb): undefined reference tozbesk_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!

Thread safety?

Not so much as issue but , is the library thread safe?

Optimization breaks underflow handling

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

Hankel functions overflowing for |z| < 10^{-1}

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.

Caclulating Bessel functions of a first kind with a real and imaginary component yields a complex vice real number

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.