|
If the function is not very complex, you can convert it to a constant-time template by using a technique called template metaprogramming. If you post the code maybe I can help you with it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks!
Googled for the term and found some nice pages. I'll try to do the conversion myself first - it will be a nice introduction to the concept. But I hope you don't
mind if I ask you for help if I get stuck...
/moliate
The corners of my eyes catch hasty, bloodless motion -
a mouse?
Well, certainly a peripheral of some kind.
Neil Gaiman - Cold Colours
|
|
|
|
|
Good luck. TMP is an amazing technique, if difficult to tackle at first. Don't hesitate to ask for help.
PS: If you're succesful, your case could be a nice introduction article to this technique here in CP.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
how do you do this?? When i make dialog boxes they minimize right above the taskbar as opposed to minimizing into the taskbar with the parent application... Do you have to change the owner of the dialog boxes?? When you call AFXMESSAGEBOX("") that dialog that is created gets put into the taskbar.. So i am asuming that when a window is created whos owner is the main application, it gets put into the taskbar upon minimization - but when a dialog is created as a child, it minimizes right above the taskbar. Ive asked this quesiton before and had no answers - has anyone had this problem before?? Can someone at least point me where to look for the answer?
thanks
-kevin
|
|
|
|
|
am i explaining myself correctly????????????????????????????????
does anyone have anyclue??
|
|
|
|
|
When you create an instance of the dialog, do you pass it a pointer to it's parent window? i.e.
CMyDialog dlg(this);
dlg.DoModal();
This may help if you're not doing it already
-Alex
|
|
|
|
|
hello @all,
i would like to build a hyperterminal into a mfc program (after i pressed a button, the hyperterminal is to appear).
how can that be done?
thank you very much
sunny
|
|
|
|
|
Try using this code:
<br />
::ShellExecute(0,0,"hypertrm.exe",0,0,SW_SHOW);<br />
|
|
|
|
|
Hmmm,
Can somebodu please help me!
Well here is the story.
In my *.h file i #include <windows.h> if i remove this or #include "stdafx.h" I get this error.
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
in one of my *.h file i use CString and must #include <afx.h> or #include "stdafx.h" but when i do that i get this error what should I do?
Please help me.
\Larsson
|
|
|
|
|
make sure stdafx.h is the very first #include in each source file and that you are not including windows.h in any file at all. If you are developing an MFC app you must use afxwin.h instead. The error is generated when the windows.h file is included before afxwin.h. Hope this helps.
Joseph Dempsey
joseph_r_dempsey@yahoo.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
Well,
Thank it works so far but now I get
fatal error C1004: unexpected end of file found
in the file afxv_w32.h
do you now what this is??
\Larsson
|
|
|
|
|
On an exact note: that message is usually given when you didn't terminate an if/else, while, dowhile, or for() statement correctly or if you left a function open. By the above i mean you forgot to add your closing '}'.
If thats not it:
Seems like there is something screwed with your project. Make sure you don't have any circular included ( one file and that includes another that includes the first one ) and then make sure each of your files in question are setup to use a precompiler header. Also make sure your stdafx.h file is in good shape. If its not the compiler generated maybe posting it here would be helpfull.
Joe
Joseph Dempsey
joseph_r_dempsey@yahoo.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
Just comment out the error. It's a stupid error anyway. I've done it for years on numberous projects and it's never broken anything running that way.
|
|
|
|
|
Hi:
I am not able to explain this behaviour:
1. The following code produces 0.013721122105938371, which is correct:
printf("\n\n%4.25Lf\n\n", + mBase[3][3] * exp( -4.0 * fAlpha * fPeriod )
+ mBase[3][2] * exp( -3.0 * fAlpha * fPeriod )
+ mBase[3][1] * exp( -2.0 * fAlpha * fPeriod )
+ mBase[3][0] * exp( -1.0 * fAlpha * fPeriod ));
2. The following code also produces the same number:
double a,b,c,d;
a = mBase[3][3] * exp( -4.0 * fAlpha * fPeriod );
b = mBase[3][2] * exp( -3.0 * fAlpha * fPeriod );
c = mBase[3][1] * exp( -2.0 * fAlpha * fPeriod );
d = mBase[3][0] * exp( -1.0 * fAlpha * fPeriod );
printf("\n\n%4.25Lf\n\n", a+b+c+d);
3. But this code produces a slightly different number 0.013721122105938344 (error in the last 2 digits for a relatively small loop! for larger loops it only gets worse!):
int n;
double fOrthonormal = 0.0;
for (n = 0; n <= 3; n++) {
fOrthonormal += mBase[3][n] * exp( -( double )(n + 1) * fAlpha * fPeriod);
}
4. MOreover this code, surprisingly also produces a different number!
int n;
double fOrthonormal = 0.0;
for (n = 3; n >= 0; n--) {
fOrthonormal += mBase[3][n] * exp( -( double )(n + 1) * fAlpha * fPeriod);
}
Precision in my case is important. It looks like it's really sensitive to the order in which numbers are added. But when I would intuitively expect an error in the last digit only (for a 4 item loop), it produces an error in the last 2 or 3! Any ideas why this happens?
IS THERE A BETTER NUMBER CLASS TO USE WHEN PRECISION MATTERS?
Thanks
|
|
|
|
|
Anton A. Loukine wrote:
Any ideas why this happens?
because doubles are only approximations.
Anton A. Loukine wrote:
IS THERE A BETTER NUMBER CLASS TO USE WHEN PRECISION MATTERS?
you'll probably need a scaled integer solution, if absolute accuracy is important.
-c
Be very, very careful what you put into that head, because you will never, ever get it out. --Thomas Cardinal Wolsey
|
|
|
|
|
Double precision numbers only have 15 places of precision. Also, when doing addition and subtraction, order of operation can change the result since those operations are most prone to error.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Assuming this reference is upto date:
http://www.cs.nyu.edu/exact/core/download/windowsInstr.html
Its code that deals with exact mathematics. Might be what you need
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
This is because of the IEEE format for FP numbers. If you knew how it's stored, then you'd be amazed that you can get that accurate at all.
The difference is the -(double)(n+1)
Try initalizing a negative double array double a[]={-4.0, -3.0 ...} and using that, if at all possible. It is in the negation that you are losing precision, IMHO.
|
|
|
|
|
Negation is just a simple flip of the sign bit. Addition and subtraction are the usual causes in precision problems..
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Skewled
Well I do know that multiplication is addition - you convert to the same base and add exponents. I forget how addition works. It's been a few years.
|
|
|
|
|
Anton A. Loukine screamed:
IS THERE A BETTER NUMBER CLASS TO USE WHEN PRECISION MATTERS?
1. You don't need to scream.
2. That depends on what you define as "better". Try Googling for NTL (Number theory library). It has almost arbitrary bit-length precision floating point numbers (if you want 1024 bits of FP precision, you get it). It also contains class(es) to handle large integeres.
|
|
|
|
|
Does anyone know how to to get mouse events in the area OUTSIDE the buttons of a tab control?
If I derive a new class from CTabCtrl and then add, for example, a OnLButtonDown() handler, it *never* gets called unless I click on the tab/button area of the control. Is there some mechanism to turn this on? If I override PreTranslateMessage() in my custom tab class, it receives NO messages at all if I click or move the mouse over the out tab control area (i.e. the area that contains the buttons/tabs)
Any thoughts?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
|
|
|
|
|
Hi when i compile the code i get
WINDOWS.H already included. MFC apps must not #include <windows.h>
this is when I add the #include <afx.h>
if i try to remove the #include <windows.h> i get many many error and if i don't add #include <afx.h> I don't can use my funktion.
So what should i do please help if you can.
This is a tricky one.
\Larsson
|
|
|
|
|
Probably removing the LEAN_AND_MEAN define and the #include <windows.h> from your stdafx.h helps.
... you keep forgetting that sheep shagging is not a crime in Australia ...Paul Watson, The Lounge
|
|
|
|
|
Hmmm,
I don't now what you meen what should I remove and whare?
\Larsson
|
|
|
|