Example #1
0
 public function calculate($data)
 {
     $this->data = $data;
     $result = tanh($this->sum() * $this->beta * $this->betaWeight);
     //        $result = tanh($this->sum() * $this->beta * $this->betaWeight);
     return $result;
 }
Example #2
0
 function nicko(&$irc, &$data)
 {
     $args = array_slice($data->messageex, 1);
     $nick = $args[0];
     if (strlen($nick) > 0) {
         $this->score = $shifts = 0;
         $special_cost = array('69' => 500, 'dea?th' => 500, 'dark' => 400, 'n[i1]ght' => 300, 'n[i1]te' => 500, 'f**k' => 500, 'sh[i1]t' => 500, 'coo[l1]' => 500, 'kew[l1]' => 500, 'lame' => 500, 'dood' => 500, 'dude' => 500, '[l1](oo?|u)[sz]er' => 500, '[l1]eet' => 500, 'e[l1]ite' => 500, '[l1]ord' => 500, 'pron' => 1000, 'warez' => 1000, 'xx' => 100, '\\[rkx]0' => 1000, '\\0[rkx]' => 1000);
         foreach ($special_cost as $special => $cost) {
             $special_pattern = $special;
             if (ereg($special, $nick)) {
                 $this->punish($cost, "special");
             }
         }
         $clean = eregi_replace("[^A-Z0-9]", "", $nick);
         $this->punish(pow(10, strlen($nick) - strlen($clean)) - 1, "non-alha ({$clean} vs {$nick})");
         $k3wlt0k_weights = array(5, 5, 2, 5, 2, 3, 1, 2, 2, 2);
         for ($digit = 0; $digit < 10; $digit++) {
             $this->punish($k3wlt0k_weights[$digit] * substr_count($nick, $digit), "leet digits");
         }
         $this->punish($this->slow_pow(9, similar_text($nick, strtoupper($nick))) - 1, "lowercase");
         if (ereg("^.*[XZ]\$", $nick)) {
             $this->punish(50, "lame endings");
         }
         if (eregi("[0-9][a-z]", $nick, $regs)) {
             $shifts = @sizeof($regs) - 1;
             unset($regs);
         }
         if (eregi("[a-z][0-9]", $nick, $regs)) {
             $shifts = @sizeof($regs) - 1;
             unset($regs);
         }
         $this->punish($this->slow_pow(9, $shifts) - 1, "shifts");
         if (ereg("[A-Z]", $nick, $regs)) {
             $caps = @sizeof($regs) - 1;
             unset($regs);
             $this->punish($this->slow_pow(7, $caps), "upper case");
         }
         $percentage = 100 * (1 + tanh(($this->score - 400) / 400)) * (1 - 1 / (1 + $this->score / 5)) / 2;
         $digits = 2 * (2 - floor(log(100 - $percentage) / log(10)));
         $out = "'{$nick}' is " . sprintf("%." . $digits . "f", $percentage) . "% lame";
     } else {
         $out = "'" . $data['nick'] . "' is 100% lame";
     }
     $this->talk($irc, $data, $out);
     $this->log($irc, $data, $out);
 }
Example #3
0
 function activation()
 {
     //calculate the outputs of the hidden neurons, the hidden neurons are tanh
     for ($i = 0; $i < $this->numHidden; $i++) {
         $hidVal =& $this->hiddenVal[$i];
         $hidVal = 0.0;
         for ($j = 0; $j < $this->numInputs; $j++) {
             $hidVal = $hidVal + $this->trainInput[$this->patNum][$j] * $this->weightsIH[$j][$i];
         }
         $hidVal = tanh($hidVal);
     }
     //calculate the output of the network, the output neuron is linear
     $this->outPred = 0.0;
     for ($i = 0; $i < $this->numHidden; $i++) {
         $this->outPred = $this->outPred + $this->hiddenVal[$i] * $this->weightsHO[$i];
     }
     //calculate the error
     $this->errThisPat = $this->outPred - $this->trainOutput[$this->patNum];
 }
 /**
  * Returns the hyperbolic tangent of an angle.
  *
  * @param  number $angle
  * @return number
  */
 public function tanh($angle)
 {
     return tanh($angle);
 }
Example #5
0
 /**
  * Hyperbolic tangent.
  * @link http://php.net/manual/en/function.tanh.php
  * @param float $number <p>The argument to process</p>
  * @return float The hyperbolic tangent of <i>number</i>
  */
 public static function tanh($number)
 {
     return tanh($number);
 }
 /**
  * @param float $x A number
  * @return float The hyperbolic tangent of the given value
  */
 public function tanh($x)
 {
     return tanh($x);
 }
