Commit 911e2ccf by Bertrand NÉRON

### fix doc in matrix

parent dba0c7b4
 ... ... @@ -91,18 +91,14 @@ def to_str(matrix): # by design all matrix cols have same size for row in zip(*matrix): cells = [str(cell) for cell in row] s += " ".join(cells) + "\n" s += "\t".join(cells) + "\n" return s def mult(matrix, val): """ :param matrix: the matrix to compute the size :param matrix: the matrix :type matrix: matrix :param rows_no: the number of rows :type rows_no: int :param col_no: the number of columns :type col_no: int :param val: the value to mult the matrix with :type val: int :return: a new matrix corresponding the scalar product of matrix * val ... ... @@ -115,6 +111,21 @@ def mult(matrix, val): return new_matrix def mult_inplace(matrix, val): """ compute the scalar product of a matrix and a value do this operation in place :param matrix: the matrix :type matrix: matrix :param val: the value to mult the matrix with :type val: int """ for col in matrix: for row_nb, cell in enumerate(col): col[row_nb] = cell * val def get_row(matrix, row_no): """ :param matrix: the matrix to compute the size ... ... @@ -221,8 +232,7 @@ def replace_row(matrix, row_no, row): for col_no, value in enumerate(row): set_cell(matrix, row_no, col_no, value) if __name__ == '__main__': m = create(5, 3) print(m) ... ... @@ -233,4 +243,7 @@ if __name__ == '__main__': print(to_str(m)) print("get row 0", get_row(m, 0)) print("get col 0", get_col(m, 0)) m2 = create(3, 2, 4) mult_inplace(m2, 2) print(to_str(m2))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment