|
The code is meant to calculate the MSE of a transmit code for synthetic aperture radar systems. I really only included it in case someone wanted to dig through it. I guess I meant my question to be more general. As in, "Given any function with only local variables, why would this behavior occur? (by the way, here's such a function)"
|
|
|
|
|
sorry, didnt see this - my b/berry didnt synch or was off the network for some reason ..
As KarstenK says below, which was a also the point of the link I pasted, make sure everything is initialised to a value you expect - even a matrix, where the system has gone out and grabbed chunks of memory for the cells, may not be 'clean' - so if you're doing a calc across the matrix and there's cr@p in the middle, bingo
'g'
|
|
|
|
|
Posted code contains many instances of your own classes. Since we don't know about them, how could help?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Ah, my mistake, I did not copy the includes. The classes used are all defined in the boost ( http://www.boost.org/[^]) template library and in the STL. Matrix is boost's ublas implementation, complex and vector are STL.
|
|
|
|
|
if debug != release it is often an contruction issue.
is std::vector< complex<double> > properly initilized?
or the use of some static members can often lead to damages
make som output in the long function to find WHERE it happens
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I am trying to save the content in IPicture to JPG. CImage seems to promising. However I can't use MFC or ALT. Thanks in advance...
|
|
|
|
|
Have you tried this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks very much for your reply. I figured out the solution by myself. I ended up with using Gdi+. What I did was:
1) Create IStream and save content of IPicture to this stream;
2) call Gdiplus::Image::FromStream to load this BMP format stream into image;
3) By passing in the JPG format ClsID, I called Save to save this image to JPG format stream. This is all I needed. Of course, you can save it out as a file.
|
|
|
|
|
Here is simplest way for save jpg and... formats CImage class.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hello everybody!
I'm working on a small personal project which has to use async sockets. So far I've not yet finished the GUI (since I'm coding it with pure WinAPI, it's going to take some time) but i thought to give it a shot and see if it's processing all specified messages in WndProc but so far i realized that it isn't processing network messages. Here's a sample code from my project:
int WINAPI WinMain(HINSTANCE currentInst,
HINSTANCE prevInst,
LPSTR args,
int showVar)
{
WSADATA wsaData;
if(WSAStartup(0x0202, &wsaData))
{
MessageBox(NULL,"Call to WSAStartup() failed at line #", "Error!", MB_ICONEXCLAMATION | MB_OK);
WSACleanup();
return wsaFail;
}
else
{
if(wsaData.wVersion != 0x0202)
{
MessageBox(NULL,"Wrong socket version! at line #", "Error!", MB_ICONEXCLAMATION | MB_OK);
WSACleanup();
return wsaFail;
}
}
WNDCLASSEX windowClass;
HWND handleToWindow;
SOCKET serverSocket;
sockaddr_in serverSockAddrIn;
MSG Msg;
windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.style = CS_HREDRAW | CS_NOCLOSE | CS_VREDRAW;
windowClass.lpfnWndProc = WndProc;
windowClass.lpszClassName = class_name;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hInstance = currentInst;
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 6);
windowClass.lpszMenuName = NULL;
windowClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&windowClass))
{
MessageBox(NULL, "Window Registration Failed at EntryPoint.cpp line #", "Error!", MB_ICONEXCLAMATION | MB_OK);
return windowRegistrationFail;
}
handleToWindow = CreateWindowEx(WS_EX_CLIENTEDGE | WS_EX_OVERLAPPEDWINDOW | WS_EX_TOPMOST,
class_name,
"Server Console",
WS_OVERLAPPED| WS_VISIBLE,
400, 500, 800, 500, NULL, NULL, currentInst, NULL);
if(handleToWindow == NULL)
{
MessageBox(NULL, "Window Creation Failed at line #", "Error!", MB_ICONEXCLAMATION | MB_OK);
return windowCreationFail;
}
UpdateWindow(handleToWindow);
memset(&serverSockAddrIn, 0, sizeof(serverSockAddrIn));
serverSockAddrIn.sin_family = AF_INET;
serverSockAddrIn.sin_port = htons(2567);
serverSockAddrIn.sin_addr.s_addr = htonl(INADDR_ANY);
serverSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(serverSocket == INVALID_SOCKET)
{
MessageBox(NULL, "Socket Creation Failed at EntryPoint.cpp line#", "Error!", MB_ICONEXCLAMATION | MB_OK);
WSACleanup();
return socketFail;
}
WSAAsyncSelect(serverSocket, handleToWindow, NetworkNotification, FD_ACCEPT | FD_READ | FD_WRITE | FD_CLOSE);
if(bind(serverSocket, (sockaddr*)&serverSockAddrIn, sizeof(serverSockAddrIn)) == SOCKET_ERROR)
return 0;
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return 0;
}
So far this is the whole entry point of my program. Keep in mind that it's not finished yet. Please do not reply with coments like "You should error check at x" etc. if it's not a possible fix for my problem.
WndProc (showing only network messages):
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case NetworkNotification:
{
switch(WSAGETSELECTEVENT(lParam))
{
case FD_ACCEPT:
{
MessageBox(hwnd, "Success!", "Test", NULL);
break;
}
case FD_READ:
break;
case FD_WRITE:
break;
case FD_CLOSE:
break;
}
}
case WM_COMMAND:
{
}
case WM_CREATE:
{
}
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
}
I repeat...it's not the whole WndProc here. Unless it's really needed i wouldn't like to post it all.
As far as I'm aware, it should show the message box when a client is trying to connect, but of course.. since i'm not calling accept() the client won't be able to connect but it still should trigger a FD_ACCEPT event...right ?
Ahh...i almost forgot..
#define NetworkEvent (WM_USER + 5)
modified on Friday, January 8, 2010 8:32 AM
|
|
|
|
|
What is the value of "NetworkNotification"? Unless it's a valid WM_xxx type message it will not be getting dispatched to your WndProc.
|
|
|
|
|
Member 4054478 wrote: As far as I'm aware, it should show the message box when a client is trying to connect, but of course.. since i'm not calling accept() the client won't be able to connect but it still should trigger a FD_ACCEPT event...right ?
Yes, but you should also listen to incoming connections on the server side: socket , WSAAsyncSelect , bind , listen
Let me know if this fixes it. When implementing an own asynchronous network class, think about adding a DNS resolver later on... otherwise hostname lookups will be blocking everything (they can take quite a while).
/M
|
|
|
|
|
|
can i have an example using this method?
|
|
|
|
|
Searching[^] is not so difficult.
Neither reading first[^].
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
|
No comments.
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
can you define "POLYGON" ?
|
|
|
|
|
a04.lqd wrote: can you define "POLYGON" ?
Dead parrot
|
|
|
|
|
a polygon is a 2 dimensional object with at least three sides.
what the heck do you think it means?
sorry. watch out for the blowback.
|
|
|
|
|
the inside, the outside, and the ...
gee, I keep forgetting the third one.
|
|
|
|
|
Yes, I can.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
.
. .
Can you line the dots? That's one polygon (a.k.a. Triangle)
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
No, and anyone who just hands you one is a fool.
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
sure.
int main(int argc, char** argv)
{
return 0;
}
|
|
|
|
|