예제 #1
0
 public static function canResize($imagePath)
 {
     $pictureInfo = getimagesize($imagePath);
     $memoryNeeded = round(($pictureInfo[0] * $pictureInfo[1] * $pictureInfo['bits'] * $pictureInfo['channels'] / 8 + Math::power(2, 16)) * 1.65);
     $memoryLimit = str_replace('M', '', Config::getMemoryLimit()) * Math::power(2, 20);
     return $memoryLimit > $memoryNeeded + memory_get_usage(TRUE) ? TRUE : FALSE;
 }
예제 #2
0
 public function multiply($a, $b)
 {
     $times = Math::absSystem($b);
     for ($i = 0; $i < $times; $i++) {
         $a += $a;
     }
     return $b > 0 ? $a : -$a;
 }
예제 #3
0
파일: ArraysW.php 프로젝트: rendix2/QW_MVS
 public static function fisherYates($data)
 {
     $size = count($data);
     foreach ($data as $k => $v) {
         $index = Math::randomInterval(0, $size);
         self::swap($data, $k, $index);
     }
     return $data;
 }
예제 #4
0
파일: Session.php 프로젝트: rendix2/QW_MVS
 public static function newId()
 {
     usleep(Math::randomInterval(2, 4) * 100);
     for ($i = 0; $i < Math::randomInterval(2, 5); $i++) {
         usleep(100);
         session_regenerate_id(TRUE);
         usleep(100);
     }
     usleep(Math::randomInterval(2, 4) * 100);
     return self::id();
 }
예제 #5
0
 public final function getDepth(AbstractBinaryTree $root = NULL)
 {
     if ($root == NULL) {
         return -1;
     }
     if ($root instanceof TernaryTree) {
         return 1 + Math::max($this->getDepth($root->left), $this->getDepth($root->middle), $this->getDepth($root->right));
     } else {
         return 1 + Math::max($this->getDepth($root->left), $this->getDepth($root->right));
     }
 }
예제 #6
0
 public function __construct($width = 400, $height = 200)
 {
     parent::__construct();
     if (!Validator::isNumber($width) || Validator::isNumber($height)) {
         throw new IllegalArgumentException();
     }
     $this->captcha = new Images($width, $height);
     $this->captcha->setBackgroundColor(new Color(0, 0, 0));
     $this->captcha->setTextColor(new Color(255, 255, 255));
     $string = new StringW(Hash::r());
     $this->text = $string->subString(0, Math::randomInterval(6, 8));
     $this->captcha->setText(Math::randomInterval(2, 6), new Point(0, 0), $string, FALSE);
 }
예제 #7
0
 public function index()
 {
     $ipString = '2001:4cfb:bfc4:0000:0000:0000:0123:4aab';
     $myIP = new IPv6("2001:4cfb:0000:0000:0000:0000:0123:4aab", FALSE);
     //$myIP = new IPv4( '1.2.3.4', TRUE );
     $myIP = new IPvU($ipString, FALSE);
     //$myIP = new IPvU( "1.2.3.4", FALSE);
     echo ' IPString=' . $ipString . '<br>';
     echo 'MY IP=' . $myIP->getNiceIP() . '<br>';
     $z = new StringW("aookkooa");
     echo 'Text:<b>' . $z . '</b><br>Longest palindrome using Manachers algorithm: <b>' . $z->getLongestPalindromeManacher() . '</b>';
     $this->getDB()->query('SELECT user_name FROM users LIMIT 50;', []);
     $res = $this->getDB()->fetchAll();
     $this->getDB()->freeStatement();
     echo 'ack2:' . Math::ackermannLimitedRecoursion(3, 88);
     //echo 'ack:' . Math::ackermann( 3, 17 );
     return $res;
 }
예제 #8
0
 public static function solveQuadraticEquation($a, $b, $c)
 {
     if ($b == 0 && $c <= 0) {
         $c = Math::absSystem($c);
         $c /= $a;
         $cSqrt = Math::squareRoot($c);
         return [0 => $cSqrt, 1 => -$cSqrt];
     }
     $d = self::discriminant2($a, $b, $c);
     if ($d < 0) {
         return NULL;
     } else {
         if ($d == 0 || $a == 0) {
             return [0 => -$b / 2 * $a, 1 => NULL];
         } else {
             return [0 => -$b + Math::squareRoot($d) / (2 * $a), 1 => -$b - Math::squareRoot($d) / (2 * $a)];
         }
     }
 }
