Advertisement
chmdznr

application of power of matrix library

Sep 8th, 2014
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. //baca matrix dari file .csv
  2. if (($handle = fopen('the_matrix.csv', 'r')) !== FALSE) {
  3.     $m1=array();
  4.     $row=0;
  5.     while (($data = fgetcsv($handle)) !== FALSE) {
  6.         for($col=0;$col<count($data);$col++){
  7.             $m1[$row][$col]=$data[$col];
  8.         }
  9.         $row++;
  10.     }
  11.     fclose($handle);
  12. } else {
  13.     echo 'Failed to read the file!';
  14.     exit();
  15. }
  16. echo 'Original Matrix:';
  17. print_matrix($m1);
  18. $start_time = microtime(true);
  19. $pangkat=mat_pow($m1, 512);
  20. $stop_time = microtime(true);
  21.  
  22. echo 'Matrix after power to 512:';
  23. print_matrix($pangkat);
  24.  
  25. echo 'Time needed to calculate (ms) = '.($stop_time-$start_time);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement