|
Yeah
It can work well, not considering its run speed
Your way is to adopt an array pointer, that seems a little different
but what has been solved regarding to a big array slice[N][N] by adopting a array pointer?
This is a difficult problem, really. Is it related with OS, compiling way? Or maybe it is a memory allocating problem...
How do you think about this?
|
|
|
|
|
it crashes because if not allocated dynamically this array is allocated on the stack which probably can't hold 1024*1024*4-bytes...
|
|
|
|
|
Problem: "slice[j][i]=(float)(slice[j][i]+0.01F);" is executed faster than "slice[i][j]=(float)(slice[i][j]+0.01F);"
I think it should be answered from two aspects
1. In VC, A two-dimension array is stored according to its row first, then its col,...
2. Virtual memory technology. Paging and Swaping
In this problem every row of that array couldn't get enough free space
so when accessing to any data of another row a swapping action will happen
therefore one runs faster than the other
Am I right?
|
|
|
|
|
Maxwell Chen
|
|
|
|
|
1. I don't know, other than it's likely to be a virtual memory pathology.
2. This is your code,
<br />
for ( j = 0; j< N; j++ )<br />
{<br />
for ( i = 0; i < N; i++ )<br />
{<br />
slice [i][j] = (float)(slice[i][j] + 0.01 ) ;<br />
}<br />
}<br />
for ( j = 0; j< N; j++ )<br />
{<br />
for ( i = 0; i < N; i++ )<br />
{<br />
float * pf = slice + ( i * N ) + j ;<br />
*pf += 0.01 ;<br />
}<br />
}<br />
<br />
for ( j = 0; j< N; j++ )<br />
{<br />
for ( i = 0; i < N; i++ )<br />
{<br />
slice [j][i] = (float)(slice[j][i] + 0.01 ) ;<br />
}<br />
}<br />
for ( j = 0; j< N; j++ )<br />
{<br />
float * pf = slice + (j * N) ;<br />
for ( i = 0; i < N; i++ )<br />
{<br />
*pf += 0.01 ;<br />
++pf ;<br />
}<br />
}<br />
IOW in the first example you are asking the CPU to do an extra multiplication each time around the inner loop. The optimiser may be able to turn it into an addition (if that's faster...), but it's still extra work.
More subtley the second example accesses memory consecutively, so the data is much more likely to be in the CPU cache, whereas the first accesses every N * sizeof ( float ) bytes which means the next value will never be in the cache, accessing main memory means waiting about, accessing the cache puts that off, and since the cache is read and written to main memory in relatively large chunks you will get an entire 'cache line' of modified values going to main memory in the same time as it takes to write one.
Anyway it would be worth examining the generated machine code for each example to see what the optimiser actually does, and perhaps play with the options.
3. The default stack size for Win32 is 1MB. You are asking to allocate 4MB (sizeof ( float ) == 4 ) so the only way is to exit with an exception. You can adjust this in the linker, or with EditBin, but for a data structure of this nature either declaring it statically as in your example or allocation on the heap as in Maxwell's is appropriate.
Paul
|
|
|
|
|
Great!
Full and clear!!
Thank you very much!!!
|
|
|
|
|
I'd like to convert the C programs found in "Controling the world With Your PC" to Visual C++.Net programs. I have the dll for Win2000,XP and need sort of a starting point to the prodess. Ideas, tips? An exsample even ?
I did old QB & a little pascal. Got VB.Net and VC++.Net on the computer.
Thanks
Gyrogearloose
|
|
|
|
|
Any C program should run in VC++, including VC++.NET. What problems are you having ? The most likely one is that a project you create will have precompiled headers turned on, and you'll need to turn them off, or create a stdafx.h file and include it everywhere.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Christian Graus wrote:
Any C program should run in VC++, including VC++.NET
Not C99 (ISO/IEC 9899:1999) programs.
Maxwell Chen
|
|
|
|
|
Oh, yeah. I forgot about that.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Maxwell Chen
|
|
|
|
|
Well, yes that sounds like that will be the next problem and answer. If I try to use (open project) from the start page, it only shows exstentions for the VB.Net that I have on the computer with the C++. It doesn't show C++ exstentions at all. If however I click on a file like duolphase.C , it will display it in visual studio but there are no controls avalable to edit the program. I mean no tabs, no controls at all.
I tryed to set options-environment but found nothing refering to the start page that made any difference. The only thing I can figure is I'll have to type it in as a new project and go from there. Like the header file thing you mentioned.
Wander what would happen if I rename xxxxxx.C to xxxxxx.cs ??
Tryed posting in the VS forum but no answer as yet.
In case your wandering, yes there is a comercial app in the works and a gui-servo&stepper motor app for public domain.
Thanks for the help.
Gyrogearloose
|
|
|
|
|
AAAhhh I got it! Use main menue not the open project tab.
File-open-openfile After it opens in the environment use start without debug . Using Start brings up an error message about it being an a bynary code it don't know. Then it will try to run, ( mixed results) but it does run.
Renaming the file didn't seem to make any difference. Soooo this means the next step is to type it into a new project so debug can handle it.
Small steps guys,small steps.
Gota keep reading this forum. Tons of info.
Gyrogearloose
|
|
|
|
|
I've recently updated one of my MFC applications to use the serialization functions available in CImageList (CImageList::Read and CImageList::Write).
The problem I'm having is, my application must run under both WinNT and WinXP.
When a file is saved under WinXP, the file is no longer readable under NT. I get an unexpected file format error, and the way the CImageLists are being saved seem to be the culprit.
Does anyone know what I can do to make the Image list serialization functions work the same under both operating systems?
|
|
|
|
|
When you save on XP you're getting a v6 format file, which is not readable by previous OSes. Use ImageList_WriteEx() and pass the ILP_DOWNLEVEL flag to save in a format that previous OSes can read.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
"die"
ahhhh!
"diet"
AAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!!!!!!!
|
|
|
|
|
Recap from the title :
I'd like to hide my console-based app from the windows taskbar.
(Basicly once executed, it should just run permanently in the background without bothering me with it's window )
Anyone got any idea how to do this on WinXP ?
(I've searched for it but all I / Google could come up with was stuff that worked on Win9X... I'm proably looking in the wrong direction.. )
|
|
|
|
|
so the W98 stuff does not work in XP ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I dont think you can do that by directly executing the console app.
You can do it by launching the console app from a windows app using createprocess and setting shownowindow* styel..
*I dont remember exactly the bit name but you can find out in the MSDN.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
call GetConsoleWindow() to get the console window handle and then ShowWindow(SW_HIDE) to remove it from windows taskbar.
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
Environment: Windows 2000 Professional, VC++ 6
I am trying to trap the loss of focus on a dialog box in order to close it. Initially I thought that I could handle WM_KILLFOCUS or WM_ACTIVATE. Unfortunately these are not being fired as I expected.
My next approach used SetCapture to detect mouse down events outside the dialog. While it works well for that, it breaks the control notification messaging (e.g. BN_CLICKED): they are no longer fired.
Can anyone suggest a way around this or another approach? It seems like there should be a standard way to do this.
thanks,
Mike Thompson
|
|
|
|
|
|
I've tried it both ways. It started out modal but I made it modeless in the hope that I'd see WM_KILLFOCUS or WM_ACTIVATE at other times. No such luck.
thanks,
MT
|
|
|
|
|
I tried the following and it actually works:
void CDlgFocusTestDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
if (nState == WA_INACTIVE)
EndDialog(IDOK);
else
CDialog::OnActivate(nState, pWndOther, bMinimized);
}
Hope, this will solve ur prob
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
My problem with WM_ACTIVATE is that it is fired only when switching to another application. My application is full-screen and the dialog box is in a DLL loaded by the application. There is only our full-screen application to click on, so WM_ACTIVATE isn't fired.
thanks,
Mike Thompson
|
|
|
|
|
BTW, i tried it with modal dialog box
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|