예제 #9
0
파일: Matrix.php 프로젝트: rendix2/QW_MVS
 public function numberPower($number)
 {
     if (!Validator::isNumber($number)) {
         throw new IllegalArgumentException();
     }
     $newMatrix = [];
     for ($i = 0; $i < $this->getMatrixSizeA(); $i++) {
         for ($j = 0; $j < $this->getMatrixSizeB(); $j++) {
             $newMatrix[$i][$j] = Math::power($this->getMatrix()[$i][$j], $number);
         }
     }
     return new Matrix($newMatrix);
 }
예제 #10
0
파일: Color.php 프로젝트: rendix2/QW_MVS
 public function getRedHexa()
 {
     return Math::decimalToHexadecimal($this->red);
 }
예제 #11
0
파일: Hash.php 프로젝트: rendix2/QW_MVS
 public static function rNum()
 {
     return Math::randomInterval(0, Math::randomInterval(1, Math::randomInterval(2, 1000)));
 }
예제 #12
0
 protected function sort(AbstractSort $sort)
 {
     $maxDepth = Math::logarithmDecade(count($this->originalData)) * 2;
     $this->sortedData = $this->introsort($this->originalData, $maxDepth);
 }
예제 #13
0
파일: index.php 프로젝트: rendix2/QW_MVS
print_r($arrray);
$ms = new \QW\FW\DataWorking\Sort\MergeSort($arrray);
echo '<br><br>UNSORTED:::<br><br>';
print_r($ms->getOriginalArray());
echo '<br><br>SORTED BY MERGE SORT:::<br><br>';
print_r($ms->getSortedArray());
/*
echo 'try Ackermann function:';
echo Math::ackermann( 2, 5 );

echo '<br>Finding Ackermnann inv:<br>';

Math::ackermannInv( 125 )
	->printMatrix();
*/
echo '<br>';
var_dump(Math::randomBoolean());
$root = new TernaryTree(new BinaryTree(NULL, NULL, 1), new BinaryTree(NULL, NULL, 2), new BinaryTree(NULL, NULL, 3), 4, FALSE);
echo 'Z------';
print_r($root->iteratorEulerTour()->getFinalData());
$root = NULL;
$root3 = new TernaryTree(new TernaryTree(NULL, NULL, NULL, 2), new TernaryTree(NULL, NULL, NULL, 3), new TernaryTree(new TernaryTree(NULL, NULL, NULL, 5), new TernaryTree(NULL, NULL, NULL, 6), NULL, 4), 1);
echo 'Euler TERNARY:<br>';
print_r($root3->iteratorEulerTour()->getFinalData());
$root3 = NULL;
$root4 = new \QW\FW\DataStructures\Trees\Nary\NaryTree([new \QW\FW\DataStructures\Trees\Nary\NaryTree([], 3), new \QW\FW\DataStructures\Trees\Nary\NaryTree([], 3), new \QW\FW\DataStructures\Trees\Nary\NaryTree([new \QW\FW\DataStructures\Trees\Nary\NaryTree([], 5), new \QW\FW\DataStructures\Trees\Nary\NaryTree([], 6)], 4)], 1);
$root4 = NULL;
?>


예제 #14
0
파일: Boolean.php 프로젝트: rendix2/QW_MVS
 public static function randomBoolean()
 {
     return new Boolean(Math::randomBoolean());
 }
예제 #15
0
 public static function sieveOfEratosthenes($number)
 {
     $sieve = [];
     $sieve[0] = $sieve[1] = TRUE;
     $squareRoot = Math::squareRoot($number);
     for ($i = 2; $i <= $squareRoot; $i++) {
         if ($sieve[$i] == TRUE) {
             continue;
         }
         for ($j = 2 * $i; $j < $number; $j += $i) {
             $sieve[$j] = TRUE;
         }
     }
     return $sieve;
 }
예제 #16
0
파일: StringW.php 프로젝트: rendix2/QW_MVS
 public function subString($start, $end = NULL)
 {
     return new StringW(mb_substr($this->string, Math::max(0, $start), Math::max(0, Math::min(Math::max(0, $end), $this->getLength() - 1)), self::UTF8));
 }
예제 #17
0
파일: MathComb.php 프로젝트: rendix2/QW_MVS
 public static function getFibonacci($x)
 {
     static $gro5;
     $gro5 = Math::squareRoot(5);
     $fi = (1 + $gro5) / 2;
     return Math::power($fi, $x) / $gro5 - Math::power(1 - $fi, $x) / $gro5;
 }
예제 #18
0
 public function sin()
 {
     return new MathComplexNumber(Math::sin($this->real) * Math::cosH($this->imaginary), Math::cos($this->real) * Math::sinH($this->imaginary));
 }
예제 #19
0
 public function getDepth(AbstractBinaryTree $root = NULL)
 {
     if ($root == NULL) {
         return -1;
     }
     return Math::max($this->getDepth($root->left), $this->getDepth($root->right)) + 1;
 }