int - How to deal with big float numbers in python -


some part of code generates big int number, further used in other calculations.this number generated calling factorial function . since in other calculation , float numbers , big int involved ,so getting error saying

"overflowerror: long int large convert float".

is there anyway work around limitation ? here attaching code .

import numpy np     #=============================alpha def alpha(li,dtype=float):     ai=1.0     mi in range(1,li+1):         ai=ai*(1-(1/(2.0*mi)))     return ai def gamma(li,dtype=int):     return  np.power(np.exp(1)/li,li)*(np.math.factorial((li)))  def j1j2(xi,deltai,dtype=int):     xii=np.abs(xi)     j1i=np.power(np.abs(xii-deltai),2.0)     j2i=np.power(np.abs(xii+deltai),2.0)     return int(np.floor(j1i)),int(np.ceil(j2i)) #========================*********** def r(xi,sigmai,ni,dtype=float):     ui=xi/sigmai      a1i=np.power(np.exp(1)/ni,ni)     a2i=np.power(ui,2.0*ni)     a3i=(np.power(ui,2.0))     a4i=np.exp(-a3i)     ri=a1i*a2i*a4i         return ri  def r1(xi,sigmai,ni,dtype=float):     ui=1.0*xi/sigmai     ri=np.exp(-2.0*np.power(ui-np.sqrt(ni),2.0))         return  ri      def sumpro(xi,ni,sigmai,a1i,a2i,dtype=float):     sum=0.0     li in (a1i,a2i):         sum=sum+(alpha(li)/gamma(np.abs(ni-li)))*r(xi,sigmai,np.abs(ni-li))     return 2.0*gamma(ni)*sum  def xmatrix(xi,sigmai,kxi,nxi,deltai,dtype=float):     xmati=np.zeros((kxi,nxi),dtype=float)     in range(nxi):         xi=1.0*xi[i]         ui=xi/sigmai         j1i,j2i=j1j2(ui,deltai)         print(i,' ',j1i,j2i)         xmati[0:j1i,i]=1         j in range(j1i,j2i):             print(j )             xmati[j,i]=sumpro(xi,j,sigmai,np.abs(j1i),np.abs(j))     return xmati       def xmatrix1(xi,sigmai,kxi,nxi,deltai,dtype=float):     xmati=np.zeros((kxi,nxi),dtype=float)     in range(nxi):         xi=1.0*xi[i]         ui=xi/sigmai         ni=int(np.floor(np.sqrt(np.abs(ui))))         j1i,j2i=j1j2(ui,deltai)         xmati[ni,i]=sumpro(xi,ni,sigmai,np.abs(j1i),np.abs(ni))      return xmati      x=np.linspace(10.0,100.0,50) x=xmatrix1(x,1,100,50,np.exp(-1.05))     


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -