|
New Problem: Now I'm doing the multiplication, where I'm trying to multiply the arrays in this order:
<br />
lambda_array*dip_array*azim_array*r_array<br />
what am i doing wrong? all my values in the final range array, fr_array are all zero, which shouldn't be the case...
Here's the code.
<br />
<br />
#include <math><br />
#include "stdafx.h"<br />
#include <iostream><br />
using namespace std;<br />
<br />
double theta, phi, t, p;
double lambda1 = 0.5;<br />
double lambda2 = 2;<br />
double a11,a12,a21,a22,d11,d13,d31,d33;<br />
const double pi = 3.142857;<br />
const int rows = 3;<br />
const int cols = 3;<br />
<br />
double dip_array [3][3] = {0}; <br />
<br />
double azim_array [3][3] = {0}; <br />
<br />
double lambda_array [3][3] = {0}; <br />
<br />
double r_array [3] = {0};<br />
<br />
double fr_array [3][3] = {0}; <br />
<br />
<br />
double a(double p)<br />
{<br />
d11 = cos((p*pi)/180);<br />
return d11;<br />
}<br />
<br />
double b(double p)<br />
{<br />
d13 = -1*sin((p*pi)/180);<br />
return d13;<br />
}<br />
<br />
double c(double p)<br />
{<br />
d31 = sin((p*pi)/180);<br />
return d31;<br />
}<br />
<br />
double d(double p)<br />
{<br />
d33 = cos((p*pi)/180);<br />
return d33;<br />
}<br />
<br />
<br />
double e(double t)<br />
{<br />
a11 = sin((t*pi)/180);<br />
return a11;<br />
}<br />
<br />
double f(double t)<br />
{<br />
a12 = cos((t*pi)/180);<br />
return a12;<br />
}<br />
<br />
double g(double t)<br />
{<br />
a21 = -1*cos((t*pi)/180);<br />
return a21;<br />
}<br />
<br />
double h(double t)<br />
{<br />
a22 = sin((t*pi)/180);<br />
return a22;<br />
}<br />
<br />
<br />
void printarray (double arg[][3]) <br />
{<br />
for (int i=0; i<rows; i++)
{<br />
for (int j=0; j<cols; j++)
cout << arg[i][j] << " ";<br />
cout << "\n";<br />
}<br />
}<br />
<br />
void printarray2(double arg[]) <br />
{<br />
for (int i=0; i<rows; i++)
{<br />
cout << arg[i] << " ";<br />
cout << "\n";<br />
}<br />
}<br />
<br />
void mult(double fr_array[3][3])<br />
{<br />
for(int i=0;i<rows;i++)
{<br />
for(int j=0;j<cols;j++)
{<br />
for(int k=0;k<cols;k++)
{<br />
for(int l=0;l<cols;l++)
{<br />
fr_array [i][j] += lambda_array [i][l]*dip_array [l][k]*azim_array[k][j];<br />
fr_array [i][j] += fr_array[i][j]*r_array[i];<br />
}<br />
}<br />
}<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
<br />
cout<<"ANISOTROPY MODELLING.\n";<br />
cout<<"\nPlease enter a real number between 0 and 360 for the azimuth angle, theta, then press the 'Enter' key.\n\n";<br />
cin>>t;<br />
<br />
cout<<"\nPlease enter a real number between 0 and 360 for the dip angle, phi, then press the 'Enter' key.\n\n";<br />
cin>>p;<br />
<br />
a(p);<br />
b(p);<br />
c(p);<br />
d(p);<br />
e(t);<br />
f(t);<br />
g(t);<br />
h(t);<br />
<br />
double dip_array [3][3] = {{d11,0,d13},{0,1,0},{d31,0,d33}}; <br />
<br />
double azim_array [3][3] = {{a11,a12,0},{a21,a22,0},{0,0,1}}; <br />
<br />
double lambda_array [3][3] = {{lambda1,0,0},{0,1,0},{0,0,lambda2}}; <br />
<br />
double r_array [3] = {4,8,3.94};<br />
<br />
<br />
<br />
cout<<"\nThe dip array is:\n";<br />
printarray(dip_array);<br />
<br />
cout<<"\nThe azimuth array is:\n";<br />
printarray(azim_array);<br />
<br />
cout<<"\nThe anisotropy array is:\n";<br />
printarray(lambda_array);<br />
<br />
cout<<"\nThe original range array is:\n";<br />
printarray2(r_array);<br />
<br />
<br />
mult(fr_array);<br />
cout<<"\nThe final range array is:\n";<br />
printarray(fr_array);<br />
<br />
<br />
<br />
return 0;<br />
}
You can use 60 degrees for theta and phi, for check, since cos(60) = 0.5, sin(60) = 0.866....
|
|
|
|
|
I add a new Win32 Console Application project, how can include what
files to use MFC CString ?
Thanks in advance.
|
|
|
|
|
when you are create new WIN32 Console Application project , on step 1 you can choose "An application suppurt MFC" from options.
But you can also include class <afx.h> that support CString.
|
|
|
|
|
I add a new Win32 Application project, how can I use MFC in this project ? What files will I need to include ?
Thanks in advance.
|
|
|
|
|
I did not choose this option, how can I use it in current project?
Thanks in advance.
|
|
|
|
|
1.From Project|Setting Choose Option form MFC Dll!
2.include afxwin.h header file for your CString class.
3.call AfxWinInit(..) for intialization of MFC dll in your Application
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
How can I tell when a window has refreshed its (for lack of a bettter term) window hooks? More specifically, how can I tell when a hook I have installed on a window has been flushed out?
Thanks
|
|
|
|
|
Who can tell me how I can get the HWND of Edit Box in a window,if I have get the CWnd of the window.thank you very much!!!
Jack
|
|
|
|
|
// Wnd is an instance of CWnd
HWND hwndEdit = ::GetDlgItem (Wnd.GetSafeHwnd(), ID_EDIT);
|
|
|
|
|
Thank you~~But idon't know The ID_EDIT.Indeed I need a function that auto detect the current window which contain a text box,and then record the window title.
Jack
|
|
|
|
|
If you have a CWnd from your edit box, let's name it MyWnd, then simply use
HWND MyHandle = MyWnd.m_hwnd.
CWnd::m_hWnd is public.
~RaGE();
|
|
|
|
|
CWnd::GetSafeHwnd()
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi,
I am finding the TStringGrid component which I want to import to MFC application,
Anyone knows, please let me know !!!
Because in my MFC application I need to get data from the TStringGrid Control (this control from Another applicatin that was create by Delphi, it contains the TStringGrid control likes CListCtrl in MFC application)
Thanks
flowerdan
|
|
|
|
|
MSDN says we can use VirtualAllocEx() to obtain memory from another process.
When I testify this, VirtualAllocEx(MEM_RESERVER|MEM_COMMIT) succeeded,
but when I tried to write to the buffer, most often it caused GPF!
Here is my sample codes:
// Create a child process and obtain its handle.
// Use the handle to allocate memory with VirtualAllocEx().
// Then use the return buffer to do data copying, etc...
-----------------------------------------------------------------
...
CreateProcess( OtherProcess, NULL,NULL, NULL, TRUE, CREATE_SUSPENDED , NULL, NULL, &si, &pi );
pBase = (char*) VirtualAllocEx ( pi.hProcess, NULL, iSize, MEM_RESERVE, PAGE_NOACCESS );
pBuffer = (char*) VirtualAllocEx ( pi.hProcess, pBase, iSize, MEM_COMMIT, PAGE_READWRITE);
ZeroMemory( temp, iSize); // *** Add this line causes GPF at the end of the program***
VirtualFreeEx( pi.hProcess, pBase, 0, MEM_DECOMMIT);
VirtualFreeEx( pi.hProcess, pBase, 0, MEM_RELEASE);
.....
ResumeThread( (HANDLE ) pi.hThread);
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
...
-----------------------------------------------------------------
It seemed everything were OK as all the function calls all succeeded.
However, the program could encounter GPF upon end of main().
Obviously it was caused by the ZeroMemory() write action.
If no write action was performed, then no problem arised.
And if only wrote few hundread bytes to the return buffer, it could have no problem either.
I think I could have make some mistakes here but I still couldn't find out the reason after carefully examining all the possibilities.
Can somebody give me insight on this!
Other than FileMapping or WM_COPYDATA,
I really want to use another approach like VirtualAllocEx() to share data among different processes.
Thanks for help.
|
|
|
|
|
macauit wrote:
ZeroMemory( temp, iSize);
What is "temp"? It's not defined anywhere in your code...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
For performing some write operations in memory allocated by VirtualAllocEx() use WriteProcessMemory() function. Other functions often raise an exception when used to write in memory of another process.
|
|
|
|
|
Hi,
I'm working on a SDI MFC application that's coming along good, but I got a frustrating bug.
Double clicking on a file in, for instance, my documents, gives a error message saying that the file cannot be found, and asks me to check the filename spelling and that the file exists. The thing is, the files opens just as it should, I just get this message as a "extra treat".
Any ida on what's going wrong?
|
|
|
|
|
what is the difference between (c):
HMENU hMenu = NULL;
and
HMENU hMenu = (HMENU) NULL;
or (c++):
HMENU hMenu = 0;
and
HMENU hMenu = reinterpret_cast<HMENU>(0);
Is cast operator while initializing pointers really necessary?
|
|
|
|
|
There is no difference between any of those. They all have the same effect.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hello,
I am trying to make a plugin in Visual C++ using netscape API.
the plugin gets invoked when i try to open a non-native user defined file (eg. somefile.yyy )and runs properly. But it does get invoked for html and htm files.
Please help....i need to submit this project for graduation.
thanks in advance...
zuber
|
|
|
|
|
I was trying to includeThe nFS Library[^] in my project, but I couldn't do it like the demo application, where he didn't include neither the .h files nor the .lib file into the project.
When I tried to recompile my program with including all the .h and .cpp files of the libraries it worked.
Since my project is already full with files, so I removed all these files, and included only the .lib file, and recompiled the program. and I got the following error
LIBCMT.lib(crt0.obj) : error LNK2005: __amsg_exit already defined in msvcrtd.lib(MSVCR70D.dll)<br />
LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCR70D.dll)<br />
LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCR70D.dll)<br />
LIBCMT.lib(crt0dat.obj) : error LNK2005: __cexit already defined in msvcrtd.lib(MSVCR70D.dll)<br />
LIBCMT.lib(crt0dat.obj) : error LNK2005: __c_exit already defined in msvcrtd.lib(MSVCR70D.dll)<br />
LIBCMT.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCR70D.dll)<br />
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)<br />
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)<br />
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)<br />
LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)<br />
msvcrtd.lib(MSVCR70D.dll) : error LNK2005: __setmbcp already defined in LIBCMT.lib(mbctype.obj)<br />
LINK : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library<br />
LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library<br />
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup<br />
Debug/Trial.exe : fatal error LNK1120: 1 unresolved externals
When I put /NODEFAULTLIB:LIBCMT, it works fine. But I will need multi-threading for an even more important Library.
So, what are the consequences of adding that line to the commandline of Linker....... and what can I do to solve my problem without having to add it. Do I have to go back to adding all the .h and .cpp files of the library.... or .
Please help.
|
|
|
|
|
This happens when you try to link things together that have been compiled with different settings.
Go through *every* single library that you are linking in and make sure you are using the correct one i.e. multi-threaded. You also need to check the DLL/not-DLL switches are all the same as well.
Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin
Awasu 2.1.1 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Thanks
It worked fine.
|
|
|
|
|
I can host and communicate with it just fine. The only quirk is that it refuses to use the XP look and feel for buttons and other HTML controls. I have a manifest for my app. Every native/win32 control is correctly themed, so the manifest is obviously correct. In fact, IE's own scrollbar is correctly themed, just not its contents.
What did I miss?
I am hosting the control in an ATL/WTL project, but I don't think that's the problem. I should also mention that if I load the html file in IE (the "real" browser), UI controls are themed.
--
Schni Schna Schnappi! Schnappi Schnappi Schnapp!
|
|
|
|
|
This takes a few steps, and I don't think I have code for it handy at the moment, but the procedure is:
Write a COM object that implements IDocHostUIHandler .
That COM object has to be attached (vague term here, this is the part I don't have memorized) to the AtlAxWin that is hosting the WebBrowser control.
In the IDocHostUIHandler::GetHostInfo() method, do this:
HRESULT CFoo::GetHostInfo(DOCHOSTUIINFO *pInfo)
{
pInfo->dwFlags |= DOCHOSTUIFLAG_THEME;
return S_OK;
} The "attach" part is done by querying the WebBrowser control for ICustomDoc and calling its SetUIHandler() method.
Let me know if you need more help, I can try to find some working code for you.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|