Click here to Skip to main content
15,742,011 members

Comments by federico.strati (Top 5 by date)

federico.strati 16-Nov-10 3:45am View    
the solving method is not correct for large values of b, that is why I presented the correct algorithm in another alternate... see Numerical Recipees in C or Wolfram site
federico.strati 10-Nov-10 5:07am View    
Oh well, thanks Alain, I didn't know the standard evoluted to include the machine epsilon in the constants, I will include it in the solution... :-)
federico.strati 9-Nov-10 10:38am View    
Oh well, the machine epsilon is around 3x10-8 for single precision and around somethingx10-16 for double precision... but to effectively state the tolerance for each machine you need a list of define's as in the GSL (GNU Scientific Library). It's not given in <limits.h> or other standard includes. Hence the used value 1x10-15 is a good choice for portable programs... It is up to the programmer and left as an exercise for the reader here to implement machine epsilons define's appropriate for its programs. Remember this is just a Tip, not a full bloated library... Cheers
federico.strati 9-Nov-10 4:23am View    
The inputs "y" and "z" serve the only purpose of finding a root in the given [y,z] interval. I needed it in my work so I left it in the function presented here. But, as you say, you may just eliminate those two inputs and use "x1=q/a; x2=c/q;" in the body of the function.
federico.strati 19-Oct-10 6:30am View    
Yes, it is more complex in the base class stated, but it is very simple to use it:
you just derive a class, say CSimpleConsumer, from CConsumer and implement the virtual method
"Execute" to do whatever you need taking into account the m_bStop boolean to exit cleanly.
You start the thread with base method "Start", you abort with "Abort", you stop with "Stop", etc...
in this way you have embedded a thread completely in a class per itself.
You instantiate the derived class and you have a new thread available, etc... .
Maybe you may interested in this simple way to embed a thread in a class. This is achieved
just by passing "this" to the argument of CreateThread and having the member "LocalThreadFunc"
reinterpret it and calling the pure virtual method of the class "Execute".