Example #1
0
 public static function Ex1()
 {
     // returnam raspunsul sub forma de json
     // completant headerul
     header('Content-Type: application/json');
     // initializam variabilele
     $n = $_POST['n'];
     $A = self::getMatrixFromString($_POST['matrice']);
     $epsilon = $_POST['epsilon'];
     $Ae = self::appendIn($A, $n);
     $gauss = self::GaussElimination($Ae, $n, $epsilon);
     if ($gauss[1]) {
         echo json_encode(array("sts" => 0, "n" => $n, "epsilon" => pow(10, -$epsilon), "A" => self::getStringFromArray($A), "Ae" => self::getStringFromArray($gauss[0]), "invA" => "Matrice Singulara"));
     } else {
         $divide = self::divideIn($gauss[0], $n);
         $R = $divide[0];
         $B = $divide[1];
         $Ai = array();
         for ($i = 0; $i < $n; $i++) {
             $x = HomeWork2::getX($R, $n, $B[$i]);
             $Ai[$i] = $x;
         }
         $AxAi = self::multiplyMatrixes($A, $Ai);
         $In = self::genI($n);
         $norm = self::getNorm1(self::subtractMatrices($AxAi, $In, $n), $n);
         echo json_encode(array("sts" => 1, "n" => $n, "epsilon" => pow(10, -$epsilon), "A" => self::getStringFromMatrix($A), "Ae" => self::getStringFromMatrix($gauss[0]), "invA" => self::getStringFromMatrix($Ai), "det" => self::getDeterminantT($R), "norm" => self::getStringFromArray($norm)));
     }
 }
Example #2
0
             break;
     }
     break;
 case 2:
     switch ($_POST['action']) {
         case 'ex1':
             HomeWork2::ex1();
             break;
         case 'ex2':
             HomeWork2::ex2();
             break;
         case 'ex3':
             HomeWork2::ex3();
             break;
         case 'ex4':
             HomeWork2::ex4();
             break;
     }
     break;
 case 3:
     switch ($_POST['action']) {
         case 'ex1':
             HomeWork3::ex1();
             break;
     }
     break;
 case 4:
     switch ($_POST['action']) {
         case 'ex1':
             HomeWork4::ex1();
             break;