help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: octave-forge: gsl oct files don't execute


From: Glen Henshaw
Subject: Re: octave-forge: gsl oct files don't execute
Date: Fri, 27 May 2005 14:27:14 -0400

I found and fixed my problem. The problem, as I suspected, was that the main/gsl/gsl_sf.cc file was being generated incorrectly. The fix comes from a NetBSD port patch available at

http://cvsweb.se.netbsd.org/index.cgi/pkgsrc/math/octave-forge/patches/patch-aa

The notes attached to the patch say:
"Use awk instead of csplit during the build.  csplit was only
used in one place and it generated a build dependency on a package
which conflicts with many other pkgs."

The patch is:

--- main/gsl/replace_template.sh.orig    2004-05-04 15:49:42.000000000 +0000
+++ main/gsl/replace_template.sh    2005-03-18 20:26:03.000000000 +0000
@@ -1,8 +1,11 @@
#!/bin/sh
-csplit -f tmp_gsl $1 /DEFUN/ /GSL_FUNC_DOCSTRING/ /./ > /dev/null
+awk '/DEFUN/ {exit} {print}' $1 > tmp_gsl00
+awk '/DEFUN/ {state=1} /GSL_FUNC_DOCSTRING/ {if(state==1){exit}} state==1{print}' $1 > tmp_gsl01
+awk '/DEFUN/ {state=1} /GSL_FUNC_DOCSTRING/ {if(state==1){print ; exit}}' $1 > tmp_gsl02
+awk 'state==2{print} /DEFUN/ {state=1} /GSL_FUNC_DOCSTRING/ {if(state==1){state=2}}' $1 > tmp_gsl03
cat tmp_gsl01 | sed "s/GSL_OCTAVE_NAME/$octave_name/g"
cat docstring.txt | sed 's/\\/\\\\/g' | sed 's/$/\\n\\/g'
cat tmp_gsl03 | sed "s/GSL_OCTAVE_NAME/$octave_name/g" | sed "s/GSL_FUNC_NAME/$funcname/g"
-rm -f tmp_gsl* docstring.txt
\ No newline at end of file
+rm -f tmp_gsl* docstring.txt



Applying it leads to a new main/gsl/replace_template.sh file:

#!/bin/sh

awk '/DEFUN/ {exit} {print}' $1 > tmp_gsl00
awk '/DEFUN/ {state=1} /GSL_FUNC_DOCSTRING/ {if(state==1){exit}} state==1{print}' $1 > tmp_gsl01
awk '/DEFUN/ {state=1} /GSL_FUNC_DOCSTRING/ {if(state==1){print ; exit}}' $1 > tmp_gsl02
awk 'state==2{print} /DEFUN/ {state=1} /GSL_FUNC_DOCSTRING/ {if(state==1){state=2}}' $1 > tmp_gsl03
cat tmp_gsl01 | sed "s/GSL_OCTAVE_NAME/$octave_name/g"
cat docstring.txt | sed 's/\\/\\\\/g' | sed 's/$/\\n\\/g'
cat tmp_gsl03 | sed "s/GSL_OCTAVE_NAME/$octave_name/g" | sed "s/GSL_FUNC_NAME/$funcname/g"

rm -f tmp_gsl* docstring.txt


The build now runs cleanly the first time through, the gsl_sf.cc file is much longer than it was before, and I can execute gsl functions from octave:

octave:1> help zeta
zeta is the dynamically-linked function from the file
/opt/local/libexec/octave/2.1.71/site/oct/powerpc-apple-darwin8.1.0/octave-forge/zeta.oct

function y = zeta (x)

These routines compute the Riemann zeta function \zeta(s) for
arbitrary s, s \ne 1.

The Riemann zeta function is defined by the infinite sum
\zeta(s) = \sum_{k=1}^\infty k^{-s}.

This function is from the GNU Scientific Library,
see http://www.gnu.org/software/gsl/ for documentation.


