Accelerer execution d un programme - matrices
Bonjour,
J aimerais savoir s il est possible d accelerer ce programme, qui semble prendre bcp trop de temps (quand j appelle getPPgrid, XgRID ET YGrid sont des np array 200*200):
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
def GetPrice(self,payoff):
return self.Integrator.IntegrateOverDensity(payoff)
def GetPPPrice(self,k1,k2):
return self.GetPrice(GenPPPay(k1,k2))
def GetPPGrid(self,xGrid,yGrid):
rowNum=xGrid.shape[0]
colNum=xGrid.shape[1]
rep=np.empty([rowNum,colNum])
for i in range(0,rowNum):
for j in range(0,colNum):
rep[i][j]=self.GetPPPrice(xGrid[i][j],yGrid[i][j])
return rep
# return self.GetPPPrice(xGrid,yGrid) |
Code:
1 2 3 4 5 6 7 8 9
|
def GenPPPay(k1,k2):
return lambda (x,y):DuoDiPPPayOff(x,y,k1,k2)
def DuoDiPPPayOff(x,y,k1,k2):
if(x<=k1 and y<= k2):
return 1
else:
return 0 |
Thanks!