I hav a code like this
evidently this code does not seem to reiterate... it jus perform the operation once only.... even if it finds tht the difference exceeds the given value specified by PREC it doesnt iterate again... it jus throws out the result of the calculation given by its first attempt on it... anybody care 2 help?
Code:
i=0
while i<n:
xold.data[0][i]=float(self.enINITGUESS.get()); #INITGUESS is an initial value
xnew.data[0][i]=xold.data[0][i];
i=i+1
i=0
flag = 1
if True:
flag=0
for i in range (n): # all this is for improving my xnew
j=0
temp=0
while j<i:
temp=temp+a.data[i][j]*xnew.data[0][j] #a,b,xnew,xold are classes #defined earlier
j=j+1
j=i+1
while j<n:
temp=temp+a.data[i][j]*xold.data[0][j]
j=j+1
xnew.data[0][i]=(b.data[0][i]-temp)/a.data[i][i]
s1=xold.data[0][i]
s2=xnew.data[0][i] #evaluating the results differences
e.data[0][i]= s1-s2
if e.data[0][i]<float(0):
e.data[0][i]=0-e.data[0][i]
i=0
for i in range (n):
xold.data[0][i]=xnew.data[0][i]
if e.data[0][i]>float(self.enPREC.get()): #if more than a certain value iterate #again using the newly defined xold
flag=1
evidently this code does not seem to reiterate... it jus perform the operation once only.... even if it finds tht the difference exceeds the given value specified by PREC it doesnt iterate again... it jus throws out the result of the calculation given by its first attempt on it... anybody care 2 help?
Comment