Example #7
0
<?php

define("MAX_64Bit", 9223372036854775807);
define("MAX_32Bit", 2147483647);
define("MIN_64Bit", -9223372036854775807 - 1);
define("MIN_32Bit", -2147483647 - 1);
$longVals = array(MAX_64Bit, MIN_64Bit, MAX_32Bit, MIN_32Bit, MAX_64Bit - MAX_32Bit, MIN_64Bit - MIN_32Bit, MAX_32Bit + 1, MIN_32Bit - 1, MAX_32Bit * 2, MAX_32Bit * 2 + 1, MAX_32Bit * 2 - 1, MAX_64Bit - 1, MAX_64Bit + 1, MIN_64Bit + 1, MIN_64Bit - 1);
foreach ($longVals as $longVal) {
    echo "--- testing: {$longVal} ---\n";
    var_dump(tanh($longVal));
}
?>
===DONE===
Example #8
0
echo rtrim("\t\tThese are a few words :) ... ");
echo rtrim("\t\tThese are a few words :) ... ", " \t.");
echo rtrim("\tExample string\n", "..");
echo chop("\t\tThese are a few words :) ... ");
echo chop("\t\tThese are a few words :) ... ", " \t.");
echo chop("\tExample string\n", "..");
echo acos(0.5);
echo acosh(0.5);
echo asin(0.5);
echo asinh(0.5);
echo atan(0.5);
echo atan2(0.5, 0.5);
echo atanh(0.5);
echo cos(0.5);
echo cosh(0.5);
echo sin(0.5);
echo sinh(0.5);
echo tan(0.5);
echo tanh(0.5);
echo exp(5.7);
echo exp(12);
echo log10(12);
echo log(12);
echo sqrt(2);
echo ceil(7.9);
echo floor(7.9);
echo fmod(5.7, 1.3);
echo ip2long("127.0.0.1");
echo long2ip(pow(2, 32) + 1024);
echo rad2deg(M_PI_4);
echo deg2rad(45);
Example #9
0
 public static function tanh($self, $a)
 {
     return tanh($a);
 }
Example #10
0
 /**
  * 
  * Get the compatibility by weight. Based on euclidean distance ...
  * @param array $searchee 
  * @param array $candidate
  * @param int $type
  */
 function getCompatibilityByWeight($searchee = array(), $candidate = array(), $type = 1)
 {
     $commonItems = 0;
     $sim = 0;
     foreach ($searchee["MemberAttributeWeight"] as $weight_searchee) {
         foreach ($candidate["MemberAttributeWeight"] as $weight_candidate) {
             if ($weight_searchee["attribute_id"] == $weight_candidate["attribute_id"]) {
                 $attribute = $this->controller->Attribute->find("first", array("conditions" => array("Attribute.id" => $weight_candidate["attribute_id"])));
                 //if ($attribute["attribute_type_id"]==$type){
                 $commonItems++;
                 $weight1 = $weight_searchee["weight"];
                 $weight2 = $weight_candidate["weight"];
                 $sim += pow($weight1 - $weight2, 2);
                 //}
             }
         }
     }
     if ($commonItems > 0) {
         $sim = sqrt($sim / $commonItems);
         $sim = 1 - tanh($sim);
         $maxItems = min(count($searchee["MemberAttributeWeight"]), count($candidate["MemberAttributeWeight"]));
         $sim = $sim * ($commonItems / $maxItems);
     }
     return $sim;
 }
/**
 * Calculate TANH, within bounds.
 * 
 * @param
 *        	double d The value to calculate for.
 * @return double The result.
 */
function tanh($d)
{
    return \Encog\MathUtil\BoundNumbers\bound(\tanh($d));
}
 /**
  * {@inheritdoc}
  */
 public function tanh($angle)
 {
     return $this->withPrecision(tanh($angle));
 }
 protected function processCoth()
 {
     $operands = $this->getOperands();
     $operand = $operands[0];
     if ($operand->getValue() == 0) {
         return null;
     } else {
         if (is_infinite($operand->getValue())) {
             return new Float(0.0);
         }
     }
     return new Float(1 / tanh($operand->getValue()));
 }
Example #14
0
<?php

