数式から来るそれぞれのケースで、巨大な(、例えば 96Go、72000行×72000列)の配列を作成して浮動小数点数を入れなければなりません。配列は後に計算されます。巨大なnumpy 2D配列を作成して塗りつぶす最速の方法は?
import itertools, operator, time, copy, os, sys
import numpy
from multiprocessing import Pool
def f2(x): # more complex mathematical formulas that change according to values in *i* and *x*
temp=[]
for i in combine:
temp.append(0.2*x[1]*i[1]/64.23)
return temp
def combinations_with_replacement_counts(n, r): #provide all combinations of r balls in n boxes
size = n + r - 1
for indices in itertools.combinations(range(size), n-1):
starts = [0] + [index+1 for index in indices]
stops = indices + (size,)
yield tuple(map(operator.sub, stops, starts))
global combine
combine = list(combinations_with_replacement_counts(3, 60)) #here putted 60 but need 350 instead
print len(combine)
if __name__ == '__main__':
t1=time.time()
pool = Pool() # start worker processes
results = [pool.apply_async(f2, (x,)) for x in combine]
roots = [r.get() for r in results]
print roots [0:3]
pool.close()
pool.join()
print time.time()-t1
- ような巨大なnumpyの配列を作成し、記入する最速の方法は何ですか? を入力して集計し、numpy配列に変換しますか?
- 2d-arrayのcase/columns/rowsが独立しているため、配列の充填を高速化できますか?マルチプロセッシングを使ってそのような計算を最適化するための手掛かり/トレイル?
それがリアルタイムである必要はないか、それを計算することができますオフラインで使用するそれを読むためにピクルス? –
私はリアルタイムであることを好むが、酸洗がより速ければ、私は気にしない...あなたの質問をよく理解することを願っていますか? – sol