Hi everyone,
I am trying to re-implement a function using numba @guvectorize , but it is giving a different answer than the original one, even with different dimensions, although I exactly copy-pasted the inner implementation of the function.
Here is the code -
def _numbba_dfun(c_0,r,s,xo,K11,K12,K21,sigma,mu,A_ik,B_ik,C_ik,a_i,b_i,c_i,d_i,e_i,f_i,h_i,p_i,IE_i,II_i,m_i,n_i,xi,eta,tau,alpha,beta,gamma,local_coupling,derivative):
derivative[0] = (eta - a_i * xi ** 3 + b_i * xi ** 2 - tau +
K11 * (numpy.dot(xi, A_ik) - xi) -
K12 * (numpy.dot(alpha, B_ik) - xi) +
IE_i + c_0 + local_coupling * xi)
derivative[1] = c_i - d_i * xi ** 2 - eta
derivative[2] = r * s * xi - r * tau - m_i
derivative[3] = (beta - e_i * alpha ** 3 + f_i * alpha ** 2 - gamma +
K21 * (numpy.dot(xi, C_ik) - alpha) +
II_i + c_0 + local_coupling * xi)
derivative[4] = h_i - p_i * alpha ** 2 - beta
derivative[5] = r * s * alpha - r * gamma - n_i
output-
[[[0.00626052 0.02834203 0.01901754]]
[[0.00626052 0.02834203 0.01901754]]
[[0.00626052 0.02834203 0.01901754]]]
original -
[[ 8.92213600e+00 3.06011878e+00 6.53621388e+00]
[-4.28615252e+00 -1.57905386e+01 6.35905655e-01]
[ 6.90567981e-02 4.11970892e-02 4.15780552e-02]
[ 1.06933037e+01 4.98178298e+00 7.40080018e+00]
[-5.58867023e+00 -8.52945099e-01 -4.12586326e-01]
[ 6.26051667e-03 2.83420291e-02 1.90175413e-02]]
Why does it not give the same dimensions, and it’s just calculating 1 value 3 times and just returning it? I’m new to Numba and this forum, so if additional information is needed please let me know. I would appreciate any input or insights from your side.
Thank you!