Dev(3pm) | User Contributed Perl Documentation | Dev(3pm) |
PDL::VectorValued::Dev - development utilities for vector-valued PDLs
use PDL; use PDL::VectorValued::Dev; ##--------------------------------------------------------------------- ## ... stuff happens
PDL::VectorValued::Dev provides some developer utilities for vector-valued PDLs. It produces code for processing with PDL::PP.
Wrapper for pp_def() which calls vvpp_expand() on 'Code' and 'BadCode' values in %args.
Expand PDL::VectorValued macros in $vvpp_code. Currently known PDL::VectorValued macros include:
MACRO_NAME EXPANSION_SUBROUTINE ---------------------------------------------------------------------- $CMPVEC(...) vvpp_expand_cmpvec(...) $CMPVAL(...) vvpp_expand_cmpval(...) $LB(...) vvpp_expand_lb(...)
See the documentation of the individual expansion subroutines for details on calling conventions.
You can add your own expansion macros by pushing an expansion manipulating the array
@PDL::VectorValued::Dev::MACROS
which is just a list of expansion subroutines which take a single argument (string for Code or BadCode) and should return the expanded string.
Returns a signature type for representing PDL indices. For PDL >= v2.007 this should be "PDL_Indx", otherwise it will be "int".
Returns a C typedef for the "PDL_Indx" type if running under PDL <= v2.007, otherwise just a comment. You can call this from client PDL::PP modules as
pp_addhdr(PDL::VectorValued::Dev::vv_indx_typedef);
Gets basename of a PDL::PP variable by removing leading '$' and anything at or following the first open parenthesis:
$base = vvpp_pdlvar_basename('$a(n=>0)'); ##-- $base is now 'a'
Returns PDL::PP code for lexicographically comparing two vectors $vec1 and $vec2 along the dimension named $dim, storing the comparison result in the C variable $retvar, similar to what:
$retvar = ($vec1 <=> $vec2);
"ought to" do.
Parameters:
The PDL::PP code for cmpvec() looks something like this:
use PDL::VectorValued::Dev; pp_def('cmpvec', Pars => 'a(n); b(n); int [o]cmp()', Code => ( 'int cmpval;' .vvpp_cmpvec_code( '$a()', '$b()', 'n', 'cmpval' ) .$cmp() = cmpval' ); );
Returns PDL::PP expression code for lexicographically comparing two values $val1 and $val2, storing the comparison result in the C variable $retvar, similar to what:
($vec1 <=> $vec2);
"ought to" do.
Parameters:
Returns PDL::PP code for binary lower-bound search for the value $find() in the sorted pdl $vals($imin:$imax-1). Parameters:
Some additional low-level functions are provided in the PDL::Ngrams::Utils package. See PDL::Ngrams::Utils for details.
All of these functions would be more intuitive if implemented directly as PDL::PP macros, and thus expanded directly by pp_def() rather than requiring vvpp_def().
At the time of this module's writing, I was unable to figure out how to use the (then undocumented) PDL::PP macro expansion mechanism. As of 2022, PDL::PP offers support for user-defined macros, and this module should be refactored to take advantage of that... but that hasn't happened yet.
perl by Larry Wall.
Bryan Jurish <moocow@cpan.org>
PDL by Karl Glazebrook, Tuomas J. Lukka, Christian Soeller, and others.
Copyright (c) 2007-2022, Bryan Jurish. All rights reserved.
This package is free software. You may redistribute it and/or modify it under the same terms as Perl itself.
2022-10-20 | perl v5.36.0 |