Math::Symbolic::Custom::Transformation

Transform Math::Symbolic trees
Download

Math::Symbolic::Custom::Transformation Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Steffen Muller
  • Publisher web site:
  • http://search.cpan.org/~smueller/

Math::Symbolic::Custom::Transformation Tags


Math::Symbolic::Custom::Transformation Description

Transform Math::Symbolic trees Math::Symbolic::Custom::Transformation is a Perl extension to the Math::Symbolic module. You're assumed to be remotely familiar with that module throughout the documentation.This package implements transformations of Math::Symbolic trees using Math::Symbolic trees. I'll try to explain what this means in the following paragraphs.Until now, in order to be able to inspect a Math::Symbolic tree, one had to use the low-level Math::Symbolic interface like comparing the top node's term type with a constant (such as T_OPERATOR) and then its operator type with more constants. This has changed with the release of Math::Symbolic::Custom::Pattern.To modify the tree, you had to use equally low-level or even encapsulation-breaking methods. This is meant to be changed by this distribution.SYNOPSIS use Math::Symbolic::Custom::Transformation; my $trafo = Math::Symbolic::Custom::Transformation->new( 'TREE_x + TREE_x' => '2 * TREE_x' ); my $modified = $trafo->apply($math_symbolic_tree); if (defined $modified) { print "Outermost operator is a sum of two identical trees. "; print "Transformed it into a product. ($modified) "; } else { print "Transformation could not be applied. "; } # shortcut: new_trafo use Math::Symbolic::Custom::Transformation qw/new_trafo/; # use the value() function to have the transformation compute the value # of the expression after the replacements. simplify{} works similar. my $another_trafo = new_trafo( 'TREE_foo / CONST_bar' => 'value{1/CONST_bar} * TREE_foo' ); # If you'll need the same transformation but don't want to keep it around in # an object, just do this: use Memoize; memoize('new_trafo'); # Then, passing the same transformation strings will result in a speedup of # about a factor 130 (on my machine) as compared to complete recreation # from strings. This is only 20% slower than using an existing # transformation. Requirements: · Perl


Math::Symbolic::Custom::Transformation Related Software