Example #1
0
 /**
  * Check norm of difference of "matrices".
  * @param matrix $X
  * @param matrix $Y
  */
 function checkMatrices($X = null, $Y = null)
 {
     if ($X == null || $Y == null) {
         return false;
     }
     $eps = pow(2.0, -52.0);
     if ($X->norm1() == 0.0 & $Y->norm1() < 10 * $eps) {
         return true;
     }
     if ($Y->norm1() == 0.0 & $X->norm1() < 10 * $eps) {
         return true;
     }
     $A = $X->minus($Y);
     if ($A->norm1() > 1000 * $eps * max($X->norm1(), $Y->norm1())) {
         die("The norm of (X-Y) is too large: " . $A->norm1());
     } else {
         return true;
     }
 }