|
satheesh.yuva,
Which line is the error happening on?
Regards,
Gareth.
|
|
|
|
|
Hey guys,
I am writing a program that works with the registry.
I have the following problem when I want to read REG_SZ values. I don't know how to separate the values correctly.
Example:
Key - HKEY_LOCAL_MACHINE\Software\Classes\AviFile\Shell\Play\Command
ValueName - (Default)
C:\Program Files\Windows Media Player\wmplayer.exe /prefetch:8 /Play "%L"
Might appear also as
"c:\program files\windows\media player\wmplayer.exe" /prefetch:8 /Play "%L"
If I split the string using '"' or ' ' it won't work in all of the cases.
It's not like with parsing command line arguments where you know that a path with spaces in it will have the correct punctuation.
How does microsoft know how to parse these strings correctly?
|
|
|
|
|
mjmim wrote: How does microsoft know how to parse these strings correctly?
I cannot confirm this but I read once that they have software developers working there.
led mike
|
|
|
|
|
.
Any real answers?
|
|
|
|
|
Ok, so this is the first time I am posting up an article about programming. After reading the help I understand that I am to post up my coding, point out the obvious and state my problem so i will do that now...
1- The code:
using System;
using System.Collections;
using System.Collections.Generic;
class ClassX
{
//receives the dependent 'y' variable and then the regressors in the cast: lists<double> only
public static Matrix beta(List<double> y, List<double> reg1, List<double> reg2, List<double> reg3, List<double> reg4, List<double> reg5, List<double> reg6)
{
int n = ret_nzd.Count;
//first get the regressors into a 2-D array and then matrix into a n*7 sized matrix
double[,] a = new double[n,7];
for(int iy=0;iy<7;iy++)
for (int ix = 0; ix<7; n; ix++)
{
if (iy == 0)
a[ix, iy] = 1.0;
if (iy == 1)
a[ix, iy] = reg1[ix];
if (iy == 2)
a[ix, iy] = reg2[ix];
if (iy == 3)
a[ix, iy] = reg3[ix];
if (iy == 4)
a[ix, iy] = reg4[ix];
if (iy == 5)
a[ix, iy] = reg5[ix];
if (iy == 6)
a[ix, iy] = reg6[ix];
}
//now get the dependent variable,y, into a n*1 array and then matrix
double[,] yarray = new double[n,1];
for (int ix = 0; ix<7; n; ix++)
yarray[ix,0] = y[ix];
//define new matrices
Matrix X = new Matrix(a);
Matrix Y = new Matrix(yarray);
Matrix BetaMatrix = new Matrix(7, 1);
Matrix XTemp = new Matrix(7,7);
Matrix XdashXInverse = new Matrix(7,7);
Matrix XTransY = new Matrix(7,1);
//X'X:
Matrix XTrans = X.Transpose();
for (int ix = 0; ix < 7; ix++)
{
for (int iy = 0; iy < 7; iy++)
{
for (int iz = 0; iz < 7; iz++)
{
XTemp[ix, iy] += XTrans[ix, iz] * X[iz, iy];
}
}
}
//(X'X)^-1:
XdashXInverse = XTemp.Inverse();
//X'Y = 7*1
for (int ix = 0; ix < 7; ix++)
{
for (int iz = 0; iz < n; iz++)
{
XTransY[ix, 0] = XTrans[ix, iz] * Y[iz, 0];
}
}
//(X'X)^-1 (X'Y):
for (int ix = 0; ix < 7; ix++)
{
for (int iz = 0; iz < n; iz++)
{
BetaMatrix[ix, 0] = XdashXInverse[ix,iz] * XTransY[iz, 0];
}
}
return BetaMatrix;
}
}
2- The obvious:
I am trying to obtain a linear multi-regression model in c# but I wanted to build most of the modeling myself in order to learn c#. What you can see so far is that my data is coming in the form of a list<double> where the dependent variable is labelled y and the regressors are named reg1,...,reg6 with a count of about a thousand data points. and i want a 2d array so that i can convert to a amtrix and hence do some matrix operations on.
3- The problem:
I am using a cs file (matrix class) produced by Syed Mehroz Alam where the article was produced on this forum titled 'Application of Fraction class: Matrix class in C#'. I will not show his code as I dont think it is appropriate for me to post something produced by someone else without their consent. My problem then becomes when i try running the programme. basically I get an error from the matric class stating:
catch (Exception)
{
throw new FractionException("Conversion not possible");
}
I am not sure what I am doing wrong to get this exception error message from the matrx class. Can anyone please help?
|
|
|
|
|
Change that code to
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
throw new FractionException("Conversion not possible");
}
and see what it shows you. Better yet, set a breakpoint and step through the code to see which line blows up. The debugger will let you look at the exception details, even if you don't assign the exception to a variable.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hello,
I want to invoke methods from the unmanaged code(COM component.).
I want some suggestion for that, should i go for managed C++ wrapper or
will be it OK if i go for C#.
Basically main problem with the com is that, it has exposed one
method named Init((Inknown *) *pSYNInfo).
But they don't have exposed the SYNinfo class, which needs to be
passed to Init function. So what approach should i do so that i can
invoke the Init() function after setting the proper values to the SYNInfo
Class. Can i access the SYNInfo file by adding the header file in the
managed C++. Please help me out.
Thanks in advance.
|
|
|
|
|
|
|
What do you mean by 'special' ???
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I guess he means escape characters.
|
|
|
|
|
That's one reasonable guess. Characters not allowed in a filename is another. It's really impossible to tell.
And it's incredible how many people come here, ask oblique questions and never answer when you ask for more information to try to help them.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: What do you mean by 'special' ???
It eats all its meals with a spoon, and married its cousin.
|
|
|
|
|
Hi,
If you use an automatic property and want to reference it within the same class I assume you would specify the property but if you had another property within the same class that required validation you would reference the field.
Don't you think this is messy code?
<code>
private string _firstName;
public string FirstName
{
get
{
return _firstName;
}
set
{
_firstName = value;
}
}
public string LastName { get; set; }
public void Foo()
{
string test = _firstName + LastName;
}
</code>
|
|
|
|
|
I think automatic properties are ugly to start with.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Why not like this?
public void Foo()<br />
{<br />
string test = FirstName + LastName;<br />
}
The fact that there is a field doesn't mean you have to use it...
Robert
|
|
|
|
|
The Microsoft Coding Guidelines says you should use fields internally within a class.
I could be wrong?!?!?
|
|
|
|
|
They are guidelines. Not the law. Judge Dredd isn't going to pay a visit because of this.
|
|
|
|
|
He will if you name all your controls TextBox1 and ComboBox1 though.
Okay, I can dream...
|
|
|
|
|
He mightn't, but I will visit with the wet towel of vengeance ready to whip his sorry ass.
|
|
|
|
|
My first job was in a very small startup. The owner thought he was a developer and created variables 'a' and 'b' then when he needed more he would go to 'aa' and 'bb'
I'm still waiting to see anyone top that story, and it's true!
led mike
|
|
|
|
|
Those guidelines were probably written before automatic properties were introduced.
I made just a suggestion. You said it looked ugly...
Robert
|
|
|
|
|
Hi,
If you use an automatic property and want to reference it within the same class I assume you would specify the property but if you had another property within the same class that required validation you would reference the field.
Don't you think this is messy code?
<br />
<br />
private string _firstName;<br />
<br />
public string FirstName<br />
{<br />
<br />
get<br />
{<br />
return _firstName;<br />
}<br />
set<br />
{<br />
_firstName = value;<br />
}<br />
}<br />
<br />
public string LastName { get; set; }<br />
<br />
public void Foo()<br />
{<br />
string test = _firstName + LastName;<br />
}<br />
<br />
modified on Thursday, March 6, 2008 5:29 AM
|
|
|
|
|
tell me, is the following so hard to understand :
<font color="red">Please do not post programming questions here</font>
moreover, you were already been told so in one of your previous questions XLINQ. so, no excuse man
|
|
|
|
|
On 15th Dec 2007 you were told not to post programming questions[^] in the Lounge.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|