Starting from:
$30

$24

Homework 2 Matrix Multiply Solution




Write a matrix multiply function, called mm, in JavaScript



The function should take two arguments, and return the matrix-multipied result.



Your function should do error checking. For example:



– Are both arguments arrays?




– Are the lengths consistant?




Document what you error check.



You need to support 1x1 matrixes, with no upper bound on size.



Matrixes are represented using nested arrays.



The innermost arrays are the rows.



So




[[1,2,3],[4,5,6]]




represents a 2x3 matrix




(123




456)




For example:




mm(1,2)



throw new Error("first argument is not an array");




console.log(mm([[1,2],[3,4]],[[5,6],[7,8]])); [[19,22],[43,50]]



For this exercise, you are allowed to use any resource you wish as long as you give the source. (for example, stack overflow)
Hand in you listing, and at least 3 tests (input and output).



You can use chalk and chrome, just chrome, or node.



Use




http://ku-fpg.github.io/workbook/EECS_368/ To generate the cover sheet.



1

More products