Subject: | Inline::BC cannot access the math library |
I've attempted to use the math functions of the BC library which is
built during the "make" step of Inline::BC. Unfortunately they don't
appear to be accessible from Inline::BC and there doesn't seem to exist
an "Inline BC => Config" option to load these functions.
Would it be possible to implement a Config option, say MATHLIB, so that
BC's math library is then loaded? For example,
use Inline BC => "DATA"
MATHLIB => 1;
would now make the standard math functions accessible.
I've attached the Perl script that I've been using up to now. The output
from this script is shown below:
<-----------------------Information
Section----------------------------------->
Information about the processing of your Inline BC code:
Your source code needs to be compiled. I'll use this build directory:
/home/rong/dvlCorner/perlINL/_Inline/build/sinhcalc_pl_e17e
and I'll install the executable as:
/home/rong/dvlCorner/perlINL/_Inline/lib/auto/sinhcalc_pl_e17e/sinhcalc_pl_e17e.bc
<-----------------------End of Information
Section---------------------------->
Runtime error (func=bc_sinh, adr=11): Function e not defined.
N = 1 SINH =
Runtime error (func=bc_sinh, adr=11): Function e not defined.
N = 1.5 SINH =
Runtime error (func=bc_sinh, adr=11): Function e not defined.
N = 2 SINH =
Runtime error (func=bc_sinh, adr=11): Function e not defined.
N = 2.5 SINH =
...
The equivalent code in BC language executes just fine when using "bc -l".
Kind regards,
Ron.
Subject: | SINHCALC.PL |
#!/usr/local/bin/perl
#------------------------------------------------------------------------------
# PERL SCRIPT : sinhcalc.pl
# VERSION : 1.00.0
# AUTHOR : Ron Grunwald
# EMAIL : rongrw@yahoo.com.au
# DATE WRITTEN : Jan 14, 2009
#------------------------------------------------------------------------------
MainFunction: {
use strict;
use warnings;
use constant { MAIN_NAME => q{sinhcalc.pl},
BOOL_T => 1,
BOOL_F => 0,
ERR_FLAG => -1
};
use feature ":5.10";
use Inline BC => 'DATA',
PRINT_INFO => 1;
my ($n, $r);
for ($n = 1; $n < 6.0; $n += 0.5) {
$r = bc_sinh( $n );
say (" N = $n SINH = $r");
}
}
__DATA__
__BC__
/* Define the BC function sinh(u) */
define bc_sinh (u) {
scale = 12
t = (e(u) - e(-u)) * 0.5
return ( t )
}