python中矩阵(matrix或array)运算比for循环速度更快

在matlab中进行矩阵元素处理时,使用矩阵运算比for循环快。在Python语言中也是这样的。下面这个程序是一个简单的测试。python import time as tm import numpy as np dim = 100000#数据长度(包含的元素个数) x1 = np.ones(dim) x2 = np.ones(dim) yFor = np.ones(dim) tStart = t
相关文章
相关标签/搜索