| … | |
… | |
| 32 | sub _PGcomplexmacros_init { |
32 | sub _PGcomplexmacros_init { |
| 33 | } |
33 | } |
| 34 | # export functions from Complex1. |
34 | # export functions from Complex1. |
| 35 | |
35 | |
| 36 | foreach my $f (@Complex1::EXPORT) { |
36 | foreach my $f (@Complex1::EXPORT) { |
| 37 | #PG_restricted_eval("\*$f = \*Complex1::$f"); # this is too clever -- |
37 | # #PG_restricted_eval("\*$f = \*Complex1::$f"); # this is too clever -- |
| 38 | # the original subroutines are destroyed |
38 | # the original subroutines are destroyed |
| 39 | next if $f eq 'sqrt'; #exporting the square root caused conflicts with the standard version |
39 | next if $f eq 'sqrt'; #exporting the square root caused conflicts with the standard version |
| 40 | # You can still use Complex1::sqrt to take square root of complex numbers |
40 | # You can still use Complex1::sqrt to take square root of complex numbers |
| 41 | next if $f eq 'log'; #exporting loq caused conflicts with the standard version |
41 | next if $f eq 'log'; #exporting loq caused conflicts with the standard version |
| 42 | # You can still use Complex1::log to take square root of complex numbers |
42 | # You can still use Complex1::log to take square root of complex numbers |
| … | |
… | |
| 47 | } |
47 | } |
| 48 | }; |
48 | }; |
| 49 | PG_restricted_eval($string); |
49 | PG_restricted_eval($string); |
| 50 | } |
50 | } |
| 51 | |
51 | |
|
|
52 | |
| 52 | # You need to add |
53 | # You need to add |
| 53 | # sub i(); # to your problem or else to dangerousMacros.pl |
54 | # sub i(); # to your problem or else to dangerousMacros.pl |
| 54 | # in order to use expressions such as 1 +3*i; |
55 | # in order to use expressions such as 1 +3*i; |
| 55 | # Without this prototype you would have to write 1+3*i(); |
56 | # Without this prototype you would have to write 1+3*i(); |
| 56 | # The prototype has to be defined at compile time, but dangerousMacros.pl is complied first. |
57 | # The prototype has to be defined at compile time, but dangerousMacros.pl is complied first. |
| 57 | #Complex1::display_format('cartesian'); |
58 | #Complex1::display_format('cartesian'); |
| 58 | |
59 | |
| 59 | # number format used frequently in strict prefilters |
60 | # number format used frequently in strict prefilters |
| 60 | my $number = '([+-]?)(?=\d|\.\d)\d*(\.\d*)?(E([+-]?\d+))?'; |
61 | my $number = '([+-]?)(?=\d|\.\d)\d*(\.\d*)?(E([+-]?\d+))?'; |
| 61 | |
|
|
| 62 | |
62 | |
| 63 | |
63 | |
| 64 | sub polar{ |
64 | sub polar{ |
| 65 | my $z = shift; |
65 | my $z = shift; |
| 66 | my %options = @_; |
66 | my %options = @_; |