I'm writing some new code to deal handle the new GSL SF Legendre functions (see https://sourceforge.net/p/pdl/bugs/407/ ). This is my first time really diving into PP.
The signature of the new function is: Signature: gsl_sf_legendre_array(double x(); double [o]y(n); char norm; int lmax; int csphase) To explain, gsl_sf_legendre_array returns the value at x of ALL the Legendre functions up to and including degree lmax, so the output piddle has higher dimensions than the input piddle. The Code section of my pp_def'd function works well, it compiles and produces good output when I run it. So I thought I could add a BadCode section. So I added HandleBad =>1, BadCode => <<'EOBC', int ell, em, index; if ( $ISBAD( x() ) ) { $SETBAD ( y() ); } else { <snip code that is the same as Code section> } EOBC The 'int ell…' line of that snippet is exactly the same as in the Code section, as is the contents of the 'else' block. The only difference then between the Code and BadCode sections is that I have added the "if( $ISBAD...) {… } else { }" lines, which looks almost exactly like the example in PP.pod's 'Handling bad values' section [after the bad-related macros have been described]. When I do that I get the compiler error: > Access Index not found: y, 0, n > On stack: > at ../../../../blib/lib/PDL/PP/PdlParObj.pm line 428. > PDL::PP::PdlParObj::do_indterm(PDL::PP::PdlParObj=HASH(0x7f96c92ff990), > "y", 0, HASH(0x7f96c9230ba8), ARRAY(0x7f96c935aa60)) called at > ../../../../blib/lib/PDL/PP/PdlParObj.pm line 364 > PDL::PP::PdlParObj::do_access(PDL::PP::PdlParObj=HASH(0x7f96c92ff990), > "", ARRAY(0x7f96c935aa60)) called at ../../../../blib/lib/PDL/PP/PDLCode.pm > line 757 > PDL::PP::BadAccess::get_str(PDL::PP::BadAccess=ARRAY(0x7f96c92fea18), > PDL::PP::Code=HASH(0x7f96c929a978), ARRAY(0x7f96c935aa60)) called at > ../../../../blib/lib/PDL/PP/PDLCode.pm line 226 > PDL::PP::Block::get_str_int(PDL::PP::Block=ARRAY(0x7f96c8971e68), > PDL::PP::Code=HASH(0x7f96c929a978), ARRAY(0x7f96c935aa60)) called at > ../../../../blib/lib/PDL/PP/PDLCode.pm line 212 > PDL::PP::Block::get_str(PDL::PP::Block=ARRAY(0x7f96c8971e68), > PDL::PP::Code=HASH(0x7f96c929a978), ARRAY(0x7f96c935aa60)) called at > ../../../../blib/lib/PDL/PP/PDLCode.pm line 226 > > PDL::PP::Block::get_str_int(PDL::PP::ComplexThreadLoop=ARRAY(0x7f96c8972108), > PDL::PP::Code=HASH(0x7f96c929a978), ARRAY(0x7f96c935aa60)) called at > ../../../../blib/lib/PDL/PP/PDLCode.pm line 212 > > PDL::PP::Block::get_str(PDL::PP::ComplexThreadLoop=ARRAY(0x7f96c8972108), > PDL::PP::Code=HASH(0x7f96c929a978), ARRAY(0x7f96c935aa60)) called at > ../../../../blib/lib/PDL/PP/PDLCode.pm line 255 > PDL::PP::BadSwitch::get_str(PDL::PP::BadSwitch=ARRAY(0x7f96c9299d18), > PDL::PP::Code=HASH(0x7f96c929a978), ARRAY(0x7f96c935aa60)) called at > ../../../../blib/lib/PDL/PP/PDLCode.pm line 226 > PDL::PP::Block::get_str_int(PDL::PP::GenericLoop=ARRAY(0x7f96c935aa18), > PDL::PP::Code=HASH(0x7f96c929a978), ARRAY(0x7f96c935aa60)) called at > ../../../../blib/lib/PDL/PP/PDLCode.pm line 212 > PDL::PP::Block::get_str(PDL::PP::GenericLoop=ARRAY(0x7f96c935aa18), > PDL::PP::Code=HASH(0x7f96c929a978), ARRAY(0x7f96c935aa60)) called at > ../../../../blib/lib/PDL/PP/PDLCode.pm line 168 > PDL::PP::Code::new("PDL::PP::Code", " int ell, em, > index;\x{a}\x{9} switch (\$COMP(norm)){\x{a}\x{9} "..., "\x{9} int ell, > em, index;\x{a}\x{9} if ( \$ISBAD( x() ) ) {\x{a}\x{9} \$S"..., > ARRAY(0x7f96c9299d00), HASH(0x7f96c929a948), > PDL::PP::PdlDimsObj=HASH(0x7f96c935a598), ARRAY(0x7f96c882c508), > HASH(0x7f96c947e030), 1, ...) called at ../../../../blib/lib/PDL/PP.pm line > 3270 > PDL::PP::__ANON__(" int ell, em, index;\x{a}\x{9} switch > (\$COMP(norm)){\x{a}\x{9} "..., "\x{9} int ell, em, index;\x{a}\x{9} if > ( \$ISBAD( x() ) ) {\x{a}\x{9} \$S"..., ARRAY(0x7f96c9299d00), > HASH(0x7f96c929a948), PDL::PP::PdlDimsObj=HASH(0x7f96c935a598), > ARRAY(0x7f96c882c508), HASH(0x7f96c947e030), 1, "gsl_sf_legendre_array", ...) > called at ../../../../blib/lib/PDL/PP.pm line 323 > PDL::PP::Rule::apply(PDL::PP::Rule=HASH(0x7f96c94bf1d0), > HASH(0x7f96c91cd418)) called at ../../../../blib/lib/PDL/PP.pm line 3565 > PDL::PP::translate(HASH(0x7f96c91cd418), ARRAY(0x7f96c94c89c8)) called > at ../../../../blib/lib/PDL/PP.pm line 1133 > PDL::PP::pp_def("gsl_sf_legendre_array", "GenericTypes", > ARRAY(0x7f96c882c508), "OtherPars", "char norm; int lmax; int csphase", > "Pars", "double x(); double [o]y(n);", "RedoDimsCode", > "\$SIZE(n)=gsl_sf_legendre_array_n(\$COMP(lmax));", ...) called at > gsl_sf_legendre.pd line 76 > which is not super helpful. Can somebody spot the error I'm making? I've compared to BadCode sections elsewhere in the PDL source but haven't seen anything that's too different from what I'm trying to do. thanks, Derek ------------------------------------------------------------------------------ Find and fix application performance issues faster with Applications Manager Applications Manager provides deep performance insights into multiple tiers of your business applications. It resolves application problems quickly and reduces your MTTR. Get your free trial! https://ad.doubleclick.net/ddm/clk/302982198;130105516;z _______________________________________________ pdl-devel mailing list pdl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pdl-devel