From: Steven G. J. <st...@al...> - 2012-10-25 03:34:38
|
Hi all, in case there is interest I wanted to let you know that I've written a free complex-argument error function in C++ with an Octave wrapper at: http://ab-initio.mit.edu/wiki/index.php/Faddeeva_w (This is the Faddeeva function w(z), which is equivalent to erfcx(iz) where erfcx is the scaled complementary error function.) It works for arbitrary complex arguments and attains nearly machine precision everywhere in the complex plane. It is under the MIT License, which is GPL compatible. Is there interest in this? If so, is the right place octave-forge/specfun, or ...? Regards, Steven G. Johnson |
From: Juan P. C. <aju...@gm...> - 2012-10-25 06:42:07
|
On Thu, Oct 25, 2012 at 5:34 AM, Steven G. Johnson <st...@al...> wrote: > Hi all, in case there is interest I wanted to let you know that I've > written a free complex-argument error function in C++ with an Octave > wrapper at: > > http://ab-initio.mit.edu/wiki/index.php/Faddeeva_w > > (This is the Faddeeva function w(z), which is equivalent to erfcx(iz) > where erfcx is the scaled complementary error function.) It works for > arbitrary complex arguments and attains nearly machine precision > everywhere in the complex plane. It is under the MIT License, which is > GPL compatible. > > Is there interest in this? If so, is the right place > octave-forge/specfun, or ...? > > Regards, > Steven G. Johnson > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > _______________________________________________ > Octave-dev mailing list > Oct...@li... > https://lists.sourceforge.net/lists/listinfo/octave-dev Steve, Thanks! You can upload your function to the feature request forum https://sourceforge.net/p/octave/feature-requests/ Then we can look at your code and suggest improvements, etc..., if needed. In which field is your function used the most? JPi |
From: Robert T. S. <oc...@ph...> - 2012-10-25 13:22:29
|
On 10/24/2012 11:42 PM, Juan Pablo Carbajal wrote: > On Thu, Oct 25, 2012 at 5:34 AM, Steven G. Johnson <st...@al...> wrote: >> Hi all, in case there is interest I wanted to let you know that I've >> written a free complex-argument error function in C++ with an Octave >> wrapper at: >> >> http://ab-initio.mit.edu/wiki/index.php/Faddeeva_w >> >> (This is the Faddeeva function w(z), which is equivalent to erfcx(iz) >> where erfcx is the scaled complementary error function.) It works for >> arbitrary complex arguments and attains nearly machine precision >> everywhere in the complex plane. It is under the MIT License, which is >> GPL compatible. >> >> Is there interest in this? If so, is the right place >> octave-forge/specfun, or ...? >> >> Regards, >> Steven G. Johnson >> >> >> ------------------------------------------------------------------------------ >> Everyone hates slow websites. So do we. >> Make your web apps faster with AppDynamics >> Download AppDynamics Lite for free today: >> http://p.sf.net/sfu/appdyn_sfd2d_oct >> _______________________________________________ >> Octave-dev mailing list >> Oct...@li... >> https://lists.sourceforge.net/lists/listinfo/octave-dev > Steve, > > Thanks! > You can upload your function to the feature request forum > https://sourceforge.net/p/octave/feature-requests/ > > Then we can look at your code and suggest improvements, etc..., if needed. > > In which field is your function used the most? > > JPi > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > _______________________________________________ > Octave-dev mailing list > Oct...@li... > https://lists.sourceforge.net/lists/listinfo/octave-dev > > Would this go in the special functions package? I would be interested in knowing how you use this. Bob |
From: Steven G. J. <st...@al...> - 2012-10-27 17:24:23
|
Juan Pablo Carbajal wrote: > Then we can look at your code and suggest improvements, etc..., if needed. > > In which field is your function used the most? The complex error function (generalizing erf, erfc, and erfx) is used in lots of fields. We needed it to solve electromagnetic scattering problems via integral-equation methods, where it appears in Ewald summations of Green's functions in periodic domains. It is also used to compute the Voigt functions in spectroscopy (http://en.wikipedia.org/wiki/Voigt_profile), the dispersion relation in plasmas (http://farside.ph.utexas.edu/teaching/plasma/lectures/node87.html), diffusion problems, and probably in other areas I don't know about. Steven |
From: Steven G. J. <st...@al...> - 2012-10-27 18:54:19
|
Juan Pablo Carbajal wrote: > You can upload your function to the feature request forum > https://sourceforge.net/p/octave/feature-requests/ > > Then we can look at your code and suggest improvements, etc..., if needed. I've created a ticket: https://sourceforge.net/p/octave/feature-requests/42/ I didn't attach the code but instead gave the link, mainly because I'll probably be posting an updated version of the code shortly with some accuracy improvements. --SGJ |
From: Steven G. J. <st...@al...> - 2012-11-04 04:34:34
|
There is an updated version of my package (http://ab-initio.mit.edu/Faddeeva) which computes not only the Faddeeva function (the scaled complex error function) but also the ordinary erf and erfc functions of complex arguments, as well as the erfcx and erfi variants and the Dawson function (a scaled erfi). This should make it relatively painless to drop it in as a replacement for the Octave erf and erfc functions in order to support complex arguments. I would also strongly recommend providing user-callable interfaces for the erfcx, erfi, Dawson, and Faddeeva functions as well. (The scaled variants are especially important to work with error functions in the regimes where they are exponentially small or large, in order to avoid overflow/underflow limitations.) Let me know if there is anything else I can do to help. Steven |
From: Jordi G. H. <jo...@oc...> - 2012-11-20 21:34:00
|
On 4 November 2012 00:34, Steven G. Johnson <st...@al...> wrote: > There is an updated version of my package > (http://ab-initio.mit.edu/Faddeeva) which computes not only the Faddeeva > function (the scaled complex error function) but also the ordinary erf > and erfc functions of complex arguments, as well as the erfcx and erfi > variants and the Dawson function (a scaled erfi). > > This should make it relatively painless to drop it in as a replacement > for the Octave erf and erfc functions in order to support complex arguments. I'm still not sure what to do with this code... It sounds useful, sure, but you didn't write it for Octave except for a small wrapper. Since you're trying to overwrite Octave functions, it should go in Octave core but you also want to provide a bunch of other special functions, so those should go in the specfun package in OF. I'm also not sure how committed you are to maintaining this code for Octave. If this is a one-time code dump and it's up to us to maintain this code in the future, I'm less inclined to accept it into Octave core, since it's a relatively rare request. I have never heard of our users clamouring for the Faddeeva function or its relatives. What do you think, how committed are you feeling? - Jordi G. H. |
From: Daniel J S. <dan...@ie...> - 2012-11-20 22:33:49
|
Hi Steven, Some comments below with regards to Jordi's observations on integration. On 11/20/2012 03:33 PM, Jordi Gutiérrez Hermoso wrote: > On 4 November 2012 00:34, Steven G. Johnson<st...@al...> wrote: >> There is an updated version of my package >> (http://ab-initio.mit.edu/Faddeeva) which computes not only the Faddeeva >> function (the scaled complex error function) but also the ordinary erf >> and erfc functions of complex arguments, as well as the erfcx and erfi >> variants and the Dawson function (a scaled erfi). >> >> This should make it relatively painless to drop it in as a replacement >> for the Octave erf and erfc functions in order to support complex arguments. > > I'm still not sure what to do with this code... It sounds useful, > sure, but you didn't write it for Octave except for a small wrapper. > Since you're trying to overwrite Octave functions, it should go in > Octave core but you also want to provide a bunch of other special > functions, so those should go in the specfun package in OF. How much of this is the Faddeeva function and how much of it is supporting code? One concern I would have, just looking at the code for a few minutes, is all the repetitive routines for square root, sinc, etc. I would think the preference should be to utilize such algorithms from Octave's core or utilize the library that Octave is using. That way things remain consistent. The issue for integration is then what hunks to integrate and how. The package can certainly remain in the current form. For reference, the current erf and erfc appear to come from the standard math library: # gl_COMMON_DOUBLE_MATHFUNC(FUNC) # ------------------------------- # tests whether the function FUNC is available in libc or libm. # It sets FUNC_LIBM to empty or "-lm" accordingly. # FUNC must be one of the following functions, that are present on all systems # and provided by libm on all systems except Mac OS X, BeOS, Haiku: # acos asin atan atan2 cbrt cos cosh erf erfc exp fmod hypot j0 j1 jn lgamma # log log10 log1p pow remainder sin sinh sqrt tan tanh y0 y1 yn > I'm also not sure how committed you are to maintaining this code for > Octave. If this is a one-time code dump and it's up to us to maintain > this code in the future, I'm less inclined to accept it into Octave > core, since it's a relatively rare request. I have never heard of our > users clamouring for the Faddeeva function or its relatives. Certainly error function and complimentary error function find general use, but Faddeeva function seems like something particular to wave theory or Fourier analysis. Whether that belongs in the special functions category or a wave-theory (or similar) package, I don't know. This has an MIT license, correct? Is that compatible with GPL? From my brief browsing of the code, it does seem to be original and reference up-to-date papers on the algorithm and its limitations. It seems to me the first question is whether to replace erf/erfc in the core source with something that handles complex inputs. I'm not sure Faddeeva function on its own warrants core code. But there might be a better way to put Faddeeva function in a package, script code being one possibility if that turns out to not be too slow. Dan |
From: Michael D. G. <mic...@gm...> - 2012-11-20 22:54:23
|
Also keep in mind that this will need to be compatible with the Matlab complex erf(z). |
From: Steven G. J. <st...@al...> - 2012-11-21 16:40:10
|
On 11/20/12 5:54 PM, Michael D. Godfrey wrote: > Also keep in mind that this will need to be compatible with > the Matlab complex erf(z). The Matlab erf function does not support complex arguments: http://www.mathworks.com/help/matlab/ref/erf.html (There are several complex erf implementations in the Matlab Central repository.) However, any erf(z) for complex arguments will be compatible with my implementation because the extension to the complex plane is unique. (erf is an analytic function in the entire complex plane.) --SGJ |
From: Nir K. <nkr...@cc...> - 2012-11-21 01:43:43
|
Can the contributed functions be given names that don't conflict with the current Octave ones, like erf_complex? That way there should be no problem with putting them either in specfun or as their own Octave package. |
From: Daniel J S. <dan...@ie...> - 2012-11-21 02:01:24
|
On 11/20/2012 07:43 PM, Nir Krakauer wrote: > Can the contributed functions be given names that don't conflict with > the current Octave ones, like erf_complex? That way there should be no > problem with putting them either in specfun or as their own Octave > package. That's an alternative. Yet it might be desired to have complex error function family of functions: octave-cli:3> erfc(complex(1,pi)) error: erfc: not defined for complex scalar Will this code work for that? If Steven's code were released as a mini C library that could be accessed easily and had some compile switches to use internal square root, sinc, etc. functions or external, that might address Jordi's concern about maintaining the code. Dan |
From: Jordi G. H. <jo...@oc...> - 2012-10-25 14:00:07
|
On 24 October 2012 23:34, Steven G. Johnson <st...@al...> wrote: > Hi all, in case there is interest I wanted to let you know that I've > written a free complex-argument error function in C++ with an Octave > wrapper at: > > http://ab-initio.mit.edu/wiki/index.php/Faddeeva_w Thanks. This belongs in core Octave since that's where the current implementation of erf and friends is. I would need to modify your source to fit our style. Besides stylistic issues, there's also the issue that it should not be a dynamically loaded function, but built-in, so your wrapper needs to be rewritten. I am happy to do this myself. Do you have a DVCS somewhere, preferrably Mercurial, where we could keep your style on one branch and ours in another? Hopefully you plan to keep working on this function, so it's worthwhile to version your code. If you don't already have a repository set up, I would be most pleased to get you started with Mercurial. Do you recommend replacing the current implementation of erf for real arguments with your implementation? Currently for real arguments we rely on the C library's math.h implementation, and for complex arguments we error out. Thanks, - Jordi G. H. |
From: Steven G. J. <st...@al...> - 2012-10-27 17:17:32
|
Jordi Gutiérrez Hermoso wrote: > On 24 October 2012 23:34, Steven G. Johnson <st...@al...> wrote: >> Hi all, in case there is interest I wanted to let you know that I've >> written a free complex-argument error function in C++ with an Octave >> wrapper at: >> >> http://ab-initio.mit.edu/wiki/index.php/Faddeeva_w > > Thanks. This belongs in core Octave since that's where the current > implementation of erf and friends is. I would need to modify your > source to fit our style. Besides stylistic issues, there's also the > issue that it should not be a dynamically loaded function, but > built-in, so your wrapper needs to be rewritten. I am happy to do this > myself. Do you have a DVCS somewhere, preferrably Mercurial, where we > could keep your style on one branch and ours in another? Hopefully you > plan to keep working on this function, so it's worthwhile to version > your code. If you don't already have a repository set up, I would be > most pleased to get you started with Mercurial. I have a private git repository, but I can't make it public because it contains a couple of semi-free programs for performance and accuracy comparisons. It wouldn't be hard for me to check in my changes to a public Mercurial repository as well, however, if that is much easier for you than just grabbing the file from my web site periodically. I do plan to keep updating my code as needed (e.g. right now I am tweaking it to compute Re[w] more accurately in regions close to the real-z axis where Re[w] is small), so it would be nice if you could track my changes. > Do you recommend replacing the current implementation of erf for real > arguments with your implementation? Currently for real arguments we > rely on the C library's math.h implementation, and for complex > arguments we error out. Probably it is better to stick with the libc erf and erfc for real arguments. What my code computes is the scaled error function w(z), equivalent to erfcx(x) = exp(x^2) erfc(x) = w(ix) on the real axis. This means that my code has to work over a vastly greater domain, even on the real axis (where both erf and erfc are trivial except for small |x|), with a corresponding sacrifice of performance (a factor of 2-10 on my machine). You might use my code to provide an erfcx function even for real arguments, however. There are also a few other important special functions that can be computed from w(z), like the Voigt functions and Dawson's integral. --SGJ |