numcols()returns the number of columns in the matrix getitem rowcol )returns the value stored in the given matrix element both row and col must be within the valid range setitem rowcolscalar )sets the matrix element at the given row and col to scalar the element indices must be within the valid range scalebyscalar )multiplies each element of the matrix by the given scalar value the matrix is modified by this operation transpose()returns new matrix that is the transpose of this matrix add rhsmatrix )creates and returns new matrix that is the result of adding this matrix to the given rhsmatrix the size of the two matrices must be the same subtract rhsmatrix )the same as the add(operation but subtracts the two matrices multiply rhsmatrix )creates and returns new matrix that is the result of multiplying this matrix to the given rhsmatrix the two matrices must be of appropriate sizes as defined for matrix multiplication matrix operations number of operations can be performed on matrices we first describe some of the more common ones and provide examples as review of matrix arithmetic addition and subtraction two matrices can be added or subtracted to create third matrix when adding two matricescorresponding elements are summed as illustrated here subtraction is performed in similar fashion but the corresponding elements are subtracted instead of summed + + + + + scaling matrix can be uniformly scaledwhich modifies each element of the matrix by the same scale factor scale factor of less than has the effect of reducing the value of each element whereas scale factor greater than increases the value of each element scaling matrix by scale factor of is illustrated here * * * * *