| 1 | package Math::SymbolicX::NoSimplification; | ||
| 2 | |||
| 3 | 2 | ▶ | use 5.006; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | # We don't need exports | ||
| 8 | 2 | ▶ | use Math::Symbolic qw(); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | # But we might export ourselves | ||
| 11 | 2 | require Exporter; | |
| 12 | 2 | our @ISA = qw(Exporter); | |
| 13 | 2 | our %EXPORT_TAGS = ( 'all' => [ qw( | |
| 14 | dont_simplify | ||
| 15 | do_simplify | ||
| 16 | ) ] ); | ||
| 17 | 2 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |
| 18 | 2 | our @EXPORT = qw(); | |
| 19 | |||
| 20 | 2 | our $VERSION = '1.01'; | |
| 21 | |||
| 22 | # This is what we do instead of simplifying: Cloning | ||
| 23 | 2 | ▶ | sub _Minimum_Simplification_Sub { |
|
Subroutine
_Minimum_Simplification_Sub: called CC=1 SCAR=0.0
| |||
| 24 | # Minimum simplification method clones. | ||
| 25 | 2 | return $_[0]->new(); | |
| 26 | }; | ||
| 27 | |||
| 28 | # This is where we save the simplification routines for | ||
| 29 | # later reinstallation using 'do_simplify()' | ||
| 30 | sub _Simplification_Sub_Cache {} | ||
| 31 | { | ||
| 32 | # no warnings since we're redefining the simplify routine. | ||
| 33 | # It is sufficient to redefine the one in ::Operator since that | ||
| 34 | # is the only one that does anything but cloning. | ||
| 35 | 2 | ▶ | no warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 36 | 2 | *_Simplification_Sub_Cache = \&Math::Symbolic::Operator::simplify; | |
| 37 | } | ||
| 38 | |||
| 39 | # A call to this will replace the simplify() routine in M::S::Operator with | ||
| 40 | # one that just clones (see above) | ||
| 41 | 3 | ▶ | sub dont_simplify { |
|
Subroutine
dont_simplify: called CC=1 SCAR=0.0
Pod
documented
| |||
| 42 | 2 | ▶ | no warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 43 | 3 | *Math::Symbolic::Operator::simplify = | |
| 44 | \&Math::SymbolicX::NoSimplification::_Minimum_Simplification_Sub; | ||
| 45 | } | ||
| 46 | |||
| 47 | # A call to this routine will undo all the damage dont_simplify() may have | ||
| 48 | # done by restoring the simplification routine in M::S::Operator from the | ||
| 49 | # backup in this module's &Simplification_Sub_Cache. | ||
| 50 | 1 | ▶ | sub do_simplify { |
|
Subroutine
do_simplify: called CC=1 SCAR=0.0
Pod
documented
| |||
| 51 | 2 | ▶ | no warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 52 | 1 | *Math::Symbolic::Operator::simplify = \&Math::SymbolicX::NoSimplification::_Simplification_Sub_Cache; | |
| 53 | } | ||
| 54 | |||
| 55 | # By default, if you load this module, we don't simplify. | ||
| 56 | 2 | dont_simplify(); | |
| 57 | |||
| 58 | 2 | 1; | |
| 59 | __END__ | ||