/* 
 * proto float tanh(float number)
 * Function is implemented in ext/standard/math.c
*/
$arg_0 = 1.0;
$extra_arg = 1;
echo "\nToo many arguments\n";
var_dump(tanh($arg_0, $extra_arg));
echo "\nToo few arguments\n";
var_dump(tanh());
 /**
  * Calculates the hyperbolic cotangent of the parameter
  * 
  * @param float $x
  * @returns mixed A floating point on success, PEAR_Error object otherwise
  * @access public
  */
 function coth($x)
 {
     /*{{{*/
     $x = floatval($x);
     $tanh = tanh($x);
     if ($tanh == 0.0) {
         return PEAR::raiseError('Undefined operation, hyperbolic tangent of parameter is zero');
     } else {
         return 1 / $tanh;
     }
 }
Example #16
0
 /**
  * This method returns the hyperbolic tangent of this object's value.
  *
  * @access public
  * @static
  * @param IReal\Type $x                                     the operand
  * @return IDouble\Type                                     the result
  */
 public static function tanh(IReal\Type $x) : IDouble\Type
 {
     return IDouble\Type::box(tanh($x->unbox()));
 }
Example #17
0
<?php

if ($_GET['map'] == 'y') {
    $url = "http://sat0" . rand(1, 4) . ".maps.yandex.net/tiles?l=sat&x=" . $_GET['x'] . "&y=" . $_GET['y'] . "&z=" . $_GET['z'] . "&g=" . substr("Gagarin", 0, rand(1, 8));
    $url = "https://khms0.google.com/kh/v=184&src=app&x=" . $_GET['x'] . "&y=" . $_GET['y'] . "&z=" . $_GET['z'] . "&s=" . substr("Galileo", 0, rand(1, 8));
    //echo "<a href='".$url."' target='_blank'>".$url."</a><br>";
    //$exec='echo '.$_GET['x'].' '.$_GET['y'].' |cs2cs +proj=merc +ellps=WGS84 +to +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6356752 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs';
    //echo '<br>';
    //$lonlat = explode("	", exec($exec));
    //print_r($lonlat);
    //echo exec($exec);
    /*echo '<br>';
    		echo $exec;*/
    //$url = "http://sat0".rand(1, 4).".maps.yandex.net/tiles?l=sat&x=".round($lonlat[0])."&y=".round($lonlat[1])."&z=".$_GET['z']."&g=".substr("Gagarin", 0, rand(1, 8));
    $xtile = $_GET['x'] / 111319.49079327358;
    $ytile = rad2deg(asin(tanh($_GET['y'] / 20037508.342789244 * pi)));
    echo $xtile . '<br>';
    echo $ytile . '<br>';
    $url = "http://sat0" . rand(1, 4) . ".maps.yandex.net/tiles?l=sat&x=" . round($lonlat[0]) . "&y=" . round($lonlat[1]) . "&z=" . $_GET['z'] . "&g=" . substr("Gagarin", 0, rand(1, 8));
    //echo "<a href='".$url."' target='_blank'>".$url."</a><br>";
} else {
    $url = "http://khms" . rand(1, 3) . ".google.com/kh/v=184&src=app&x=" . $_GET['x'] . "&y=" . $_GET['y'] . "&z=" . $_GET['z'] . "&s=" . substr("Galileo", 0, rand(1, 8));
}
if ($_GET['map'] != 'y') {
    header('Content-Type: image/jpeg');
    //header('Content-Length: ' . filesize($file));
    //echo $url;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
function lambert93ToWgs84($x, $y)
{
    $x = number_format($x, 10, '.', '');
    $y = number_format($y, 10, '.', '');
    $b6 = 6378137.0;
    $b7 = 298.257222101;
    $b8 = 1 / $b7;
    $b9 = 2 * $b8 - $b8 * $b8;
    $b10 = sqrt($b9);
    $b13 = 3.0;
    $b14 = 700000.0;
    $b15 = 12655612.0499;
    $b16 = 0.725607765053267;
    $b17 = 11754255.426096;
    $delx = $x - $b14;
    $dely = $y - $b15;
    $gamma = atan(-$delx / $dely);
    $r = sqrt($delx * $delx + $dely * $dely);
    $latiso = log($b17 / $r) / $b16;
    $sinphiit0 = tanh($latiso + $b10 * atanh($b10 * sin(1)));
    $sinphiit1 = tanh($latiso + $b10 * atanh($b10 * $sinphiit0));
    $sinphiit2 = tanh($latiso + $b10 * atanh($b10 * $sinphiit1));
    $sinphiit3 = tanh($latiso + $b10 * atanh($b10 * $sinphiit2));
    $sinphiit4 = tanh($latiso + $b10 * atanh($b10 * $sinphiit3));
    $sinphiit5 = tanh($latiso + $b10 * atanh($b10 * $sinphiit4));
    $sinphiit6 = tanh($latiso + $b10 * atanh($b10 * $sinphiit5));
    $longrad = $gamma / $b16 + $b13 / 180 * pi();
    $latrad = asin($sinphiit6);
    $long = $longrad / pi() * 180;
    $lat = $latrad / pi() * 180;
    return array('y84' => $lat, 'x84' => $long);
}
Example #19
0
 /**
  * Tangente hiperbólica
  * @return Number
  */
 public function tanh()
 {
     $this->num = tanh($this->num);
     return $this;
 }
Example #20
0
*/
$file_path = dirname(__FILE__);
require $file_path . "/allowed_rounding_error.inc";
echo "tanh .5  = ";
var_dump(tanh(0.5));
if (allowed_rounding_error(tanh(0.5), 0.46211715726001)) {
    echo "Pass\n";
} else {
    echo "Fail\n";
}
echo "tanh -0.5  = ";
var_dump(tanh(-0.5));
if (allowed_rounding_error(tanh(-0.5), -0.46211715726001)) {
    echo "Pass\n";
} else {
    echo "Fail\n";
}
echo "tanh 3  = ";
var_dump(tanh(3.0));
if (allowed_rounding_error(tanh(3.0), 0.99505475368673)) {
    echo "Pass\n";
} else {
    echo "Fail\n";
}
echo "tanh -3  = ";
var_dump(tanh(-3.0));
if (allowed_rounding_error(tanh(-3.0), -0.99505475368673)) {
    echo "Pass\n";
} else {
    echo "Fail\n";
}
Example #21
0
 /**
  * Evaluate a FunctionNode
  *
  * Computes the value of a FunctionNode `f(x)`, where f is
  * an elementary function recognized by StdMathLexer and StdMathParser.
  *
  * @see \MathParser\Lexer\StdMathLexer StdMathLexer
  * @see \MathParser\StdMathParser StdMathParser
  * @throws UnknownFunctionException if the function respresented by the
  *      FunctionNode is *not* recognized.
  *
  * @param FunctionNode $node AST to be evaluated
  * @retval float
  */
 public function visitFunctionNode(FunctionNode $node)
 {
     $inner = $node->getOperand()->accept($this);
     switch ($node->getName()) {
         // Trigonometric functions
         case 'sin':
             return sin($inner);
         case 'cos':
             return cos($inner);
         case 'tan':
             return tan($inner);
         case 'cot':
             return 1 / tan($inner);
             // Inverse trigonometric functions
         // Inverse trigonometric functions
         case 'arcsin':
             return asin($inner);
         case 'arccos':
             return acos($inner);
         case 'arctan':
             return atan($inner);
         case 'arccot':
             return pi() / 2 - atan($inner);
             // Exponentials and logarithms
         // Exponentials and logarithms
         case 'exp':
             return exp($inner);
         case 'log':
             return log($inner);
         case 'lg':
             return log10($inner);
             // Powers
         // Powers
         case 'sqrt':
             return sqrt($inner);
             // Hyperbolic functions
         // Hyperbolic functions
         case 'sinh':
             return sinh($inner);
         case 'cosh':
             return cosh($inner);
         case 'tanh':
             return tanh($inner);
         case 'coth':
             return 1 / tanh($inner);
             // Inverse hyperbolic functions
         // Inverse hyperbolic functions
         case 'arsinh':
             return asinh($inner);
         case 'arcosh':
             return acosh($inner);
         case 'artanh':
             return atanh($inner);
         case 'arcoth':
             return atanh(1 / $inner);
         default:
             throw new UnknownFunctionException($node->getName());
     }
 }
/**
 * @param int|float $number
 *
 * @return float
 */
function hyperbolicTangent($number)
{
    return (double) \tanh($number);
}
Example #23
0
 public function Footer()
 {
     if ($this->officiel === NULL) {
         return;
     }
     if ($this->officiel === FALSE) {
         $initiales = afficher_identite_initiale($_SESSION['USER_NOM'], FALSE, $_SESSION['USER_PRENOM'], TRUE, $_SESSION['USER_GENRE']);
         $texte = 'Généré le ' . date("d/m/Y \\à H\\hi\\m\\i\\n") . ' par ' . $initiales . ' (' . $_SESSION['USER_PROFIL_NOM_COURT'] . ') avec SACoche [ ' . SERVEUR_PROJET . ' ] version ' . VERSION_PROG . '.';
         $this->SetXY(0, -$this->distance_pied);
         $this->SetFont('Arial', '', 7);
         $this->choisir_couleur_fond('gris_clair');
         $this->choisir_couleur_trait('gris_moyen');
         $this->Cell($this->page_largeur, 3, To::pdf($texte), 'TB', 0, 'C', $this->fond, SERVEUR_PROJET);
     } elseif ($this->officiel === TRUE) {
         if ($this->filigrane) {
             $this->SetFont('Arial', 'B', 72);
             $this->choisir_couleur_texte('gris_fonce');
             $this->TextWithRotation($this->page_largeur / 6, $this->page_hauteur * 5 / 6, "TEST D'IMPRESSION", tanh($this->page_hauteur / $this->page_largeur) * 180 / M_PI, 0);
         }
         $this->SetFont('Arial', '', 4);
         $this->choisir_couleur_texte('noir');
         $this->SetXY(0, -$this->distance_pied - 1.5);
         $this->Cell($this->page_largeur - $this->marge_droite, 3, To::pdf('Suivi d\'Acquisition de Compétences'), 0, 2, 'R', FALSE, SERVEUR_PROJET);
         $this->SetXY(0, -$this->distance_pied);
         $this->Cell($this->page_largeur - $this->marge_droite, 3, To::pdf(SERVEUR_PROJET), 0, 0, 'R', FALSE, SERVEUR_PROJET);
     }
 }
Example #24
0
 private function _tanh($num)
 {
     return tanh((double) $num);
 }
Example #25
0
function coth($x)
{
    return 1 / tanh($x);
}
Example #26
0
 /**
  * @return $this
  * @desc 双曲正切。
  */
 public function tanh()
 {
     $this->current = tanh($this->toDouble());
     return $this;
 }
 /**
  * Implements the derivative of the activation function. By default, this is the 
  * inverse of the 'tanh' activation function: 1.0 - tanh($value)*tanh($value);
  * 
  * @param float $value 'X'
  * @return $float 
  */
 protected function derivativeActivation($value)
 {
     $tanh = tanh($value);
     return 1.0 - $tanh * $tanh;
     //return $value * (1.0 - $value);
 }
 public function tanhHook(&$parser, $expr = '')
 {
     try {
         $res = $this->exprParser->doExpression($expr);
     } catch (ExprError $e) {
         return $e->getMessage();
     }
     $result = tanh($res);
     return $this->check($result);
 }
Example #29
0
print_r($zot);
echo "round\n";
echo round(-2354) . " " . round("foo") . " " . round(0) . " " . round(5) . round(1.2345) . "\n";
echo "sin\n";
echo sin(-2354) . " " . sin("foo") . " " . sin(0) . " " . sin(5) . sin(1.2345) . "\n";
echo "sinh\n";
echo sinh(-2354) . " " . sinh("foo") . " " . sinh(0) . " " . sinh(5) . sinh(1.2345) . "\n";
echo "sqrt\n";
echo sqrt(-2354) . " " . sqrt("foo") . " " . sqrt(0) . " " . sqrt(5) . sqrt(1.2345) . "\n";
echo "srand\n";
srand(12);
echo "(no output)\n";
echo "tan\n";
echo tan(-2354) . " " . tan("foo") . " " . tan(0) . " " . tan(5) . tan(1.2345) . "\n";
echo "tanh\n";
echo tanh(-2354) . " " . tanh("foo") . " " . tanh(0) . " " . tanh(5) . tanh(1.2345) . "\n";
echo "is_finite\n";
if (is_finite(1)) {
    echo "works.";
}
if (is_finite(log(0))) {
    echo " broken";
}
if (is_finite(sqrt(-1))) {
    echo " brokener";
}
echo "\n";
echo "is_infinite\n";
if (is_infinite(1)) {
    echo "broken.";
}
Example #30
0
function yToLat($y, $zoom)
{
    $a = pi() * ($y / totalPixelsForZoomLevel($zoom - 1) - 1);
    return -1 * rad2deg(asin(tanh($a)));
}