|
I have an expression including sin,cos,and log. Example 3*sin(4)-2. I want to know how to calculate it. Can you help me?Thanks a lot.
|
|
|
|
|
|
|
I compiled a program in Visual C++ .NET (it is an dialogue based MFC type application). I then did a release build. I copied the release build folder onto another computer (my friends') so he could check it out. When we tried to run it, it said something about a file (I think some DLL) was missing.
My question is, how do I make a release build of my application that can run on people's computers (Windows 2000 and XP) even if they don't have Visual Studio .NET? You can tell I am a newbie at this...but I was wonder how to do that.
Any help you can provide would be greatly appreciated.
Thanks.
|
|
|
|
|
use MFC in static library.
|
|
|
|
|
Just out of curiosity: how many messages can I post to Windows message queue in maximum?My test is 10 thousands messages using user message!any refences?
|
|
|
|
|
I guess it depends on the speed at which the application processes them and the amount of free memory available. If it processes them slowly, then the application might run out of memory, as each message does use up a few bytes.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Fascinating!
That is a question I never thought of asking!
I would assume that it depends on the amount of memory available, like most of our programs.
If you realy want to test the limits, you need to start with 65536 (unsigned int) messages and then try 429496295 (unsigned long) messages. I would suggest that they be user defined messages so you know that they can only be processed by your program. I, personaly, would be interested in the results of such a test; at what point will the stytem up-chuck (crash) or simplily stop exepting new messages (which would be more reasonable, but what message dialogbox would popup).
This is simular to doing a memory test, so test away and have fun!
Keep in mind that it is system dependent (aka. virtual memory available, and operating sytem installed) and not, necessarily, operating system dependent.
P.S. I do know you, but you ask question like a real programmer.
INTP
Every thing is relative...
|
|
|
|
|
John R. Shaw wrote:
you need to start with 65536 (unsigned int) messages and then try 429496295 (unsigned long) messagesWhat do you mean by that?
The following is my test code snippet
#define WM_LIYSH (WM_USER + 100)
BOOL CDlgBasedDlg::OnInitDialog()
{
...
while (nCnt != 1000000)
{
::PostMessage(this->GetSafeHwnd(), WM_LIYSH, NULL, NULL);
nCnt++;
}
}
void CDlgBasedDlg::liysh()
{
static int i = 1;
i++;
TRACE("%d\n",i);
}
It turn out that up to the time I tested the i has various value but all of them are under or equal 10000, and what's more, I got failed Assertion under the
_AFXCMN_INLINE void CToolTipCtrl::RelayEvent(LPMSG lpMsg)
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, TTM_RELAYEVENT, 0, (LPARAM)lpMsg); }
where m_hWnd is NULL
|
|
|
|
|
LiYS wrote:
What do you mean by that?
I ment for you to test the limits of your system. How you did it was up to you.
The fact that you started seeing assertions, shows that you're memory resourses where all used up. That is the number of messages you can send is based on the avialable memory.
The numbers I gave where just theoretical values for 16-bit and 32-bit processors (depending on the complier used). That is the maximine possible values.
Do you now know what the mximine number of messages that can be sent is?
INTP
Every thing is relative...
|
|
|
|
|
John R. Shaw wrote:
Do you now know what the mximine number of messages that can be sent is?
OK, I know by now it's memory dependent. But It would be more convincing if I know how the assertions related to memory exhaustion.
|
|
|
|
|
Simple: The programmer who wrote the code to create the window, which allocated memory, and failed, just returned a NULL. In other words he did not say why the call failed, he just said it did.
The first serious program I wrote would not tell you what the problem was, as a matter of fact it would not have told you anything 90% of the time. The only guarantee it gave, was that it would not crash your system, or die unexpectatly.
INTP
Every thing is relative...
|
|
|
|
|
PostMessage
Windows 2000/XP: There is a limit of 10,000 posted messages per message queue. This limit should be sufficiently large. If your application exceeds the limit, it should be redesigned to avoid consuming so many system resources.
"When you know you're going to eat crow, it's best to eat it while it's still warm." - Reader's Digest
|
|
|
|
|
Thanks Squirrel! You brought the offical explanations!
-- modified at 10:41 Sunday 9th October, 2005
|
|
|
|
|
I can type to someone addresses a value
like:
*(char*)0x0012FE10 = 'a';
but how can know 0x0012FE10 in free list or in use list
thanks!
|
|
|
|
|
Can you explain what exactly are you trying to do? Why would you need to write in some specific memory address? Normally, you just declare a local variable in the stack:
char c = 'a';
c = tolower(c);
or allocate it in the heap, use it, and release it when it's no longer needed:
char* pC = new char;
*pC = tolower(*pC);
delete pC;
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
if I to do
*(char*)0x0012FE10 = 'a';
write 'a' in address 0x0012FE10,if 0x0012FE10 is free that no problem,
but if 0x0012FE10 is use that error,so I want to know address 0x0012FE10 is use or free, use windows API? or other?
|
|
|
|
|
That would probably be illegal, unless that memory address was previously allocated for your programs personal use. What I mean by illegal, is that a modern operating sytem may complane if your trying to write to any hard-codeded memory address.
0000000009 wrote:
but how can know 0x0012FE10 in free list or in use list
thanks!
Nothing!
What I am trying to say is that you never hard-code memory addresses, unless you are writting code for hardware.
INTP
Every thing is relative...
|
|
|
|
|
Hi I'am programming matrix product and I have problem with accessing to array.
Its too slow. I use VC++ 6 (win32 console app)
This is only example:
<br />
#define N 1000<br />
int M1[1000];<br />
int M2[1000];<br />
int M3[1000];<br />
int a,b,c;<br />
<br />
<br />
for (j=0;j<N;j++)<br />
for (i=0;i<N;i++)<br />
for (k=0;k<N;k++)<br />
M3[1]=M1[1]*M2[1]; this takes about 6 sec.
for (j=0;j<N;j++)<br />
for (i=0;i<N;i++)<br />
for (k=0;k<N;k++)<br />
a=b*c;<br /> this takes 0.01 sec.
Can somebody tell me how to do it faster ?
Don't worry,I know how to do matrix product. This example just describe slow access to array's elements.
I also tried something with asm block, but
for (j=0;j<N;j++)<br />
for (i=0;i<N;i++)<br />
for (k=0;k<N;k++)<br />
__asm mov ax,1<br /> this takes about 8 sec.
-- modified at 6:27 Sunday 9th October, 2005
|
|
|
|
|
Some questions:
rudo32 wrote:
for (j=0;j<N;j++)<br />
for (i=0;i<N;i++)<br />
for (k=0;k<N;k++)<br />
M3[1]=M1[1]*M2[1];
this takes about 6 sec.
Was the use of 1 as the index in all arrays, and not using neither i , j , or k intentional?
What are M1 , M2 , and M3 ? Are they simple arrays (i.e., as in int M1[1000] ), STL vectors, MFC's CArrays, or what?
rudo32 wrote:
for (j=0;j<N;j++)<br />
for (i=0;i<N;i++)<br />
for (k=0;k<N;k++)<br />
a=b*c;
this takes 0.01 sec.
What are a , b , and c ?
The optimizer might be clever enough not to generate the triple loop and generate all of the above as equivalent to
if (N > 0)
a = b*c;
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
For realley matrix product I will must to use more then one loop.
for(int j=0;j<N;j++)<br />
{<br />
for(int i=0;i<N;i++)<br />
{<br />
fSum=0;<br />
for(int k=0;k<N;k++)<br />
fSum+=M1[N*j+k]*M2[N*k+i];<br />
M[j*N+i]=fSum;<br />
}<br />
}<br />
|
|
|
|
|
Are you sure you mean:
M3[1]=M1[1]*M2[1];
and not something like:
M3[k]=M1[i]*M2[j];
If you were really talking about the first I can't see how it would be possible to be any slower/different than the second example you posted.
If you really ment M3[k]=M1[i]*M2[j] read on:
First, compile with optimizations turned on.
It that doesn't work try using pointers:
for (pj = &j[0]; pj < &j[1000] ; pj++)
for (pi = &i[0]; pi < &i[1000] ; pi++)
for (pk = &k[0]; pk < &k[1000] ; pk++)
*pk=(*pi)*(pj);
Smart compilers might do this for you automaticaly.
H.
-- modified at 20:31 Saturday 8th October, 2005
|
|
|
|
|
Rage_bla wrote:
for (pj = &j[0]; pj < &j[1000] ; pj++)
for (pi = &i[0]; pi < &i[1000] ; pi++)
for (pk = &k[0]; pk < &k[1000] ; pk++)
*pk=(*pi)*(pj);
Your code is much more slower.
If pj is *int, then pj++ is much more slower then j++;
|
|
|
|
|
int main(int argc, char* argv[])
{
DWORD beg = GetTickCount();
int i,j,k;
for (j=0;j<N;++j)
{
for (i=0;i<N;++i)
{
for (k=0;k<N;++k)
{
M3[1] = M1[1] * M2[1]; // no indexing just 1
}
}
}
DWORD end = GetTickCount();
printf("%d\n", end - beg);
beg = GetTickCount();
int* pjk = &M1[1000];
int* pik = &M2[1000];
int* pkk = &M3[1000];
for (int* pj = &M1[0]; pj < pjk ; ++pj)
{
for (int* pi = &M2[0]; pi < pik ; ++pi)
{
for (int* pk = &M3[0]; pk < pkk ; ++pk)
{
M3[1] = M1[1] * M2[1];
}
}
}
end = GetTickCount();
printf("%d\n", end - beg);
}
The first one takes 1.594s on my system, the second one 1.438s.
That is on A64 3500+, 1GB DDR 400.
What system do you have??
-- modified at 9:58 Sunday 9th October, 2005
|
|
|
|
|
Try this. This is matrix product.
int M1[1000*1000];
int M2[1000*1000];
int M3[1000*1000];
for(j=0;j<N;j++)
for(i=0;i<N;i++)
for(k=0;k<N;k++)
M1[j*N+i]=M1[j*N+i]+M2[j*N+k]*M3[i+k*N];
I got AMD 800Mhz 256RAM :DD
-- modified at 12:03 Sunday 9th October, 2005
|
|
|
|