【Python】矩阵类的实现
内容
矩阵类的python实现
涉及知识
python的运算符重载
实现功能
矩阵类、取值、设值、判断维度相等、乘法
代码
import copy
class Matrix:
def __init__(self,row,col,value=0):
self.shape = (row,col)
self.row = row
self.col = col
self._matrix = [[value for _ in range(col)] for _ in range(row)]
def __getitem__(self,index)