05 Matrix multiple deminsions Program PHP- record

  sava--matrix5.php 

program:-

<?php

function multiply(&$mat1, &$mat2, &$res)
{
    $N = 4;
    for ($i = 0; $i < $N; $i++)
    {
        for ($j = 0; $j < $N; $j++)
        {
            $res[$i][$j] = 0;
            for ($k = 0; $k < $N; $k++)
                $res[$i][$j] += $mat1[$i][$k] * $mat2[$k][$j];
        }
    }
}


$mat1 = array(array(1, 1, 1, 1),array(2, 2, 2, 2),array(3, 3, 3, 3),array(4, 4, 4, 4));

$mat2 = array(array(1, 1, 1, 1),array(2, 2, 2, 2),array(3, 3, 3, 3),array(4, 4, 4, 4));

multiply($mat1, $mat2, $res);
$N = 4;
echo ("Result matrix :<br>");
for ($i = 0; $i < $N; $i++)
{
    for ($j = 0; $j < $N; $j++)
    {
        echo ($res[$i][$j]);
        echo(" ");
    }
    echo ("<br>");
}
?>
 

output:-


 


Comments

Popular posts from this blog

digital marketing ppt-u1

SOFTWARE

cn lab

Computer Operations and Performing - D L Unit-1-1

DBMS Degree Lab Records

DS-Record-mca-04) write a program for evaluating a given postfix expression using stack.

Java unit-1 history , C++ vs Java , java environment

Access the Internet to Browse Infromation & E-Mail Operation- D L Unit-2-1

OAT-Record-01) Visiting card

java program structure,java Tokens, keywords,