matrix multiplication javascrpt

Solutions on MaxInterview for matrix multiplication javascrpt by the best coders in the world

showing results for - "matrix multiplication javascrpt"
Mira
24 Jun 2018
1function multiplyMatrix(matrixA, matrixB)
2{
3    var result = new Array();//declare an array   
4
5    //var numColsRows=$("#matrixRC").val();
6    numColsRows=2;
7    
8    //iterating through first matrix rows
9    for (var i = 0; i < numColsRows; i++) 
10    {
11        //iterating through second matrix columns
12        for (var j = 0; j < numColsRows; j++) 
13        { 
14            var matrixRow = new Array();//declare an array
15            var rrr = new Array();
16            var resu = new Array();
17            //calculating sum of pairwise products
18            for (var k = 0; k < numColsRows; k++) 
19            {
20                rrr.push(parseInt(matrixA[i][k])*parseInt(matrixB[k][j]));
21            }//for 3
22            resu.push(parseInt(rrr[i])+parseInt(rrr[i+1]));
23
24            result.push(resu);
25            //result.push(matrixRow);
26        }//for 2
27    }//for 1
28    return result;
29}// function multiplyMatrix