ERROR OMP更改并行部分外的数组值?

时间:2017-10-25 01:57:14

标签: c openmp

import numpy as np
import matplotlib.pyplot as plt
from lmfit import Model

secs = np.linspace(1, 20, 20)
ft = np.array([16, 62, 138, 242, 366, 504, 652, 808, 971, 1138, 1309, 1483,
          1657, 1831, 2005, 2179, 2353, 2527, 2701, 2875])

def func(t, m, k, g=32.174):
    mk = m / k
    return mk*g*t + (mk*mk)*(np.exp(-t/mk)-1)

model = Model(func)

# make parameters with initial values for parameters
params = model.make_params(m=-50, g=32.174, k=-1)

# you can now fix parameters or keep them varying in the fit:
params['g'].vary = False
params['m'].vary = False

# or set bounds on parameters (you might want to avoid divide by 0)
params['k'].max=-1.e-8

# now do the fit:
result = model.fit(ft, params, t=secs, nan_policy='omit')

# print results
print(result.fit_report())

# plot results:
plt.plot(secs, ft, '.', label='data' )
plt.plot(secs, result.best_fit, '--', label='fit')
plt.xlabel('secs')
plt.ylabel('ft')
plt.legend()
plt.show()

通过在omp并行块之外的memset将board的值设置为零。 董事会的价值不是预期的零,是否有人知道如何解决它?

1 个答案:

答案 0 :(得分:1)

查看malloc的参数,然后查看memset的最后一个参数。看到有什么不同吗?