"C:/wamp/www/lab6" "Matrix - TXT" "Vector - TXT" " / " "R" " / " "R" ""

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

<?

php
$dizin="C:\wamp\www\lab6";
$d1="matrix.txt";
$d2="vector.txt";
$fmatrix=fopen("$dizin/$d1", "r");
$fvector=fopen("$dizin/$d2", "r");
$satir="";
$ArrayMatrix= array();
$ArrayVector= array();
$ArrayLengh= array();
$satir = fgets($fmatrix);
$ArrayLengh= explode(" ", $satir);
$N=$ArrayLengh[0];
$M=$ArrayLengh[1];
while(!feof($fmatrix))
{
$satir = fgets($fmatrix);
$ArrayMatrix[]=explode(" ", $satir);
}
$Vsize = fgets($fvector);
while(!feof($fvector))
{
$satir = fgets($fvector);
$ArrayVector[]=$satir;
}
MatrixMultiple($ArrayMatrix, $ArrayVector, $N, $M);
function MatrixMultiple( $Array1,$Array2,$End1,$End2 ){
$array=array();
$temp=0;
for($i=0; $i<$End1; $i++)
{
for($j=0; $j<$End2; $j++)
{
$temp += $Array1[$i][$j]* $Array2[$j];
}
$array[$i]=$temp;
}
for($i=0; $i<$End1; $i++)
{
Echo $array[$i]." <br>";
}
}
?>

You might also like