声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

声振论坛 展示 基础理论 查看内容

稀疏矩阵运算比较

2011-3-18 16:24| 发布者: 雪缘| 查看: 1791| 评论: 0|来自: 振动论坛

摘要: 比较了几种软件创建和运算(加法和乘法)稀疏矩阵的速度。 clear | clear tic | n=200; n = 200; | tic() A = rand(n,n); | A=rand(n ...
比较了几种软件创建和运算(加法和乘法)稀疏矩阵的速度。
clear                                             | clear                        
tic                                                |   n=200;                       
n = 200;                                      |    tic()                        
A = rand(n,n);                             |   A=rand(n,n);                 
for i=1:1000                                |     for i=1:1000                 
  A = A + rand(n,n) * rand(n,n);  |    A=A+rand(n,n)*rand(n,n);   
end                                              |    end                          
toc                                              |  ha=toc()                     
Elapsed time
Octave 12.35s
Matlab 3.77s                                  scilab 2.641s



import os
import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.pyplot as plt
import timeit

from scipy import random
n = 200;
a1=os.times()
A = random.rand(n,n);

for i in range(1,1001):
    A = A + random.rand(n,n) * random.rand(n,n);

a2=os.times()
c=a2[0]-a1[0]
print c

python 2.32s
结果表明,python的运算速度还是可以的,可惜的是没有运算特征值的函数。

本文内容由 mistuning 提供

最新评论

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-20 12:28 , Processed in 0.040032 second(s), 15 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部