|
CPallini wrote: Simply put, you cannot solve:
x + y = 2
x - y = 0
x + 3y = 4
You most certainly can find a solution. Whether it makes sense or not depends on what the equations represent. If, due to measurement or statistical errors, they really are representing the same set of parameters, then you can use least squares.
If all have the same importance and have been correctly normalized, etc., blah, blah, you simply find the minimum of:
[(x + y - 2)^2 + (x - y)^2 + (x + 3*y - 4)^2] w.r.t. x and y
If the minimum happens to be zero, the solution is exact. Otherwise it is an estimate of the parameters. The formal mathematical statement of the problem is something like
Find the set of x<small>i</small> that minimizes S = Sum{[f<small>j</small>(x<small>i</small>) - C<small>j</small>]^2}.
You can also add additional constraints to bound the problem and turn it into a nonlinear optimization problem.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Yes, you may indeed solve another problem, namely:
Given
f(x,y)=(x+y-2)^2 + (x-y)^2 + (x+3*y-4)^2
find the value of the pair {x,y} which minimize f(x,y).
However, that has not to do with the original linear algebric system.
The algebric system has not solutions according to the Rouché-Capelli theorem (and common sense).
Anyway, might be the OP really needed the solution to the least squares problem (i.e. I misunderstood his requirements), who knows?
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]
|
|
|
|
|
Yes, but you can solve
x + y = 2 + a
x - y = 0 + b
x + 3y = 4 + c
to find the x and y that makes a2+b2+c2 the minimum possible.
Clearly they will be not the "solution" of the system, but the value that minimize the "error" in having AX != B
Also note that - even in case of linear dependency - the method works well (it just gives the solution with a null minimum squared error, that is the -at that point- one and only solution).
Note also (not directly related to the post in answer) that saying that one particular equation is redundant is improper: all equation have the same dignity. Hence "find which equation to exclude" is a mis-posed problem. I can exclude another and get the same solution.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
emilio_grv wrote: Yes, but you can solve
x + y = 2 + ax - y = 0 + bx + 3y = 4 + c
to find the x and y that makes a2+b2+c2 the minimum possible.
That is just another 'new' different problem.
And what would be the 'practical' usefulness of the solution of such new problem is questionable. Consider, for instance, if the original system is, by remote chance:
x = 1000
x = 0
emilio_grv wrote: Note also (not directly related to the post in answer) that saying that one particular equation is redundant is improper: all equation have the same dignity. Hence "find which equation to exclude" is a mis-posed problem. I can exclude another and get the same solution.
It was a quick way to say: "when you have two linearly dependent equations, you may esclude one of them to find the solution", of course all the equations have the same dignity in the system, anyway you can arbitrarly choose one to solve the system.
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]
modified on Saturday, July 10, 2010 11:21 AM
|
|
|
|
|
I've been trying to put some code together for setting a desired file creation date/time.
I also got introduced to the FILETIME structure (2 DWORD).
DWORD unsigned long 4,294,967,296 (possibles, including zero)
Hopefully I can get a string to be processed and set the file creation date/time.
So these would be the variables for the DWORD:
1 second 100
1 minute 6,000
1 hour 360,000
24 hours 8,640,000
1 year 3,153,600,000
Current resources on MSDN use SystemTime functions, out of fear of guiding someone to fake copyrighted material.
HANDLE File = CreateFile(L"My File.txt", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_WRITE_ATTRIBUTES, NULL);
SetFileTime( File, &CreationTime, NULL, NULL);
CloseHandle(File);
|
|
|
|
|
What's your point?
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]
|
|
|
|
|
i want to set the file creation date to a specific time
|
|
|
|
|
This is what you want to do. Now, what is the question or problem?
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]
|
|
|
|
|
what's the question ?
Watched code never compiles.
|
|
|
|
|
i want to set the file creation date/time to a desired date/time
|
|
|
|
|
And what problem are you having in doing so?
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Fareed Rizkalla wrote: Current resources on MSDN use SystemTime functions, out of fear of guiding someone to fake copyrighted material.
W.T.F. ?!
I which paranoia you've got lost ?
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Is it possible to set C as the default to convert and compile in rather than c++?
If that is not possible, how do I set a specific project to C rather than C++?
(Trying to get a vb6 converted to native c rather than c++ without total rewrite.)
Thank You,
Don
|
|
|
|
|
Why don't you give the c (instead of cpp ) extension to your files?
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]
|
|
|
|
|
The compiler driver works out what type of source file it's got based on the extension you give it. Call it .cpp and it'll use the C++ compiler, .c and it'll use the C compiler. You can overide this on a per source file basis by using /TC (compile as C) and /TP (compile as C++). It's an advanced option in the properties of the project.
Cheers,
Ash
|
|
|
|
|
Edit : Issue was mostly with the spawned EXE that did not handled parameters properly.
Now everything is working ok.
Thanks.
I'm trying to figure out a couple of issues I have with some path that contains spaces when using ShellExecuteEx :
The current directory contains space : C:\Users\me\Documents\Visual Studio 2008\Projects\asdcasd\asdcasd
TCHAR Buffer[MAX_PATH];
DWORD dwRet;
dwRet = GetCurrentDirectory(MAX_PATH, Buffer);
CString sWorkingPath;
sWorkingPath.Format( _T("\"%s\""), Buffer );
CString command ( _T("XMLtoPDF.exe"));
CString parameters( _T(""));
CString sExe;
sExe.Format ( _T("\"%s\\%s\""), Buffer, command);
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = _T("open");
ShExecInfo.lpFile = sExe;
ShExecInfo.lpParameters = parameters;
ShExecInfo.lpDirectory = sWorkingPath;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
The exe spawns a console (it's a perl byte-compiled stand-alone) and tells me the path is not good : C:\Users\me\Documents\Visual does not exists.
I've checked the path and they all semms to be double-quoted to handle the spaces.
Am i missing something ?
Thanks a bunch.
Watched code never compiles.
modified on Thursday, July 8, 2010 3:52 PM
|
|
|
|
|
Suggestions:
1) Use GetShortPathName() .
2) Use UrlEscape() .
I'm not sure if either will work, however.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I have a CFormView class that hosts a Microsoft WebBrowser ActiveX control. I use the control to browse to various HTML pages. Some of these pages create pop-up pages, through some JavaScript buttons.
Now when I browse to the site through IE, and the pop-up windows are created, they work fine and display their contents. When I browse to the site through my app, the pop-up windows are created, but I get a script error saying "A security error has occurred". I can then continue by clicking on the "Yes" button, but nothing further happens.
In my application I browse to the pages through Navigate2("http://username:password@site.blah"), thus passing some security credentials to the page. Could this be the problem ? How do I pass these credentials on to the popup (of which I have no control) ? Any other ideas as to what the problem could be ?
Thanks !
OD
|
|
|
|
|
On accessing a class member variable, the process crashes.
The class variable is a structure instance of size 108 bytes which is properly padded.
On Get_proc() which returns the structure pointer(address of the instance) it crashes.
The Get_proc() is called from another class scope.
The Stack points within the Get_proc() call and then accessing the structure address it crashes. The structure pointer is not NULL.
On making the structure instance scope as global, it does not crash.
Please do give your inputs.
user_m is a properly padded aligned structure with variables BYTE and WORD.
class User
{
private:
user_m inst_user_m;
public:
user_m* Get_proc();
}
user_m* Get_proc()
{
if (&user_m)
return &user_m;
}
|
|
|
|
|
apphia_j_79 wrote: if (&user_m)
Since inst_user_m is not a pointer, this really makes no sense.
apphia_j_79 wrote: return &user_m;
Shouldn't you be returning &inst_user_m instead?
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Does the instance of User you call Get_proc() on exist after the call to Get_proc()?
If you do something like:
user_m *grab_user_m()
{
User u;
return u.Get_proc();
}
then you're on a one way trip to stack overwrite city. From your symptoms this would be the first thing I'd look for.
Just remember: NEVER return pointers or references to lumps of data internal to a class - it'll all end in tears unless you're very careful.
Cheers,
Ash
|
|
|
|
|
Greetings,
Before I start tearing my hair out I wondered if anyone might be able to help.
Thus far I have no problem in using OLEDB with SQL Compact via an accessor BUT I simply cannot find out what native data type to map a 'bit' value to.
At present I have the following which compiles fine.
class CDBMain
{
public:
BOOL f_HubDel;
...
BEGIN_COLUMN_MAP(CDBMain)
COLUMN_ENTRY(1, f_HubDel)
...
However at runtime I have binding errors like this.
Binding entry 0 failed. Status: 2
Now I am about to rework the SQL DB schema to use a CHAR[1] but if anyone can tell me what I am doing wrong then you will save me a lot of work.
Many thanks
Alan
|
|
|
|
|
Just a guess here but did you try with bool (lowercase bool, not BOOL)? Or maybe with a bitfield type, like:
int f_HubDel:1; or unsigned int f_HubDel:1; ?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Sorry but that does not work either.
Since I posted I have been doing some digging and I found the following in atldbcli.h
DEFINE_OLEDB_TYPE_FUNCTION(SHORT ,DBTYPE_I2)
So you would think SHORT would do... Nope that fails to bind too.
I have found two solutions
1. Update atldbcli.h to include your own DEFINE_OLEDB_TYPE_FUNCTION for DBTYPE_BOOL
2. Use a CAST in the SQL command to convert the value to an int as follows.
CAST(Table.BitField AS int) AS AltName
Personally I have decided to stick to the latter.
I hope this will save someone the pain I have just been through.
Alan
|
|
|
|
|
Hi all..
I am trying to make a small exe in VC++ that shows system turn on time and the number of hours elapsed till shutdown.. can someone help to figure the method in vc++ .. I have a similar exe of VB which is working fine... Plz help me ...
Thanks in advance...
|
|
|
|