472,953 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,953 software developers and data experts.

recursiveness using bool...

I hav a code like this

Expand|Select|Wrap|Line Numbers
  1. i=0
  2. while i<n:
  3.     xold.data[0][i]=float(self.enINITGUESS.get());   #INITGUESS is an initial value
  4.     xnew.data[0][i]=xold.data[0][i];
  5.     i=i+1
  6. i=0
  7. flag = 1
  8. if True:
  9.     flag=0
  10.     for i in range (n):                  # all this is for improving my xnew
  11.         j=0
  12.         temp=0
  13.         while j<i:
  14.             temp=temp+a.data[i][j]*xnew.data[0][j]    #a,b,xnew,xold are classes #defined earlier
  15.             j=j+1
  16.         j=i+1
  17.         while j<n:
  18.             temp=temp+a.data[i][j]*xold.data[0][j]
  19.             j=j+1
  20.         xnew.data[0][i]=(b.data[0][i]-temp)/a.data[i][i]
  21.         s1=xold.data[0][i]
  22.         s2=xnew.data[0][i]                          #evaluating the results differences
  23.         e.data[0][i]= s1-s2
  24.         if e.data[0][i]<float(0):
  25.             e.data[0][i]=0-e.data[0][i]
  26.         i=0
  27.         for i in range (n):
  28.             xold.data[0][i]=xnew.data[0][i]
  29.         if e.data[0][i]>float(self.enPREC.get()):  #if more than a certain value iterate #again using the newly defined xold
  30.             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?
Jul 13 '07 #1
1 981
elbin
27
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?
This code has no while statement dealing with flag, so I don't see how it could possibly iterate. Just replace the

Expand|Select|Wrap|Line Numbers
  1. if TRUE:
with

Expand|Select|Wrap|Line Numbers
  1. while flag:
and you'll have it.
Jul 13 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Saeed Amrollahi | last post by:
Dear All C++ Programmers Hello I am Saeed Amrollahi. I am a software engineer in Tehran Sewerage Company. I try to use std::map and map::find member function. I use Visual Studio .NET. my...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
0
by: Jim dunn | last post by:
HI I am having problems with C# with regards to its compatibility with win32 API methods, I am trying to read from a windows CE comm port using C# and imported methods from coredll.dll, it seems...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
13
by: kamaraj80 | last post by:
Hi I am using the std:: map as following. typedef struct _SeatRowCols { long nSeatRow; unsigned char ucSeatLetter; }SeatRowCols; typedef struct _NetData
0
by: Mona | last post by:
Newbie question - I am a newbie to c++ and stl maps. My question is based onSystemC which is a specialized C++ hardware programming language. I am trying to create a map with key of type sc_lv<22>...
40
by: Mark P | last post by:
I'm implementing an algorithm and the computational flow is a somewhat deep. That is, fcn A makes many calls to fcn B which makes many calls to fcn C, and so on. The return value of the outermost...
6
by: =?Utf-8?B?U2FtZWVrc2hh?= | last post by:
Hi, I want to write a simple .net program to open a URL, fill in fields, and click on a button to submit it using .net 1.1 framework. Can someone help in suggesting the libraries I should use?...
4
by: Michael Bray | last post by:
Lets say I want to have a sparse lookup by two int values to a string value... I can do it by: Dictionary<int, Dictionary<int, string>d = new ... d = "hello"; This is fine if there is only...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.