[system] / trunk / pg / macros / PGcommonFunctions.pl Repository:
ViewVC logotype

Annotation of /trunk/pg/macros/PGcommonFunctions.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2602 - (view) (download) (as text)

1 : dpvc 2576 ##############################################
2 :     #
3 :     # Implements functions that are common to
4 :     # the new Parser.pm and the old PGauxiliaryFunctions.pl
5 :     #
6 :    
7 : dpvc 2602 sub _PGcommonFunctions_init {}
8 : dpvc 2576
9 :     #
10 :     # Make these interact nicely with Parser.pm
11 :     #
12 :     package CommonFunction;
13 :    
14 :     #
15 :     # Either call Parser (if it has been loaded) or
16 :     # the functions below. (If it's ever the case
17 :     # that both the Parser and PGauxiliaryFunctions.pl are
18 :     # both preloaded, then there will be no need for
19 :     # this, as you can always use the Parser versions.
20 :     # We only need this because Parser might not be loaded.)
21 :     #
22 :    
23 :     sub Call {
24 :     my $self = shift;
25 :     my $fn = shift;
26 : dpvc 2602 if ($main::_parser_loaded) {return Parser::Function->call($fn,@_)}
27 : dpvc 2576 return $self->$fn(@_);
28 :     }
29 :    
30 :     sub log {CORE::log($_[1])}
31 :     sub ln {CORE::log($_[1])}
32 :     sub logten {CORE::log($_[1])/CORE::log(10)}
33 :    
34 :     sub tan {CORE::sin($_[1])/CORE::cos($_[1])}
35 :     sub cot {CORE::cos($_[1])/CORE::sin($_[1])}
36 :     sub sec {1/CORE::cos($_[1])}
37 :     sub csc {1/CORE::sin($_[1])}
38 :    
39 :     sub asin {CORE::atan2($_[1],CORE::sqrt(1-$_[1]*$_[1]))}
40 :     sub acos {CORE::atan2(CORE::sqrt(1-$_[1]*$_[1]),$_[1])}
41 :     sub atan {CORE::atan2($_[1],1)}
42 :     sub acot {CORE::atan2(1,$_[1])}
43 :     sub asec {acos(1.0/$_[1])}
44 :     sub acsc {asin(1.0/$_[1])}
45 :    
46 :     sub sinh {(CORE::exp($_[1])-CORE::exp(-$_[1]))/2}
47 :     sub cosh {(CORE::CORE::exp($_[1])+CORE::CORE::exp(-$_[1]))/2}
48 :     sub tanh {(CORE::exp($_[1])-CORE::exp(-$_[1]))/(CORE::exp($_[1])+CORE::exp(-$_[1]))}
49 :     sub sech {2/(CORE::exp($_[1])+CORE::exp(-$_[1]))}
50 :     sub csch {2.0/(CORE::exp($_[1])-CORE::exp(-$_[1]))}
51 :     sub coth {(CORE::exp($_[1])+CORE::exp(-$_[1]))/(CORE::exp($_[1])-CORE::exp(-$_[1]))}
52 :    
53 :     sub asinh {CORE::log($_[1]+CORE::sqrt($_[1]*$_[1]+1.0))}
54 :     sub acosh {CORE::log($_[1]+CORE::sqrt($_[1]*$_[1]-1.0))}
55 :     sub atanh {CORE::log((1.0+$_[1])/(1.0-$_[1]))/2.0}
56 :     sub asech {CORE::log((1.0+CORE::sqrt(1-$_[1]*$_[1]))/$_[1])}
57 :     sub acsch {CORE::log((1.0+CORE::sqrt(1+$_[1]*$_[1]))/$_[1])}
58 :     sub acoth {CORE::log(($_[1]+1.0)/($_[1]-1.0))/2.0}
59 :    
60 :     sub sgn {$_[1] <=> 0}
61 :    
62 :     #
63 :     # Back to main package
64 :     #
65 :     package main;
66 :    
67 :     #
68 :     # Make main versions call the checker to see
69 :     # which package-specific version to call
70 :     #
71 :    
72 :     sub ln {CommonFunction->Call('log',@_)}
73 :     sub logten {CommonFunction->Call('logten',@_)}
74 :    
75 :     sub tan {CommonFunction->Call('tan',@_)}
76 :     sub cot {CommonFunction->Call('cot',@_)}
77 :     sub sec {CommonFunction->Call('sec',@_)}
78 :     sub csc {CommonFunction->Call('csc',@_)}
79 :    
80 :     sub arcsin {CommonFunction->Call('asin',@_)}; sub asin {CommonFunction->Call('asin',@_)}
81 :     sub arccos {CommonFunction->Call('acos',@_)}; sub acos {CommonFunction->Call('acos',@_)}
82 :     sub arctan {CommonFunction->Call('atan',@_)}; sub atan {CommonFunction->Call('atan',@_)}
83 :     sub arccot {CommonFunction->Call('acot',@_)}; sub acot {CommonFunction->Call('acot',@_)}
84 :     sub arcsec {CommonFunction->Call('asec',@_)}; sub asec {CommonFunction->Call('asec',@_)}
85 :     sub arccsc {CommonFunction->Call('acsc',@_)}; sub acsc {CommonFunction->Call('acsc',@_)}
86 :    
87 :     sub sinh {CommonFunction->Call('sinh',@_)}
88 :     sub cosh {CommonFunction->Call('cosh',@_)}
89 :     sub tanh {CommonFunction->Call('tanh',@_)}
90 :     sub sech {CommonFunction->Call('sech',@_)}
91 :     sub csch {CommonFunction->Call('csch',@_)}
92 :     sub coth {CommonFunction->Call('coth',@_)}
93 :    
94 :     sub arcsinh {CommonFunction->Call('asinh',@_)}; sub asinh {CommonFunction->Call('asinh',@_)}
95 :     sub arccosh {CommonFunction->Call('acosh',@_)}; sub acosh {CommonFunction->Call('acosh',@_)}
96 :     sub arctanh {CommonFunction->Call('atanh',@_)}; sub atanh {CommonFunction->Call('atanh',@_)}
97 :     sub arcsech {CommonFunction->Call('asech',@_)}; sub asech {CommonFunction->Call('asech',@_)}
98 :     sub arccsch {CommonFunction->Call('acsch',@_)}; sub acsch {CommonFunction->Call('acsch',@_)}
99 :     sub arccoth {CommonFunction->Call('acoth',@_)}; sub acoth {CommonFunction->Call('acoth',@_)}
100 :    
101 :     sub sgn {CommonFunction->Call('sgn',@_)}
102 :    
103 :     1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9