Additional help for built-in functions, operators, and variables
is available in the on-line version of the manual.  Use the command
`help -i <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
mailing list.
octave:2> zeta(2)
ans = 1.6449


Thanks for the help,
Glen






On May 26, 2005, at 5:42 PM, Marius Schamschula wrote:

Glen,

Are you sure octave-forge didn't complain? Any time I compile octave-forge under Mac OS X 103.x or 10.4.x the gsl compile fails first time through. I patch using the following patch

*** main/gsl/gsl_sf.cc.dist    Mon Nov 22 21:14:31 2004
--- main/gsl/gsl_sf.cc    Tue Nov 23 07:59:28 2004
***************
*** 27,31 ****
      error("GSL error %d at %s, line %d: %s\n", gsl_errno, file, line, reason);
  }
! The Clausen function is defined by the following integral,\n\
  \n\
  Cl_2(x) = - \\int_0^x dt \\log(2 \\sin(t/2))\n\
--- 27,31 ----
      error("GSL error %d at %s, line %d: %s\n", gsl_errno, file, line, reason);
  }
! /* The Clausen function is defined by the following integral,\n\
  \n\
  Cl_2(x) = - \\int_0^x dt \\log(2 \\sin(t/2))\n\
***************
*** 310,311 ****
--- 310,312 ----
  |x| <= 1. Theses routines avoid the overflows that occur for the\n\
  standard normalization of P_l^m(x).\n\
+ */
\ No newline at end of file

and the run make a second time. Then the gsl routines compile cleanly.

BTW: what compiler are you using?

On May 26, 2005, at 1:59 PM, Glen Henshaw wrote:


Hi all,

I just installed octave-forge-2004.11.16 from source on MacOSX 10.4 (Tiger). I have octave 2.1.70 installed using the darwinports port. octave-forge builds and installs without complaint.

In octave, I can execute any octave-forge .m file and many oct files ok, but when I try to execute certain oct files they don't appear to exist at all, e.g. zeta.oct shows up under help but if I try to execute it I get

octave:1> help zeta
help: sorry, `zeta' is not documented
octave:2> zeta
error: `zeta' undefined near line 9 column 1


Most, if not all, of these are part of the gsl package, which appeared to build and install correctly. However, the gsl_sf.cc file looks a little flaky, as there is very little in it:


#include <octave/oct.h>
#include <gsl/gsl_sf.h>
#include <gsl/gsl_sf_result.h>
#include <gsl/gsl_errno.h>

void octave_gsl_errorhandler (const char * reason, const char * file,
                              int line, int gsl_errno)
{
    error("GSL error %d at %s, line %d: %s\n", gsl_errno, file, line, reason);
}
/* The Clausen function is defined by the following integral,\n\
\n\
Cl_2(x) = - \\int_0^x dt \\log(2 \\sin(t/2))\n\
\n\
It is related to the dilogarithm by Cl_2(\\theta) = \\Im Li_2(\\exp(i \\theta)).\n\
The Dawson integral is defined by \\exp(-x^2) \\int_0^x dt \\exp(t^2).\n\
A table of Dawson's integral can be found in Abramowitz & Stegun, Table 7.5.\n\
The Debye functions are defined by the integral \n\
\n\
D_n(x) = n/x^n \\int_0^x dt (t^n/(e^t - 1)).\n\
\n\
For further information see Abramowitz & Stegun, Section 27.1.\n\
The Debye functions are defined by the integral\n\
\n\
D_n(x) = n/x^n \\int_0^x dt (t^n/(e^t - 1)).\n\
\n\
For further information see Abramowitz & Stegun, Section 27.1.\n\
The Debye functions are defined by the integral\n\
\n\
D_n(x) = n/x^n \\int_0^x dt (t^n/(e^t - 1)).\n\
\n\
For further information see Abramowitz & Stegun, Section 27.1.\n\
The Debye functions are defined by the integral\n\
\n\
D_n(x) = n/x^n \\int_0^x dt (t^n/(e^t - 1)).\n\
\n\
For further information see Abramowitz & Stegun, Section 27.1.\n\
These routines compute the error function \n\
erf(x) = (2/\\sqrt(\\pi)) \\int_0^x dt \\exp(-t^2).\n\
These routines compute the complementary error function \n\
erfc(x) = 1 - erf(x) = (2/\\sqrt(\\pi)) \\int_x^\\infty \\exp(-t^2).\n\
These routines compute the logarithm of the complementary error\n\
function \\log(\\erfc(x)).\n\
These routines compute the Gaussian probability function \n\
Z(x) = (1/(2\\pi)) \\exp(-x^2/2).\n\
These routines compute the upper tail of the Gaussian probability\n\
function  Q(x) = (1/(2\\pi)) \\int_x^\\infty dt \\exp(-t^2/2).\n\
The hazard function for the normal distrbution, also known as the \n\
inverse Mill's ratio, is defined as \n\
h(x) = Z(x)/Q(x) = \\sqrt{2/\\pi \\exp(-x^2 / 2) / \\erfc(x/\\sqrt 2)}. \n\
It decreases rapidly as x approaches -\\infty and asymptotes to \n\
h(x) \\sim x as x approaches +\\infty.\n\
These routines compute the quantity \\exp(x)-1 using an algorithm that \n\
is accurate for small x.\n\
These routines compute the quantity (\\exp(x)-1)/x using an algorithm \n\
that is accurate for small x. For small x the algorithm is based on \n\
the expansion (\\exp(x)-1)/x = 1 + x/2 + x^2/(2*3) + x^3/(2*3*4) + \\dots.\n\
These routines compute the quantity 2(\\exp(x)-1-x)/x^2 using an\n\
algorithm that is accurate for small x. For small x the algorithm is \n\
based on the expansion \n\
2(\\exp(x)-1-x)/x^2 = 1 + x/3 + x^2/(3*4) + x^3/(3*4*5) + \\dots.\n\
These routines compute the exponential integral E_1(x),\n\
\n\
E_1(x) := Re \\int_1^\\infty dt \\exp(-xt)/t.\n\
These routines compute the second-order exponential integral E_2(x),\n\
\n\
E_2(x) := \\Re \\int_1^\\infty dt \\exp(-xt)/t^2.\n\
These routines compute the exponential integral E_i(x),\n\
\n\
Ei(x) := - PV(\\int_{-x}^\\infty dt \\exp(-t)/t)\n\
\n\
where PV denotes the principal value of the integral.\n\
These routines compute the integral Shi(x) = \\int_0^x dt \\sinh(t)/t.\n\
These routines compute the integral \n\
\n\
Chi(x) := Re[ \\gamma_E + \\log(x) + \\int_0^x dt (\\cosh[t]-1)/t] , \n\
\n\
where \\gamma_E is the Euler constant.\n\
These routines compute the exponential integral \n\
Ei_3(x) = \\int_0^x dt \\exp(-t^3) for x >= 0.\n\
These routines compute the Sine integral Si(x) = \\int_0^x dt \\sin(t)/t.\n\
These routines compute the Cosine integral \n\
Ci(x) = -\\int_x^\\infty dt \\cos(t)/t for x > 0. \n\
These routines compute the Arctangent integral \n\
AtanInt(x) = \\int_0^x dt \\arctan(t)/t. \n\
These routines compute the complete Fermi-Dirac integral F_{-1/2}(x).\n\
These routines compute the complete Fermi-Dirac integral F_{1/2}(x).\n\
These routines compute the complete Fermi-Dirac integral F_{3/2}(x).\n\
These routines compute the Gamma function \\Gamma(x), subject to x not \n\
being a negative integer. The function is computed using the real \n\
Lanczos method. The maximum value of x such that \\Gamma(x) is not \n\
considered an overflow is given by the macro GSL_SF_GAMMA_XMAX and is 171.0.\n\
These routines compute the logarithm of the Gamma function, \n\
\\log(\\Gamma(x)), subject to x not a being negative integer. \n\
For x<0 the real part of \\log(\\Gamma(x)) is returned, which is \n\
equivalent to \\log(|\\Gamma(x)|). The function is computed using \n\
the real Lanczos method.\n\
These routines compute the regulated Gamma Function \\Gamma^*(x) \n\
for x > 0. The regulated gamma function is given by,\n\
\n\
\\Gamma^*(x) = \\Gamma(x)/(\\sqrt{2\\pi} x^{(x-1/2)} \\exp(-x))\n\
            = (1 + (1/12x) + ...)  for x \\to \\infty\n\
\n\
and is a useful suggestion of Temme. \n\
These routines compute the reciprocal of the gamma function, 1/\\Gamma(x) using the real Lanczos method.\n\
These compute the principal branch of the Lambert W function, W_0(x).\n\
\n\
Lambert's W functions, W(x), are defined to be solutions of the\n\
equation W(x) \\exp(W(x)) = x. This function has multiple branches \n\
for x < 0; however, it has only two real-valued branches. \n\
We define W_0(x) to be the principal branch, where W > -1 for x < 0, \n\
and W_{-1}(x) to be the other real branch, where W < -1 for x < 0.\n\
These compute the secondary real-valued branch of the Lambert \n\
W function, W_{-1}(x).\n\
\n\
Lambert's W functions, W(x), are defined to be solutions of the\n\
equation W(x) \\exp(W(x)) = x. This function has multiple branches \n\
for x < 0; however, it has only two real-valued branches. \n\
We define W_0(x) to be the principal branch, where W > -1 for x < 0, \n\
and W_{-1}(x) to be the other real branch, where W < -1 for x < 0.\n\
These routines compute \\log(1 + x) for x > -1 using an algorithm that\n\
is accurate for small x.\n\
These routines compute \\log(1 + x) - x for x > -1 using an algorithm \n\
that is accurate for small x.\n\
These routines compute the digamma function \\psi(x) for general x, \n\
x \\ne 0.\n\
These routines compute the real part of the digamma function on \n\
the line 1+i y, Re[\\psi(1 + i y)].\n\
These routines compute the first synchrotron function \n\
x \\int_x^\\infty dt K_{5/3}(t) for x >= 0.\n\
These routines compute the second synchrotron function \n\
x K_{2/3}(x) for x >= 0.\n\
These routines compute the transport function J(2,x).\n\
\n\
The transport functions J(n,x) are defined by the integral\n\
representations J(n,x) := \\int_0^x dt t^n e^t /(e^t - 1)^2.\n\
These routines compute the transport function J(3,x).\n\
\n\
The transport functions J(n,x) are defined by the integral\n\
representations J(n,x) := \\int_0^x dt t^n e^t /(e^t - 1)^2.\n\
These routines compute the transport function J(4,x).\n\
\n\
The transport functions J(n,x) are defined by the integral\n\
representations J(n,x) := \\int_0^x dt t^n e^t /(e^t - 1)^2.\n\
These routines compute the transport function J(5,x).\n\
\n\
The transport functions J(n,x) are defined by the integral\n\
representations J(n,x) := \\int_0^x dt t^n e^t /(e^t - 1)^2.\n\
These routines compute \\sinc(x) = \\sin(\\pi x) / (\\pi x) for any value of x.\n\
These routines compute \\log(\\sinh(x)) for x > 0.\n\
These routines compute \\log(\\cosh(x)) for any x.\n\
These routines compute the Riemann zeta function \\zeta(s) for \n\
arbitrary s, s \\ne 1.\n\
\n\
The Riemann zeta function is defined by the infinite sum \n\
\\zeta(s) = \\sum_{k=1}^\\infty k^{-s}. \n\
These routines compute the eta function \\eta(s) for arbitrary s.\n\
\n\
The eta function is defined by \\eta(s) = (1-2^{1-s}) \\zeta(s).\n\
These routines compute the regular cylindrical Bessel function of\n\
order n, J_n(x).\n\
These routines compute the irregular cylindrical Bessel function of \n\
order n, Y_n(x), for x>0.\n\
These routines compute the regular modified cylindrical Bessel\n\
function of order n, I_n(x).\n\
These routines compute the scaled regular modified cylindrical Bessel\n\
function of order n, \\exp(-|x|) I_n(x)\n\
These routines compute the irregular modified cylindrical Bessel\n\
function of order n, K_n(x), for x > 0.\n\
\n\
These routines compute the regular spherical Bessel function of \n\
order l, j_l(x), for l >= 0 and x >= 0.\n\
These routines compute the irregular spherical Bessel function of\n\
order l, y_l(x), for l >= 0.\n\
These routines compute the scaled regular modified spherical Bessel\n\
function of order l, \\exp(-|x|) i_l(x)\n\
These routines compute the scaled irregular modified spherical Bessel\n\
function of order l, \\exp(x) k_l(x), for x>0.\n\
These routines compute the N-relative exponential, which is the n-th\n\
generalization of the functions gsl_sf_exprel and gsl_sf_exprel2. The\n\
N-relative exponential is given by,\n\
\n\
exprel_N(x) = N!/x^N (\\exp(x) - \\sum_{k=0}^{N-1} x^k/k!)\n\
            = 1 + x/(N+1) + x^2/((N+1)(N+2)) + ...\n\
            = 1F1 (1,1+N,x)\n\
These routines compute the complete Fermi-Dirac integral with an\n\
integer index of j, F_j(x) = (1/\\Gamma(j+1)) \\int_0^\\infty dt (t^j\n\
/(\\exp(t-x)+1)).\n\
These routines compute the Taylor coefficient x^n / n! \n\
for x >= 0, n >= 0.\n\
These functions evaluate the Legendre polynomial P_l(x) for a specific\n\
value of l, x subject to l >= 0, |x| <= 1\n\
These routines compute the Legendre function Q_l(x) for x > -1, x != 1\n\
and l >= 0.\n\
These routines compute the polygamma function \\psi^{(m)}(x) \n\
for m >= 0, x > 0.\n\
These routines compute the regular cylindrical Bessel function of\n\
fractional order nu, J_\\nu(x).\n\
These routines compute the irregular cylindrical Bessel function of\n\
fractional order nu, Y_\\nu(x).\n\
These routines compute the regular modified Bessel function of\n\
fractional order nu, I_\\nu(x) for x>0, \\nu>0.\n\
These routines compute the scaled regular modified Bessel function of\n\
fractional order nu, \\exp(-|x|)I_\\nu(x) for x>0, \\nu>0.\n\
These routines compute the irregular modified Bessel function of\n\
fractional order nu, K_\\nu(x) for x>0, \\nu>0.\n\
These routines compute the logarithm of the irregular modified Bessel\n\
function of fractional order nu, \\ln(K_\\nu(x)) for x>0, \\nu>0.\n\
These routines compute the scaled irregular modified Bessel function\n\
of fractional order nu, \\exp(+|x|) K_\\nu(x) for x>0, \\nu>0.\n\
These routines exponentiate x and multiply by the factor y to return\n\
the product y \\exp(x).\n\
These routines compute the incomplete Fermi-Dirac integral with an\n\
index of zero, F_0(x,b) = \\ln(1 + e^{b-x}) - (b-x).\n\
These routines compute the Pochhammer symbol \n\
\n\
(a)_x := \\Gamma(a + x)/\\Gamma(a), \n\
\n\
subject to a and a+x not being negative integers. The Pochhammer\n\
symbol is also known as the Apell symbol.\n\
These routines compute the logarithm of the Pochhammer symbol,\n\
\\log((a)_x) = \\log(\\Gamma(a + x)/\\Gamma(a)) for a > 0, a+x > 0.\n\
These routines compute the relative Pochhammer symbol ((a,x) - 1)/x\n\
where (a,x) = (a)_x := \\Gamma(a + x)/\\Gamma(a).\n\
These routines compute the normalized incomplete Gamma Function \n\
Q(a,x) = 1/\\Gamma(a) \\int_x\\infty dt t^{a-1} \\exp(-t) for a > 0, x >= 0.\n\
These routines compute the complementary normalized incomplete Gamma\n\
Function P(a,x) = 1/\\Gamma(a) \\int_0^x dt t^{a-1} \\exp(-t) \n\
for a > 0, x >= 0.\n\
These functions compute the incomplete Gamma Function the\n\
normalization factor included in the previously defined functions:\n\
\\Gamma(a,x) = \\int_x\\infty dt t^{a-1} \\exp(-t) for a real and x >= 0.\n\
These routines compute the Beta Function, \n\
B(a,b) = \\Gamma(a)\\Gamma(b)/\\Gamma(a+b) for a > 0, b > 0.\n\
These routines compute the logarithm of the Beta Function,\n\
\\log(B(a,b)) for a > 0, b > 0.\n\
These routines compute the hypergeometric function 0F1(c,x).\n\
These routines compute the irregular Spherical Conical Function\n\
P^{1/2}_{-1/2 + i \\lambda}(x) for x > -1.\n\
These routines compute the regular Spherical Conical Function\n\
P^{-1/2}_{-1/2 + i \\lambda}(x) for x > -1.\n\
These routines compute the conical function P^0_{-1/2 + i \\lambda}(x)\n\
for x > -1.\n\
These routines compute the conical function P^1_{-1/2 + i \\lambda}(x)\n\
for x > -1.\n\
These routines compute the Hurwitz zeta function \\zeta(s,q) \n\
for s > 1, q > 0.\n\
These routines compute the Airy function Ai(x) with an accuracy\n\
specified by mode.\n\
These routines compute the Airy function Bi(x) with an accuracy\n\
specified by mode.\n\
These routines compute a scaled version of the Airy function \n\
S_A(x) Ai(x). For x>0 the scaling factor S_A(x) is \\exp(+(2/3) x^(3/2)), and\n\
is 1 for x<0.\n\
These routines compute a scaled version of the Airy function \n\
S_B(x) Bi(x). For x>0 the scaling factor S_B(x) is exp(-(2/3) x^(3/2)), and\n\
is 1 for x<0.\n\
These routines compute the Airy function derivative Ai'(x) with an\n\
accuracy specified by mode.\n\
These routines compute the Airy function derivative Bi'(x) with an\n\
accuracy specified by mode.\n\
These routines compute the derivative of the scaled Airy function\n\
S_A(x) Ai(x).\n\
These routines compute the derivative of the scaled Airy function\n\
S_B(x) Bi(x).\n\
These routines compute the complete elliptic integral K(k) to the\n\
accuracy specified by the mode variable mode.\n\
These routines compute the complete elliptic integral E(k) to the\n\
accuracy specified by the mode variable mode.\n\
These routines compute the location of the s-th zero of the Airy\n\
function Ai(x).\n\
These routines compute the location of the s-th zero of the Airy\n\
function Bi(x).\n\
These routines compute the location of the s-th zero of the Airy\n\
function derivative Ai'(x).\n\
These routines compute the location of the s-th zero of the Airy\n\
function derivative Bi'(x).\n\
These routines compute the location of the s-th positive zero of the\n\
Bessel function J_0(x).\n\
These routines compute the location of the s-th positive zero of the\n\
Bessel function J_1(x).\n\
These routines compute the Trigamma function \\psi'(n) for positive\n\
integer n.\n\
These routines compute the Riemann zeta function \\zeta(n) for \n\
integer n, n \\ne 1.\n\
These routines compute the eta function \\eta(n) for integer n.\n\
These routines compute the associated Legendre polynomial P_l^m(x) \n\
for m >= 0, l >= m, |x| <= 1.\n\
These routines compute the normalized associated Legendre polynomial\n\
$\\sqrt{(2l+1)/(4\\pi)} \\sqrt{(l-m)!/(l+m)!} P_l^m(x)$ suitable for use\n\
in spherical harmonics. The parameters must satisfy m >= 0, l >= m,\n\
|x| <= 1. Theses routines avoid the overflows that occur for the\n\
standard normalization of P_l^m(x).\n\
*/






I have gsl-1.6 installed, also via a darwinports port.

Does anyone have any idea?

Thanks,
Glen





Dr. Glen Henshaw
Attitude Control Systems Branch
Naval Center for Space Technology
U.S. Naval Research Laboratory


Marius
--
Marius Schamschula                               Webmaster

        The Huntsville Macintosh Users Group
                    www.hmug.org

webmaster at hmug dot org    marius at schamschula dot com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]