petitviolet_blog

@petitviolet blog

2012-12-20から1日間の記事一覧

Scipyでの疎行列の扱い

行列の計算 import scipy.sparse as sp import numpy as np a = sp.lil_matrix((1, 10000)) # 1*10000の疎行列が作成される b = sp.lil_matrix((1, 10000)) # a.shape => (1, 10000) for i in xrange(a.shape[1]): r = np.random.rand() if r < 0.9: r = 0.0…