[root@dywang algebra]# diff -uN ../../../mod_tmp/algebra/parser.php parser.php --- ../../../mod_tmp/algebra/parser.php 2013-05-20 16:23:42.000000000 +0800 +++ parser.php 2014-10-07 12:03:10.903224854 +0800 @@ -1251,7 +1251,17 @@
// Check to see if there is an entry to map the function name to a PHP function if(array_key_exists($this->_value,self::$fnmap)) { $func=self::$fnmap[$this->_value]; - return $mult*$func($this->_arguments[0]->evaluate($params)); + $flag=0; + $value=$this->_arguments[0]->evaluate($params); + if ($func == "sec") {$func="cos"; $flag=1;} + elseif ($func == "cot") {$func="tan"; $flag=1;} + elseif ($func == "csc") {$func="sin"; $flag=1;} + elseif ($func == "acot") {$func="atan"; $value=1.0/$value;} + elseif ($func == "asec") {$func="atan"; $value=sqrt($value*$value-1.0);} + elseif ($func == "acsc") {$func="atan"; $value=1.0/sqrt($value*$value-1.0);} + $value=$mult*$func($value); + if ($flag==1) {return 1.0/$value;} + return $value; } // No map entry so the function name must already be a PHP function... else {
@@ -1281,11 +1291,20 @@ // Static class properties const NARGS=1; public static $fnmap = array ('ln' => 'log', - 'log' => 'log10' + 'log' => 'log10', + 'sec' => 'sec', + 'csc' => 'csc', + 'cot' => 'cot', + 'asec' => 'asec', + 'acot' => 'acot', + 'acsc' => 'acsc', ); public static $texmap = array('asin' => '\\sin^{-1}', 'acos' => '\\cos^{-1}', 'atan' => '\\tan^{-1}', + 'asec' => '\\sec^{-1}', + 'acsc' => '\\csc^{-1}', + 'acot' => '\\cot^{-1}', 'sqrt' => '\\sqrt' ); // List of functions requiring special brackets
@@ -1398,6 +1417,13 @@ 'sin', 'cos', 'tan', + 'sec', + 'csc', + 'cot', + 'abs', + 'asec', + 'acsc', + 'acot', 'asin', 'acos', 'atan'